diff options
author | Andy Green <andy.green@linaro.org> | 2012-11-14 10:42:48 +0800 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2012-11-14 10:42:48 +0800 |
commit | 329b4f532f597ba8b6d2d93508f0c363a9072815 (patch) | |
tree | 644f7365f2c417d429bc04e2a9dccc7840b60098 |
initial commit
121 files changed, 44149 insertions, 0 deletions
diff --git a/firm/mb86h56.bin b/firm/mb86h56.bin Binary files differnew file mode 100644 index 0000000..28a5dde --- /dev/null +++ b/firm/mb86h56.bin diff --git a/fmb_driver/.cproject b/fmb_driver/.cproject new file mode 100644 index 0000000..3bafb46 --- /dev/null +++ b/fmb_driver/.cproject @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?> + +<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> +<storageModule moduleId="org.eclipse.cdt.core.settings"> +<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.447822756"> +<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.447822756" moduleId="org.eclipse.cdt.core.settings" name="Default"> +<externalSettings/> +<extensions> +<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +</extensions> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<configuration artifactName="fmb_driver" buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.447822756" name="Default" parent="org.eclipse.cdt.build.core.emptycfg"> +<folderInfo id="cdt.managedbuild.toolchain.gnu.base.447822756.1520085062" name="/" resourcePath=""> +<toolChain id="cdt.managedbuild.toolchain.gnu.base.540450204" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base"> +<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.895497214" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> +<builder id="cdt.managedbuild.target.gnu.builder.base.1389126646" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/> +<tool id="cdt.managedbuild.tool.gnu.archiver.base.619265868" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1735261600" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/> +<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1426881188" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> +<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.69386890" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.linker.base.167161972" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"> +<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1836424372" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> +<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> +<additionalInput kind="additionalinput" paths="$(LIBS)"/> +</inputType> +</tool> +<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1690037006" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/> +<tool id="cdt.managedbuild.tool.gnu.assembler.base.824597737" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> +<inputType id="cdt.managedbuild.tool.gnu.assembler.input.809473110" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> +</tool> +</toolChain> +</folderInfo> +</configuration> +</storageModule> +<storageModule moduleId="scannerConfiguration"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> +<buildTargets> +<target name="default" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildArguments/> +<buildTarget>default</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildArguments/> +<buildTarget>clean</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +</buildTargets> +</storageModule> +</cconfiguration> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<project id="fmb_driver.null.589485289" name="fmb_driver"/> +</storageModule> +</cproject> diff --git a/fmb_driver/.project b/fmb_driver/.project new file mode 100644 index 0000000..1615e09 --- /dev/null +++ b/fmb_driver/.project @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>fmb_driver</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + <dictionary> + <key>?name?</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.append_environment</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.autoBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildArguments</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildCommand</key> + <value>make</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.cleanBuildTarget</key> + <value>clean</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.contents</key> + <value>org.eclipse.cdt.make.core.activeConfigSettings</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableAutoBuild</key> + <value>false</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableCleanBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableFullBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.fullBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.stopOnError</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> + <value>true</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/fmb_driver/Makefile b/fmb_driver/Makefile new file mode 100644 index 0000000..09d8406 --- /dev/null +++ b/fmb_driver/Makefile @@ -0,0 +1,36 @@ +#
+# Makefile for MB86H55 driver
+#
+
+KERN_RELEASE := $(shell uname -r)
+
+KDIR := /lib/modules/$(KERN_RELEASE)/build
+PWD := $(shell pwd)
+DEST := /lib/modules/$(KERN_RELEASE)/$(MDIR)
+
+MASTERNAME=h55fmb
+
+EXTRA_CFLAGS += -DVERSION=\"0.0.1.0\"
+EXTRA_CFLAGS += -Wall
+EXTRA_CFLAGS += -O3
+export EXTRA_CFLAGS
+
+obj-m := $(MASTERNAME).o
+inst-m := $(MASTERNAME).ko
+
+h55fmb-objs := fmb_core.o fmb_hw.o fmb_api_table.o fmb_api.o
+
+default::
+# $(MAKE) -C $(KDIR) M=$(PWD) V=1 modules
+ $(MAKE) -C $(KDIR) M=$(PWD) modules
+
+install::
+# strip --strip-debug $(inst-m)
+ -su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); /sbin/depmod -a"
+
+clean:
+ $(RM) -r *.o *.ko *.mod.c .modules.* .*.cmd .tmp_versions
+
+uninstall::
+ -su -c "rm $(DEST)/$(inst-m); /sbin/depmod -a"
+
diff --git a/fmb_driver/S99h55fmb b/fmb_driver/S99h55fmb new file mode 100755 index 0000000..ea486d1 --- /dev/null +++ b/fmb_driver/S99h55fmb @@ -0,0 +1,76 @@ +#!/bin/sh +#----------------------------------------------------------- +# S99h55fmb --- Restart script for the MB86H55 driver +#----------------------------------------------------------- + +KERN_RELEASE=`uname -r` +LIBDIR="/lib/modules/$KERN_RELEASE/$MDIR" +FIRM_PATH="/usr/local/etc/mb86h55.bin" + +module="h55fmb" +device_num="0 1 2 3 4 5 6 7" +device="/dev/h55fmb" +#device0="/dev/h55fmb0" +#device1="/dev/h55fmb1" + +# +# Check root account +# +uid=`id | sed 's/uid=//' | sed 's/(.*//'` +if [ $uid != 0 ]; then + echo "ERROR: You are not root.!!" + exit +fi + +# +# Unload old driver module +# +grep $module /proc/modules > /dev/null +if [ $? = 0 ];then + echo -n "Unloading old MB86H55 device driver... " + /sbin/rmmod $module + echo "done." +fi + +# +# Remove old device special files +# +for i in $device_num; do + rm -f $device$i + #echo $device$i +done +#rm -f $device0 +#rm -f $device1 + +# +# Load new driver module +# +if [ -e ./$module.ko ]; then + echo -n "Loading new MB86H55 device driver(./$module.ko)... " + /sbin/insmod ./$module.ko +elif [ -e $LIBDIR/$module.ko ]; then + echo -n "Loading new MB86H55 device driver($LIBDIR/$module.ko)... " + /sbin/insmod $LIBDIR/$module.ko +else + echo "ERROR: Can't find $LIBDIR/$module.ko" + exit +fi +# /sbin/insmod $LIBDIR/$module.ko msg_lvl=1023 +# /sbin/insmod $LIBDIR/$module.ko msg_lvl=511 +echo "done." + +# +# Get major number from /proc/devices +# +major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices) + +# +# Create device special files +# +for i in $device_num; do + if [ ! -e $device$i ];then + mknod $device$i c $major $i + chmod 666 $device$i + fi +done + diff --git a/fmb_driver/fmb.h b/fmb_driver/fmb.h new file mode 100644 index 0000000..62b5b25 --- /dev/null +++ b/fmb_driver/fmb.h @@ -0,0 +1,48 @@ +/** +* @brief common header file for MB86 LSI Linux driver +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +/****************************************************************************/ +#ifndef __FMB_H__ +#define __FMB_H__ + +//#include <linux/config.h> +#include <linux/version.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/string.h> +#include <linux/errno.h> +#include <linux/slab.h> +#include <linux/interrupt.h> +#include <linux/timer.h> +#include <linux/pci.h> +#include <linux/delay.h> +#include <linux/cdev.h> +#include <linux/types.h> +#include <linux/poll.h> +#include <asm/io.h> +#include <asm/uaccess.h> +#include <linux/sched.h> +#include <linux/wait.h> + +#include "fmb_msg.h" +#include "fmb_hw.h" +#include "fmb_core.h" + +/********************************************************/ +/* GROBAL VALUES */ +/********************************************************/ + +#endif /* ndef __FMB_H__ */ diff --git a/fmb_driver/fmb_api.c b/fmb_driver/fmb_api.c new file mode 100644 index 0000000..f9ab7eb --- /dev/null +++ b/fmb_driver/fmb_api.c @@ -0,0 +1,2913 @@ +/** +* @brief LSI Core Application dependence part class for MB86 Linux driver. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + + +/* + * 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. + */ + +/****************************************************************************/ +#include "fmb_api.h" + +#ifndef VERSION +#define VERSION "?.?.?.?" +#endif + +PREPARE_DEBUG_FOR_FUNC(); +//static DECLARE_WAIT_QUEUE_HEAD(sys_cmd_ack_wait); +//static DECLARE_WAIT_QUEUE_HEAD(sys_msg_wait); +//static DECLARE_WAIT_QUEUE_HEAD(video_msg_wait); +//static DECLARE_WAIT_QUEUE_HEAD(audio_msg_wait); +//static DECLARE_WAIT_QUEUE_HEAD(xerror_info_wait); +//static DECLARE_WAIT_QUEUE_HEAD(vudata_info_wait); + +/********************************************************/ +/* GROBAL VALUES */ +/********************************************************/ +//extern const struct fmb_param_head_table fmb_param_table[]; +extern const struct fmb_param_head_table g_Fmb_param_table[]; + +/********************************************************/ +/* */ +/* MB86 core register processing function */ +/* (Application part) */ +/* */ +/********************************************************/ + +/** +* @brief Get the parameter information for MB86 +* @param[in] hw_priv_p private data pointer +* @param[in] id parameter id +* @return fmb_param_table* parameter table data +* @note None +* @attention None +*/ +static struct fmb_param_table* fmb_api_get_param_table_data(struct fmb_hard_private* hw_priv_p, + unsigned long id ) +{ + int minor; + int i; + struct fmb_param_table* second_table_addr; + + minor = hw_priv_p->minor; + i = 0; + second_table_addr = NULL; + MSG(INTERNAL_LOG, minor, "START"); + + /* serch first table */ + while (g_Fmb_param_table[i].second_table_addr != NULL) { + + if (((id >> 16) & 0xffff) == g_Fmb_param_table[i].id_up_16bit) { + /* id(upper 16bit) found! */ + second_table_addr = (void *)g_Fmb_param_table[i].second_table_addr; + break; + } + else { + i++; /* next */ + } + } + + if (second_table_addr == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "second table not found....."); + return NULL; + } + + /* check array size(lower 16bit) */ + if (((id & 0xffff) + 1) > g_Fmb_param_table[i].second_table_size) { + MSG(INTERNAL_ERR_LVL, minor, "second table is invalid....."); + return NULL; + } + + if (second_table_addr[(id & 0xffff)].valid == 1) { + MSG(INTERNAL_LOG, minor, "END"); + return &second_table_addr[(id & 0xffff)]; + } + else { + MSG(INTERNAL_ERR_LVL, minor, "id is not supported....."); + return NULL; + } +} + +/** +* @brief ioctl() FMB_API_GET_PARAM Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_get_param(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned short read_data; + unsigned short* prm_data; + unsigned long counter; + unsigned long* prm_id; + struct fmb_param_info param_info; + struct fmb_param_table* table_data; + + minor = hw_priv_p->minor; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(¶m_info, (void*)argp, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_param_info)"); + return -EFAULT; + } + + prm_id = param_info.prm_id; + prm_data = param_info.prm_data; + + for (counter = 1 ; counter < param_info.prm_num+1 ; counter++) { + table_data = fmb_api_get_param_table_data(hw_priv_p, *prm_id); + + if (table_data != NULL) { + MSG(IOCTL_FUNC, minor, "offset:0x%lx, shift:0x%x, mask: 0x%x ", + table_data->offset, table_data->shift, table_data->mask ); + read_data = Fmb_hw_reg_read_lsi(hw_priv_p, table_data->offset); + read_data = ((read_data >> table_data->shift) & table_data->mask); + + if (copy_to_user(prm_data, &read_data, sizeof(unsigned short))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + /* set error result(prm_num) */ + param_info.prm_num = counter; + if (copy_to_user((void*)argp, ¶m_info, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + } + return -EFAULT; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter ID is abnormal."); + /* set error result(prm_num) */ + param_info.prm_num = counter; + if (copy_to_user((void*)argp, ¶m_info, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + } + return -EINVAL; + } + prm_id++; + prm_data++; + } + + /* set result(prm_num = 0) */ + param_info.prm_num = 0 ; + if (copy_to_user((void*)argp, ¶m_info, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + } + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SET_PARAM Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_set_param(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned short* prm_data; + unsigned long counter; + unsigned long* prm_id; + struct fmb_param_info param_info; + struct fmb_param_table* table_data; + + minor = hw_priv_p->minor; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(¶m_info, (void*)argp, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_param_info)"); + return -EFAULT; + } + + prm_id = param_info.prm_id; + prm_data = param_info.prm_data; + + for (counter = 1 ; counter < param_info.prm_num+1 ; counter++) { + table_data = fmb_api_get_param_table_data(hw_priv_p, *prm_id); + + if (table_data != NULL) { + if (*prm_data & ~table_data->mask) { + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter data is abnormal."); + /* set error result(prm_num) */ + param_info.prm_num = counter; + if (copy_to_user((void*)argp, ¶m_info, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + } + return -EINVAL; + } + /* set parameter data */ + MSG(IOCTL_FUNC, minor, "offset:0x%lx, shift:0x%x, mask: 0x%x, data:0x%x", + table_data->offset, table_data->shift, table_data->mask, *prm_data ); + Fmb_hw_reg_rmw_lsi(hw_priv_p, table_data->offset, table_data->shift, + table_data->mask, *prm_data); + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter ID is abnormal."); + /* set error result(prm_num) */ + param_info.prm_num = counter; + if (copy_to_user((void*)argp, ¶m_info, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + } + return -EINVAL; + } + prm_id++; + prm_data++; + } + + /* set result(prm_num = 0) */ + param_info.prm_num = 0 ; + if (copy_to_user((void*)argp, ¶m_info, sizeof(struct fmb_param_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_param_info)"); + } + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SEND_SYS_CMD Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT command ack timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_send_sys_cmd(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int result; + unsigned long flags; + struct fmb_cmd_sys_info cmd_sys_info; + struct fmb_sys_cmd_buf* sys_cmd_buf; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&cmd_sys_info, (void*)argp, sizeof(struct fmb_cmd_sys_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_cmd_sys_info)"); + return -EFAULT; + } + + /* check SYNC ASYNC mode */ + if (cmd_sys_info.sync == FMB_MODE_SYNC) { + /* sync mode */ + if (down_interruptible(&priv_p->sys_cmd_sync_send_mutex)) { + /** Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt in wait mutex."); + return -ERESTARTSYS; + } + } + + /** check buffer active */ + spin_lock_irqsave(&priv_p->cmd_sys_queue.lock, flags); + if (!priv_p->cmd_sys_queue.isactive) { + spin_unlock_irqrestore(&priv_p->cmd_sys_queue.lock, flags); + if(cmd_sys_info.sync == FMB_MODE_SYNC) { + up(&priv_p->sys_cmd_sync_send_mutex); + } + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->cmd_sys_queue.lock, flags); + + /** Save Request System Command */ + sys_cmd_buf = Fmb_core_get_free_cmd_sys_buf(priv_p, &priv_p->cmd_sys_queue); + if (sys_cmd_buf != NULL) { + sys_cmd_buf->cmd.reg[0] = (FMB_SYS_CMD_DESTINATION_ID_SET & FMB_SYS_CMD_DESTINATION_ID_MASK) + << FMB_SYS_CMD_DESTINATION_ID_SHIFT; + sys_cmd_buf->cmd.reg[2] = ((cmd_sys_info.id & FMB_SYS_CMD_CMD_ID_MASK) + << FMB_SYS_CMD_CMD_ID_SHIFT) | + ((cmd_sys_info.sub_id & FMB_SYS_CMD_SUB_CMD_ID_MASK) + << FMB_SYS_CMD_SUB_CMD_ID_SHIFT); + sys_cmd_buf->cmd.reg[3] = cmd_sys_info.body; + + sys_cmd_buf->cmd.distinct = cmd_sys_info.distinct; + sys_cmd_buf->cmd.sync = cmd_sys_info.sync; + + MSG(IOCTL_FUNC, minor, "id:0x%x, sub_id:0x%x, body: 0x%x, distinct:0x%lx, sync:0x%x ", + cmd_sys_info.id, cmd_sys_info.sub_id, cmd_sys_info.body, + (unsigned long)cmd_sys_info.distinct, cmd_sys_info.sync); + Fmb_core_add_busy_cmd_sys_buf(priv_p, &priv_p->cmd_sys_queue ,sys_cmd_buf); + } + else { + if(cmd_sys_info.sync == FMB_MODE_SYNC) { + up(&priv_p->sys_cmd_sync_send_mutex); + } + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a free system command buffer."); + return -EAGAIN; + } + + /** tasklet schedule */ + tasklet_schedule(&priv_p->cmd_sys_tasklet); + + if (cmd_sys_info.sync == FMB_MODE_SYNC) { + /* wait for ACK receive */ +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->sys_cmd_ack_wait_sync, + priv_p->sys_cmd_ack_rcv_flag == FMB_SYS_CMD_ACK_RECEIVE, + (FMB_CODEC_CACK_SYS_TIME * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->sys_cmd_ack_wait_sync, + priv_p->sys_cmd_ack_rcv_flag == FMB_SYS_CMD_ACK_RECEIVE, + (FMB_CODEC_CACK_SYS_TIME * HZ) / 1000); +#endif + priv_p->sys_cmd_ack_rcv_flag = FMB_SYS_CMD_ACK_NONE; + + if (result == 0) { + /** system command ack receive timeout */ + up(&priv_p->sys_cmd_sync_send_mutex); + MSG(KERN_ERR_LVL, minor, "FMB Codec LSI system command ack receive timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /** Signal(ctrl+c etc) interrupt */ + up(&priv_p->sys_cmd_sync_send_mutex); + MSG(KERN_ERR_LVL, minor, "Signal interrupt with system command ack receive wait."); + return -ERESTARTSYS; + } + + cmd_sys_info.id = priv_p->sys_cmd_ack_info.id; + cmd_sys_info.sub_id = priv_p->sys_cmd_ack_info.sub_id; + + if (copy_to_user((void*)argp, &cmd_sys_info, sizeof(struct fmb_cmd_sys_info))) { + up(&priv_p->sys_cmd_sync_send_mutex); + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_sys_info)\n"); + return -EFAULT; + } + + up(&priv_p->sys_cmd_sync_send_mutex); + } + + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SEND_VIDEO_CMD Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_send_video_cmd(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned long counter; + unsigned short* cprm_data; + unsigned long flags; + unsigned long offset; + unsigned long* cprm_id; + struct fmb_cmd_video_info cmd_video_info; + struct fmb_param_table* param_table; + struct fmb_video_cmd_buf* video_cmd_buf; + struct fmb_core_private* priv_p; + + counter = 1; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&cmd_video_info, (void*)argp, sizeof(struct fmb_cmd_video_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_cmd_video_info)"); + return -EFAULT; + } + + /* check buffer active */ + spin_lock_irqsave(&priv_p->cmd_video_queue.lock, flags); + if (!priv_p->cmd_video_queue.isactive) { + spin_unlock_irqrestore(&priv_p->cmd_video_queue.lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->cmd_video_queue.lock, flags); + + /* Save Request Video Command */ + video_cmd_buf = Fmb_core_get_free_cmd_video_buf(priv_p, &priv_p->cmd_video_queue); + if (video_cmd_buf != NULL) { + cprm_id = cmd_video_info.cprm_id; + cprm_data = cmd_video_info.cprm_data; + + for(counter = 1 ; counter < cmd_video_info.cprm_num+1 ; counter++) { + param_table = fmb_api_get_param_table_data(hw_priv_p, *cprm_id); + + if (param_table != NULL) { + if (*cprm_data & ~param_table->mask) { + MSG(INTERNAL_ERR_LVL, minor, "Specified command parameter data is abnormal."); + /* set error result(cprm_num) */ + cmd_video_info.cprm_num = counter; + if (copy_to_user((void*)argp, &cmd_video_info, sizeof(struct fmb_cmd_video_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_video_info)"); + } + Fmb_core_add_free_cmd_video_buf(priv_p, &priv_p->cmd_video_queue, video_cmd_buf); + return -EINVAL; + } + /* set command parameter data */ + offset = param_table->offset / 2; + *cprm_data = *cprm_data << param_table->shift; + video_cmd_buf->cmd.reg[offset] = (video_cmd_buf->cmd.reg[offset] & ~param_table->mask) | *cprm_data; + MSG(IOCTL_FUNC, minor, "offset:0x%lx, data:0x%x", + param_table->offset, video_cmd_buf->cmd.reg[offset]); + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified commnad parameter ID is abnormal."); + /* set error result(cprm_num) */ + cmd_video_info.cprm_num = counter; + if (copy_to_user((void*)argp, &cmd_video_info, sizeof(struct fmb_cmd_video_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_video_info)"); + } + Fmb_core_add_free_cmd_video_buf(priv_p, &priv_p->cmd_video_queue, video_cmd_buf); + return -EINVAL; + } + cprm_id++; + cprm_data++; + } + Fmb_core_add_busy_cmd_video_buf(priv_p, &priv_p->cmd_video_queue, video_cmd_buf); + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a free video command buffer."); + /* set error result(cprm_num) */ + cmd_video_info.cprm_num = counter; + if (copy_to_user((void*)argp, &cmd_video_info, sizeof(struct fmb_cmd_video_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_video_info)"); + } + return -EAGAIN; + } + + /* set result(cprm_num = 0) */ + cmd_video_info.cprm_num = 0 ; + if (copy_to_user((void*)argp, &cmd_video_info, sizeof(struct fmb_cmd_video_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_video_info)"); + } + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SEND_AUDIO_CMD Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_send_audio_cmd(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned long counter; + unsigned short* cprm_data; + unsigned long flags; + unsigned long offset; + unsigned long* cprm_id; + struct fmb_cmd_audio_info cmd_audio_info; + struct fmb_param_table* param_table; + struct fmb_audio_cmd_buf* audio_cmd_buf; + struct fmb_core_private* priv_p; + + counter = 1; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&cmd_audio_info, (void*)argp, sizeof(struct fmb_cmd_audio_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_cmd_audio_info)"); + return -EFAULT; + } + + /* check buffer active */ + spin_lock_irqsave(&priv_p->cmd_audio_queue.lock, flags); + if (!priv_p->cmd_audio_queue.isactive) { + spin_unlock_irqrestore(&priv_p->cmd_audio_queue.lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->cmd_audio_queue.lock, flags); + + /* Save Request Audio Command */ + audio_cmd_buf = Fmb_core_get_free_cmd_audio_buf(priv_p, &priv_p->cmd_audio_queue); + if (audio_cmd_buf != NULL) { + cprm_id = cmd_audio_info.cprm_id; + cprm_data = cmd_audio_info.cprm_data; + MSG(IOCTL_FUNC, minor, "cprm_id:0x%lx, cprm_data:0x%x", + *cmd_audio_info.cprm_id, *cmd_audio_info.cprm_data); + + for(counter = 1 ; counter < cmd_audio_info.cprm_num+1 ; counter++) { + param_table = fmb_api_get_param_table_data(hw_priv_p, *cprm_id); + + if (param_table != NULL) { + if (*cprm_data & ~param_table->mask) { + MSG(INTERNAL_ERR_LVL, minor, "Specified command parameter data is abnormal."); + /* set error result(cprm_num) */ + cmd_audio_info.cprm_num = counter ; + if (copy_to_user((void*)argp, &cmd_audio_info, sizeof(struct fmb_cmd_audio_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_audio_info)"); + } + Fmb_core_add_free_cmd_audio_buf(priv_p, &priv_p->cmd_audio_queue, audio_cmd_buf); + return -EINVAL; + } + /* set command parameter data */ + offset = param_table->offset / 2; + *cprm_data = *cprm_data << param_table->shift; + audio_cmd_buf->cmd.reg[offset] = (audio_cmd_buf->cmd.reg[offset] & ~param_table->mask) | *cprm_data; + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified commnad parameter ID is abnormal."); + /* set error result(cprm_num) */ + cmd_audio_info.cprm_num = counter ; + if (copy_to_user((void*)argp, &cmd_audio_info, sizeof(struct fmb_cmd_audio_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_audio_info)"); + } + Fmb_core_add_free_cmd_audio_buf(priv_p, &priv_p->cmd_audio_queue, audio_cmd_buf); + return -EINVAL; + } + cprm_id++; + cprm_data++; + } + Fmb_core_add_busy_cmd_audio_buf(priv_p, &priv_p->cmd_audio_queue ,audio_cmd_buf); + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a free audio command buffer."); + /* set error result(cprm_num) */ + cmd_audio_info.cprm_num = counter ; + if (copy_to_user((void*)argp, &cmd_audio_info, sizeof(struct fmb_cmd_audio_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_audio_info)"); + } + return -EAGAIN; + } + + /* set result(cprm_num = 0) */ + cmd_audio_info.cprm_num = 0 ; + if (copy_to_user((void*)argp, &cmd_audio_info, sizeof(struct fmb_cmd_audio_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_audio_info)"); + } + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_GET_SYS_CMD_ACK Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT command ack timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_get_sys_cmd_ack(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + int result; + unsigned long flags; + struct fmb_cmd_ack_sys_info cmd_ack_info; + struct fmb_cmd_ack_sys_buf* cmd_ack_buf = NULL; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&cmd_ack_info, (void*)argp, sizeof(struct fmb_cmd_ack_sys_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_cmd_ack_sys_info)"); + return -EFAULT; + } + + /* check buffer active */ + spin_lock_irqsave(&priv_p->cmd_cack_sys_queue.lock, flags); + if (!priv_p->cmd_cack_sys_queue.isactive) { + spin_unlock_irqrestore(&priv_p->cmd_cack_sys_queue.lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->cmd_cack_sys_queue.lock, flags); + + /* check system command ack buffer */ + if (priv_p->cmd_cack_sys_queue.b_num == 0) { + MSG(IOCTL_FUNC, minor, "timeout:0x%lx", cmd_ack_info.timeout); + if (cmd_ack_info.timeout > 0) { +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->sys_cmd_ack_wait, + priv_p->cmd_cack_sys_queue.b_num != 0, + (cmd_ack_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->sys_cmd_ack_wait, + priv_p->cmd_cack_sys_queue.b_num != 0, + (cmd_ack_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* system command ack buffer get timeout */ + MSG(KERN_ERR_LVL, minor, "system command ack buffer get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with system command ack buffer get wait."); + return -ERESTARTSYS; + } + } + else if (cmd_ack_info.timeout < 0) { + result = wait_event_interruptible(priv_p->sys_cmd_ack_wait, + priv_p->cmd_cack_sys_queue.b_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with system command ack buffer get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + } + + /* get system command ack buffer */ + cmd_ack_buf = Fmb_core_get_busy_cmd_ack_sys_buf(priv_p, &priv_p->cmd_cack_sys_queue); + if (cmd_ack_buf == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a busy system command ack buffer."); + return -EAGAIN; + } + + if (copy_to_user((void*)argp, &cmd_ack_buf->cack, sizeof(struct fmb_cmd_ack_sys_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_cmd_ack_sys_info)\n"); + Fmb_core_add_free_cmd_ack_sys_buf(priv_p, &priv_p->cmd_cack_sys_queue, cmd_ack_buf); + ret = -EFAULT; + } + + Fmb_core_add_free_cmd_ack_sys_buf(priv_p, &priv_p->cmd_cack_sys_queue, cmd_ack_buf); + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_RESET_CMD_INFO Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_reset_cmd_info(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + struct fmb_cmd_info_reset cmd_info_reset; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&cmd_info_reset, (void*)argp, sizeof(struct fmb_cmd_info_reset))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_cmd_info_reset)"); + return -EFAULT; + } + + if( (cmd_info_reset.type < FMB_CMD_INFO_NONE) || (cmd_info_reset.type > FMB_CMD_INFO_ALL) ) { + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter is abnormal."); + return -EINVAL; + } + + if(cmd_info_reset.type & FMB_CMD_INFO_SYS) { + Fmb_core_reset_cmd_sys_buf(priv_p, &priv_p->cmd_sys_queue); + } + + if(cmd_info_reset.type & FMB_CMD_INFO_VIDEO) { + Fmb_core_reset_cmd_video_buf(priv_p, &priv_p->cmd_video_queue); + } + + if(cmd_info_reset.type & FMB_CMD_INFO_AUDIO) { + Fmb_core_reset_cmd_audio_buf(priv_p, &priv_p->cmd_audio_queue); + } + + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_GET_SYS_MSG Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT async message get timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_get_sys_msg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + int result; + unsigned long flags; + struct fmb_msg_sys_info msg_sys_info; + struct fmb_sys_msg_buf* sys_msg_buf = NULL; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&msg_sys_info, (void*)argp, sizeof(struct fmb_msg_sys_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_msg_sys_info)"); + return -EFAULT; + } + + /* check buffer active */ + spin_lock_irqsave(&priv_p->msg_sys_queue.lock, flags); + if (!priv_p->msg_sys_queue.isactive) { + spin_unlock_irqrestore(&priv_p->msg_sys_queue.lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->msg_sys_queue.lock, flags); + + /* check system message buffer */ + if (priv_p->msg_sys_queue.b_num == 0) { + MSG(IOCTL_FUNC, minor, "timeout:0x%lx", msg_sys_info.timeout); + if (msg_sys_info.timeout > 0) { +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->sys_msg_wait, + priv_p->msg_sys_queue.b_num != 0, + (msg_sys_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->sys_msg_wait, + priv_p->msg_sys_queue.b_num != 0, + (msg_sys_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* system message buffer get timeout */ + MSG(KERN_ERR_LVL, minor, "system message buffer get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with system message buffer get wait."); + return -ERESTARTSYS; + } + } + else if (msg_sys_info.timeout < 0) { + result = wait_event_interruptible(priv_p->sys_msg_wait, + priv_p->msg_sys_queue.b_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with system message buffer get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + } + + /* get system message buffer */ + sys_msg_buf = Fmb_core_get_busy_msg_sys_buf(priv_p, &priv_p->msg_sys_queue); + if (sys_msg_buf == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a busy system message buffer."); + return -EAGAIN; + } + + if (copy_to_user((void*)argp, &sys_msg_buf->msg, sizeof(struct fmb_msg_sys_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_msg_sys_info)\n"); + ret = -EFAULT; + } + + Fmb_core_add_free_msg_sys_buf(priv_p, &priv_p->msg_sys_queue, sys_msg_buf); + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_GET_VIDEO_MSG Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT async message get timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_get_video_msg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int result; + int ret; + unsigned short* msg; + unsigned long flags; + struct fmb_msg_video_info msg_video_info; + struct fmb_video_msg_buf* video_msg_buf = NULL; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&msg_video_info, (void*)argp, sizeof(struct fmb_msg_video_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_msg_video_info)"); + return -EFAULT; + } + + msg = msg_video_info.msg; + + /* check buffer active */ + spin_lock_irqsave(&priv_p->msg_video_queue.lock, flags); + if (!priv_p->msg_video_queue.isactive) { + spin_unlock_irqrestore(&priv_p->msg_video_queue.lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->msg_video_queue.lock, flags); + + /* check video message buffer */ + if (priv_p->msg_video_queue.b_num == 0) { + MSG(IOCTL_FUNC, minor, "timeout:0x%lx", msg_video_info.timeout); + if (msg_video_info.timeout > 0) { +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->video_msg_wait, + priv_p->msg_video_queue.b_num != 0, + (msg_video_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->video_msg_wait, + priv_p->msg_video_queue.b_num != 0, + (msg_video_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* video message buffer get timeout */ + MSG(KERN_ERR_LVL, minor, "video message buffer get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with video message buffer get wait."); + return -ERESTARTSYS; + } + } + else if (msg_video_info.timeout < 0) { + result = wait_event_interruptible(priv_p->video_msg_wait, + priv_p->msg_video_queue.b_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with video message buffer get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + } + + /* get video message buffer */ + video_msg_buf = Fmb_core_get_busy_msg_video_buf(priv_p, &priv_p->msg_video_queue); + if (video_msg_buf == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a busy video command ack buffer."); + return -EAGAIN; + } + + if (copy_to_user(msg, video_msg_buf->msg.msg, FMB_VIDEO_MSG_REG_SIZE)) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_msg_video_info.msg)"); + ret = -EFAULT; + } + + Fmb_core_add_free_msg_video_buf(priv_p, &priv_p->msg_video_queue, video_msg_buf); + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_GET_AUDIO_MSG Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT async message get timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_get_audio_msg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int result; + int ret; + unsigned short* msg; + unsigned long flags; + struct fmb_msg_audio_info msg_audio_info; + struct fmb_audio_msg_buf* audio_msg_buf = NULL; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&msg_audio_info, (void*)argp, sizeof(struct fmb_msg_audio_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_msg_audio_info)"); + return -EFAULT; + } + + msg = msg_audio_info.msg; + + /* check buffer active */ + spin_lock_irqsave(&priv_p->msg_audio_queue.lock, flags); + if (!priv_p->msg_audio_queue.isactive) { + spin_unlock_irqrestore(&priv_p->msg_audio_queue.lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified buffer is not active."); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->msg_audio_queue.lock, flags); + + /* check audio message buffer */ + if (priv_p->msg_audio_queue.b_num == 0) { + MSG(IOCTL_FUNC, minor, "timeout:0x%lx", msg_audio_info.timeout); + if(msg_audio_info.timeout > 0) { +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->audio_msg_wait, + priv_p->msg_audio_queue.b_num != 0, + (msg_audio_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->audio_msg_wait, + priv_p->msg_audio_queue.b_num != 0, + (msg_audio_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* audio message buffer get timeout */ + MSG(KERN_ERR_LVL, minor, "audio message buffer get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with audio message buffer get wait."); + return -ERESTARTSYS; + } + } + else if (msg_audio_info.timeout < 0) { + result = wait_event_interruptible(priv_p->audio_msg_wait, + priv_p->msg_audio_queue.b_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with audio message buffer get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + } + + /* get audio message buffer */ + audio_msg_buf = Fmb_core_get_busy_msg_audio_buf(priv_p, &priv_p->msg_audio_queue); + if (audio_msg_buf == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "Failed to get a busy audio message buffer."); + return -EAGAIN; + } + + if (copy_to_user(msg, audio_msg_buf->msg.msg, FMB_AUDIO_MSG_REG_SIZE)) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_msg_audio_info.msg)"); + ret = -EFAULT; + } + + Fmb_core_add_free_msg_audio_buf(priv_p, &priv_p->msg_audio_queue, audio_msg_buf); + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_INIT_PREPARE_FIRM Command Function +* @param[in] hw_priv_p private data pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT firm download preparation completion timeout +* @note None +* @attention None +*/ +static int fmb_api_init_prepare_firm(struct fmb_hard_private* hw_priv_p) +{ + int minor; + int i; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_LOG, minor, "START"); + + priv_p->firm_write_redy = 0; + priv_p->firm_write_size = 0; + + disable_irq(hw_priv_p->pci_dev_p->irq); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_DMA); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_INT); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_XERROR); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_EDERR); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_DDERR); + + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_HCPU_IRQEN_TCPU, FMB_API_HCPU_IRQEN_TCPU_DISABLE); + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_HCPU_IRQEN_TACK, FMB_API_HCPU_IRQEN_TACK_DISABLE); + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_HCPU_IRQEN_VSYNC, FMB_API_HCPU_IRQEN_VSYNC_DISABLE); + + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_IRQST_TCPU, FMB_API_IRQST_TCPU_IRQ); + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_IRQST_TACK, FMB_API_IRQST_TACK_IRQ); + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_IRQST_VSYNC, FMB_API_IRQST_VSYNC_IRQ); + + + enable_irq(hw_priv_p->pci_dev_p->irq); + + MSG(DEBUG_LVL, minor, "reset FMB Codec LSI"); + + Fmb_hw_codec_lsi_init(hw_priv_p); + + if (priv_p->irqst_clear_flg == FMB_DATA_IRQSTFLAG_OFF){ + Fmb_hw_interrupt_set(hw_priv_p); + } + /* Private data Reset */ + Fmb_core_private_data_reset(priv_p); + + /* check bootroader boot-up */ + if (FMB_LSI_REG_FIELD_READ(hw_priv_p, FMB_API_IRQST_TCPU) != FMB_API_IRQST_TCPU_IRQ) { + for (i = 0; i < FMB_CODEC_BOOTLOADER_BOOTUP_TIME; i++) { + udelay(FMB_CODEC_BOOTLOADER_BOOTUP_DELAY_TIME); + if (FMB_LSI_REG_FIELD_READ(hw_priv_p, FMB_API_IRQST_TCPU) == FMB_API_IRQST_TCPU_IRQ) { + goto up; + } + } + MSG(INTERNAL_ERR_LVL, minor, "FMB Codec LSI bootloader boot-up timeout."); + return -ETIMEDOUT; + } + +up: + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_IRQST_TCPU, FMB_API_IRQST_TCPU_IRQ); + + MSG(DEBUG_LVL, minor, "FMB Codec LSI bootloader boot-up."); + + priv_p->firm_write_redy = 1; + + MSG(INTERNAL_LOG, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_WRITE_FIRM Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EPERM initialization preparation is not completed +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_write_firm(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + struct fmb_firm_info firm_info; + unsigned short firm_data; + unsigned short banksel; + unsigned short* user_firm_data; + unsigned long write_size; + struct fmb_core_private* priv_p; + long msg_lvl_org = msg_lvl; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_LOG, minor, "START"); + + if (priv_p->firm_write_redy != 1) { + MSG(INTERNAL_ERR_LVL, minor, "initialization is not prepared"); + return -EPERM; + } + + if (copy_from_user(&firm_info, (void*)argp, sizeof(struct fmb_firm_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_firm_info)"); + return -EFAULT; + } + + MSG(DEBUG_LVL, minor, "firm_write_size(old) = 0x%08lx, firm_size = 0x%08lx", + priv_p->firm_write_size, firm_info.firm_size); + + /* ToDo : Max check of size of firm & Even number check of size of firm. */ + if (firm_info.firm_size == 0) { + MSG(INTERNAL_ERR_LVL, minor, "invalid parameter(firm_info.firm_size=%ld)", firm_info.firm_size); + return -EINVAL; + } + if (firm_info.firm_size % 2 != 0) { + MSG(INTERNAL_ERR_LVL, minor, "invalid parameter( odd firm_info.firm_size=%ld)", firm_info.firm_size); + return -EINVAL; + } + + user_firm_data = (unsigned short*)firm_info.firm_data; + + write_size = 0; + +#ifdef DISABLE_WRITE_FIRM_LOG // [ DISABLE_WRITE_FIRM_LOG + msg_lvl = 0; +#endif // DISABLE_WRITE_FIRM_LOG ] + while (write_size < firm_info.firm_size) { + if (copy_from_user(&firm_data, user_firm_data, sizeof(unsigned short))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_firm_info.firm_data)"); + return -EFAULT; + } + + banksel = ((priv_p->firm_write_size / FMB_CODEC_BANK_SIZE) * 0x8) + FMB_CODEC_BANKSEL_FIRM_DOWNLOAD_BASE; + Fmb_hw_reg_write_lsi(hw_priv_p, FMB_BANKSEL, banksel); + + Fmb_hw_reg_write_lsi(hw_priv_p, FMB_INTERNAL_RAM + (priv_p->firm_write_size % FMB_CODEC_BANK_SIZE), SWAPW(firm_data)); + + write_size += sizeof(unsigned short); + priv_p->firm_write_size += sizeof(unsigned short); + user_firm_data++; + } + msg_lvl = msg_lvl_org; + + + MSG(DEBUG_LVL, minor, "firm_write_size(new) = 0x%08lx", priv_p->firm_write_size); + + MSG(INTERNAL_LOG, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_BOOT_UP_FIRM Command Function +* @param[in] hw_priv_p private data pointer +* @return 0 normal end +* @return -EPERM firmware is not downloaded +* @return -EFAULT user buffer(argp) access error +* @return -ETIMEDOUT firm boot up completion timeout* @note None +* @return -EINVAL invalid content of parameter +* @attention None +*/ +static int fmb_api_boot_up_firm(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int i; + struct fmb_core_private* priv_p; + struct fmb_bootup_firm_info bootup_info; + wait_queue_head_t bootup_waitq; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_LOG, minor, "START"); + + if (priv_p->firm_write_size == 0) { + MSG(INTERNAL_ERR_LVL, minor, "firmware is not downloaded"); + return -EPERM; + } + + if (copy_from_user( &bootup_info, (void*)argp, sizeof( struct fmb_bootup_firm_info ) )) { + MSG(KERN_ERR_LVL, minor, "Failed in copying from user's area.(bootup_info)"); + return -EFAULT; + } + + if (bootup_info.timeout < 0) { + MSG(INTERNAL_ERR_LVL, minor, "Invalid parameter(bootup_info.timeout = %ld)", + bootup_info.timeout); + return -EINVAL; + } + + init_waitqueue_head( &bootup_waitq ); + priv_p->firm_write_size = 0; + priv_p->firm_write_redy = 0; + + /* boot-up request */ + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_SETIRQ_TCPU, FMB_API_SETIRQ_TCPU_SET); + + /* check firmware boot-up */ + if (FMB_LSI_REG_FIELD_READ(hw_priv_p, FMB_API_IRQST_TCPU) != FMB_API_IRQST_TCPU_IRQ) { + if (bootup_info.timeout > 0) { + for (i = 0; i < bootup_info.timeout; i++) { + msleep( 1 ); + if (FMB_LSI_REG_FIELD_READ(hw_priv_p, FMB_API_IRQST_TCPU) == FMB_API_IRQST_TCPU_IRQ) { + goto up; + } + } + MSG(INTERNAL_ERR_LVL, minor, "FMB Codec LSI firmware boot-up timeout."); + return -ETIMEDOUT; + } + else { + for (i = 0; i < FMB_CODEC_FIRM_BOOTUP_TIME; i++) { + msleep( FMB_CODEC_FIRM_BOOTUP_DELAY_TIME ); + if (FMB_LSI_REG_FIELD_READ(hw_priv_p, FMB_API_IRQST_TCPU) == FMB_API_IRQST_TCPU_IRQ) { + goto up; + } + } + MSG(INTERNAL_ERR_LVL, minor, "FMB Codec LSI firmware boot-up timeout."); + return -ETIMEDOUT; + } + } + +up: + MSG(DEBUG_LVL, minor, "FMB Codec LSI firmware boot-up."); + + Fmb_hw_reg_write_lsi(hw_priv_p, FMB_BANKSEL, FMB_CODEC_BANKSEL_AFTER_BOOTUP); + + disable_irq(hw_priv_p->pci_dev_p->irq); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_DMA); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_INT); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_XERROR); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_EDERR); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_DDERR); + + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_HCPU_IRQEN_TCPU, FMB_API_HCPU_IRQEN_TCPU_ENABLE); + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_HCPU_IRQEN_TACK, FMB_API_HCPU_IRQEN_TACK_ENABLE); + FMB_LSI_REG_FIELD_WRITE(hw_priv_p, FMB_API_HCPU_IRQEN_VSYNC, FMB_API_HCPU_IRQEN_VSYNC_ENABLE); + + priv_p->sys_cmd_continuity_counter = 0; + + enable_irq(hw_priv_p->pci_dev_p->irq); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_DMA); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_INT); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_XERROR); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_EDERR); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_DDERR); + + MSG(INTERNAL_LOG, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_GET_FACTOR Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -ETIMEDOUT async factor get timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_get_factor(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + int result; + struct fmb_factor_info factor_info; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&factor_info, (void*)argp, sizeof(struct fmb_factor_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_factor_info)"); + return -EFAULT; + } + + /* Hi-Level mode */ + factor_info.factor = Fmb_core_get_factor_check(priv_p); + + if (!factor_info.factor) { + if (factor_info.timeout > 0) { + MSG(IOCTL_FUNC, minor, "timeout:0x%lx", factor_info.timeout); +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(hw_priv_p->poll_waitq, + priv_p->factor_num != 0, + (factor_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(hw_priv_p->poll_waitq, + priv_p->factor_num != 0, + (factor_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* factor info get timeout */ + MSG(KERN_ERR_LVL, minor, "factor info get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with factor info get wait."); + return -ERESTARTSYS; + } + } + else if (factor_info.timeout < 0) { + result = wait_event_interruptible(hw_priv_p->poll_waitq, + priv_p->factor_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with factor info get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + factor_info.factor = Fmb_core_get_factor_check(priv_p); + } + + if (copy_to_user((void*)argp, &factor_info, sizeof(struct fmb_factor_info))) { + MSG(KERN_ERR_LVL, minor, "Failed (fmb_factor_info.factor)\n"); + return -EFAULT; + } + + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() fmb_API_RESET_FACTOR Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_reset_factor(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + + struct fmb_factor_reset factor_reset; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&factor_reset, (void*)argp, sizeof(struct fmb_factor_reset))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_factor_reset)"); + return -EFAULT; + } + + if( (factor_reset.factor < FMB_FACTOR_NONE) || (factor_reset.factor > FMB_FACTOR_ASYNC_ALL) ) { + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter is abnormal."); + return -EINVAL; + } + + if(factor_reset.factor & FMB_FACTOR_CACK_SYS) { + Fmb_core_reset_cmd_ack_sys_buf(priv_p, &priv_p->cmd_cack_sys_queue); + } + + if(factor_reset.factor & FMB_FACTOR_MSG_SYS) { + Fmb_core_reset_msg_sys_buf(priv_p, &priv_p->msg_sys_queue); + } + + if(factor_reset.factor & FMB_FACTOR_MSG_VIDEO) { + Fmb_core_reset_msg_video_buf(priv_p, &priv_p->msg_video_queue); + } + + if(factor_reset.factor & FMB_FACTOR_MSG_AUDIO) { + Fmb_core_reset_msg_audio_buf(priv_p, &priv_p->msg_audio_queue); + } + + if(factor_reset.factor & FMB_FACTOR_XERROR) { + Fmb_core_reset_xerror_info_buf(priv_p, &priv_p->xerror_info_queue); + } + + if(factor_reset.factor & FMB_FACTOR_VUDATA) { + Fmb_core_reset_vudata_buf(priv_p, &priv_p->vudata_info_queue); + } + + if(factor_reset.factor & FMB_FACTOR_EDERR) { + Fmb_core_reset_ederr_info_buf(priv_p, &priv_p->ederr_info_queue); + } + + if(factor_reset.factor & FMB_FACTOR_DDERR) { + Fmb_core_reset_dderr_info_buf(priv_p, &priv_p->dderr_info_queue); + } + + if (!Fmb_core_get_factor_check(priv_p)) { + Fmb_core_set_factor_num(priv_p, 0); + } + + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_GET_ASYNC_INFO Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT async info get timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +static int fmb_api_get_async_info(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + int result; + unsigned long flags; + unsigned short* data; + struct fmb_async_info async_info; + struct fmb_xerror_info_buf* xerror_info_buf = NULL; + struct fmb_vudata_info_buf* vudata_info_buf = NULL; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&async_info, (void*)argp, sizeof(struct fmb_async_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_async_info)"); + return -EFAULT; + } + + data = async_info.data; + MSG(IOCTL_FUNC, minor, "type:0x%lx, timeout:0x%lx", + async_info.type, async_info.timeout); + + switch (async_info.type) { + case FMB_TYPE_ASYNC_XERROR: + /* check buffer active */ + spin_lock_irqsave(&priv_p->xerror_info_queue.lock, flags); + if (!priv_p->xerror_info_queue.isactive) { + MSG(INTERNAL_ERR_LVL, minor, "xerror info buffer is not active"); + spin_unlock_irqrestore(&priv_p->xerror_info_queue.lock, flags); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->xerror_info_queue.lock, flags); + + /* check xerror info buffer */ + if (priv_p->xerror_info_queue.b_num == 0) { + if (async_info.timeout > 0) { +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->xerror_info_wait, + priv_p->xerror_info_queue.b_num != 0, + (async_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->xerror_info_wait, + priv_p->xerror_info_queue.b_num != 0, + (async_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* xerror info buffer get timeout */ + MSG(KERN_ERR_LVL, minor, "xerror info buffer get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with xerror info buffer get wait."); + return -ERESTARTSYS; + } + } + else if (async_info.timeout < 0) { + result = wait_event_interruptible(priv_p->xerror_info_wait, + priv_p->xerror_info_queue.b_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with xerror info buffer get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + } + + /* get xerror info buffer */ + xerror_info_buf = Fmb_core_get_busy_xerror_info_buf(priv_p, &priv_p->xerror_info_queue); + if (xerror_info_buf == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "xerror info buffer none"); + return -EAGAIN; + } + + if (copy_to_user(data, xerror_info_buf->msg.data, FMB_XERROR_INFO_REG_SIZE)) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_async_info.msg)"); + Fmb_core_add_free_xerror_info_buf(priv_p, &priv_p->xerror_info_queue, xerror_info_buf); + ret = -EFAULT; + break; + } + + Fmb_core_add_free_xerror_info_buf(priv_p, &priv_p->xerror_info_queue, xerror_info_buf); + break; + case FMB_TYPE_ASYNC_VUDATA: + /* check buffer active */ + spin_lock_irqsave(&priv_p->vudata_info_queue.lock, flags); + if (!priv_p->vudata_info_queue.isactive) { + MSG(INTERNAL_ERR_LVL, minor, "vudata info buffer is not active"); + spin_unlock_irqrestore(&priv_p->vudata_info_queue.lock, flags); + return -EAGAIN; + } + spin_unlock_irqrestore(&priv_p->vudata_info_queue.lock, flags); + + /* check vudata info buffer */ + if (priv_p->vudata_info_queue.b_num == 0) { + if (async_info.timeout > 0) { +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->vudata_info_wait, + priv_p->vudata_info_queue.b_num != 0, + (async_info.timeout * HZ) / 1000); +#else + result = wait_event_timeout(priv_p->vudata_info_wait, + priv_p->vudata_info_queue.b_num != 0, + (async_info.timeout * HZ) / 1000); +#endif + if (result == 0) { + /* vudata info buffer get timeout */ + MSG(KERN_ERR_LVL, minor, "vudata info buffer get timeout."); + return -ETIMEDOUT; + } + else if (result == -ERESTARTSYS) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with vudata info buffer get wait."); + return -ERESTARTSYS; + } + } + else if (async_info.timeout < 0) { + result = wait_event_interruptible(priv_p->vudata_info_wait, + priv_p->vudata_info_queue.b_num != 0); + if (result != 0) { + /* Signal(ctrl+c etc) interrupt */ + MSG(KERN_ERR_LVL, minor, "Signal interrupt with vudata info buffer get wait."); + return -ERESTARTSYS; + } + } + else { + MSG(INTERNAL_ERR_LVL, minor, "Specified timeout value is zero."); + return -EAGAIN; + } + } + + /* get vudata info buffer */ + vudata_info_buf = Fmb_core_get_busy_vudata_buf(priv_p, &priv_p->vudata_info_queue); + if (vudata_info_buf == NULL) { + MSG(INTERNAL_ERR_LVL, minor, "vudata info buffer none"); + return -EAGAIN; + } + + if (copy_to_user(data, vudata_info_buf->msg.data, FMB_VUDATA_INFO_REG_SIZE)) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy to user's area.(fmb_async_info.msg)"); + Fmb_core_add_free_vudata_buf(priv_p, &priv_p->vudata_info_queue, vudata_info_buf); + ret = -EFAULT; + break; + } + + Fmb_core_add_free_vudata_buf(priv_p, &priv_p->vudata_info_queue, vudata_info_buf); + break; + default: + MSG(INTERNAL_ERR_LVL, minor, "invalid type"); + ret = -EINVAL; + break; + } + + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_GET_LSI_REG Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_get_lsi_reg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned short read_data; + unsigned short* prm_data; + unsigned long counter; + unsigned long offset_addr; + unsigned long access_size; + struct fmb_reg_info reg_info; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(®_info, (void*)argp, sizeof(struct fmb_reg_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_reg_info)"); + return -EFAULT; + } + + prm_data = reg_info.prm_data; + offset_addr = reg_info.offset; + access_size = reg_info.reg_num * sizeof(unsigned short); + + if (Fmb_hw_check_addr_lsi(hw_priv_p, offset_addr, access_size)){ + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter is abnormal."); + return -EINVAL; + } + + for (counter = 0 ; counter < reg_info.reg_num ; counter++) { + + MSG(IOCTL_FUNC, minor, "offset_addr:0x%lx", offset_addr); + read_data = Fmb_hw_reg_read_lsi(hw_priv_p, offset_addr); + + if (copy_to_user(prm_data, &read_data, sizeof(unsigned short))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_reg_info)"); + return -EFAULT; + } + prm_data++; + offset_addr += 2; + } + + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SET_LSI_REG Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_set_lsi_reg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned short write_data; + unsigned short* prm_data; + unsigned long counter; + unsigned long offset_addr; + unsigned long access_size; + struct fmb_reg_info reg_info; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(®_info, (void*)argp, sizeof(struct fmb_reg_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_reg_info)"); + return -EFAULT; + } + + prm_data = reg_info.prm_data; + + offset_addr = reg_info.offset; + access_size = reg_info.reg_num * sizeof(unsigned short); + + if (Fmb_hw_check_addr_lsi(hw_priv_p, offset_addr, access_size)){ + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter is abnormal."); + return -EINVAL; + } + + for (counter = 0 ; counter < reg_info.reg_num ; counter++) { + if (copy_from_user(&write_data, prm_data, sizeof(unsigned short))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_reg_info)"); + return -EFAULT; + } + + MSG(IOCTL_FUNC, minor, "offset_addr:0x%lx, write_data:0x%x", offset_addr, write_data); + Fmb_hw_reg_write_lsi(hw_priv_p, offset_addr, write_data); + + prm_data++; + offset_addr += 2; + } + + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_GET_INTERNAL_DATA Command Function +* @param[in] hw_priv_p private data pointer +* @param[in,out] type data type +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_get_internal_data(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + unsigned long flags; + struct fmb_internal_info internal_info; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&internal_info, (void*)argp, sizeof(struct fmb_internal_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_internal_info)"); + return -EFAULT; + } + + internal_info.data = -1; + + spin_lock_irqsave(&priv_p->lock_core_priv, flags); + switch (internal_info.type) { + case FMB_DATA_TYPE_ENCODE: + internal_info.data = priv_p->encode_mode; + break; + case FMB_DATA_TYPE_NOTIFY: + internal_info.data = priv_p->notify_mode; + break; + case FMB_DATA_TYPE_RDMAFLAG: + internal_info.data = priv_p->read_dma_flg; + break; + case FMB_DATA_TYPE_WDMAFLAG: + internal_info.data = priv_p->write_dma_flg; + break; + case FMB_DATA_TYPE_IRQSTFLAG: + internal_info.data = priv_p->irqst_clear_flg; + break; + case FMB_DATA_TYPE_VSYNC: + internal_info.data = priv_p->vsync_mode; + break; + default: + spin_unlock_irqrestore(&priv_p->lock_core_priv, flags); + MSG(INTERNAL_ERR_LVL, minor, "Specified parameter is abnormal."); + return -EINVAL; + } + spin_unlock_irqrestore(&priv_p->lock_core_priv, flags); + + if (copy_to_user((void*)argp, &internal_info, sizeof(struct fmb_internal_info))) { + MSG(KERN_ERR_LVL, minor, "Failed (fmb_internal_info)\n"); + return -EFAULT; + } + + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SET_INTERNAL_DATA Command Function +* @param[in] hw_priv_p private data pointer +* @param[in] type data type +* @param[in] data setting data +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ +static int fmb_api_set_internal_data(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int ret; + unsigned long flags; + struct fmb_internal_info internal_info; + struct fmb_core_private* priv_p; + + ret = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + MSG(INTERNAL_LOG, minor, "START"); + + if (copy_from_user(&internal_info, (void*)argp, sizeof(struct fmb_internal_info))) { + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_internal_info)"); + return -EFAULT; + } + MSG(IOCTL_FUNC, minor, "type:0x%lx, data:0x%lx", + internal_info.type, internal_info.data); + + spin_lock_irqsave(&priv_p->lock_core_priv, flags); + switch (internal_info.type) { + case FMB_DATA_TYPE_ENCODE: + if( (internal_info.data < FMB_DATA_ENCODE_TOP) || (internal_info.data > FMB_DATA_ENCODE_BOTTOM) ) { + ret = -EINVAL; + break; + } + priv_p->encode_mode = internal_info.data; + break; + case FMB_DATA_TYPE_NOTIFY: + if( (internal_info.data < FMB_DATA_NOTIFY_NONE) || (internal_info.data > FMB_DATA_NOTIFY_ALL) ) { + ret = -EINVAL; + break; + } + priv_p->notify_mode = internal_info.data; + break; + case FMB_DATA_TYPE_RDMAFLAG: + if( (internal_info.data != FMB_DATA_DMAFLAG_OFF) && (internal_info.data != FMB_DATA_DMAFLAG_ON) ) { + ret = -EINVAL; + break; + } + priv_p->read_dma_flg = internal_info.data; + break; + case FMB_DATA_TYPE_WDMAFLAG: + if( (internal_info.data != FMB_DATA_DMAFLAG_OFF) && (internal_info.data != FMB_DATA_DMAFLAG_ON) ) { + ret = -EINVAL; + break; + } + priv_p->write_dma_flg = internal_info.data; + break; + case FMB_DATA_TYPE_IRQSTFLAG: + if( (internal_info.data != FMB_DATA_IRQSTFLAG_ON) && (internal_info.data != FMB_DATA_IRQSTFLAG_OFF) ) { + ret = -EINVAL; + break; + } + if(internal_info.data == FMB_DATA_IRQSTFLAG_ON){ + if (priv_p->irqst_clear_flg == FMB_DATA_IRQSTFLAG_ON){ + spin_unlock_irqrestore(&priv_p->lock_core_priv, flags); + return ret; + } + Fmb_hw_interrupt_set(hw_priv_p); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_DMA); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_INT); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_XERROR); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_EDERR); + Fmb_hw_enable_irq(hw_priv_p, IRQ_FMB_DDERR); + } + else if(internal_info.data == FMB_DATA_IRQSTFLAG_OFF){ + free_irq(hw_priv_p->pci_dev_p->irq, hw_priv_p); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_DMA); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_INT); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_XERROR); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_EDERR); + Fmb_hw_disable_irq(hw_priv_p, IRQ_FMB_DDERR); + } + priv_p->irqst_clear_flg = internal_info.data; + break; + case FMB_DATA_TYPE_VSYNC: + if( (internal_info.data < FMB_DATA_VSYNC_ALL) || (internal_info.data > FMB_DATA_VSYNC_BOTTOM) ) { + ret = -EINVAL; + break; + } + priv_p->vsync_mode = internal_info.data; + break; + default: + ret = -EINVAL; + break; + } + spin_unlock_irqrestore(&priv_p->lock_core_priv, flags); + + MSG(INTERNAL_LOG, minor, "END"); + return ret; +} + +/** +* @brief ioctl() FMB_API_GET_PCI_REG Command Function +* +* @param[in] priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ + +static int fmb_api_get_pci_reg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int result; + unsigned long read_data; + unsigned long* prm_data_p; + unsigned long counter; + unsigned long offset_addr; + unsigned long access_size; + struct fmb_pci_reg_info pci_reg_info; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + result = copy_from_user(&pci_reg_info, (void*)argp, sizeof(struct fmb_pci_reg_info)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_pci_reg_info)"); + return -EFAULT; + } + + prm_data_p = pci_reg_info.prm_data; + offset_addr = pci_reg_info.offset; + access_size = pci_reg_info.reg_num * sizeof(unsigned long); + + if (Fmb_hw_check_addr_pci(hw_priv_p, pci_reg_info.reg_type, offset_addr, access_size)){ + MSG(INTERNAL_ERR_LVL, minor, "PCI access area error"); + return -EINVAL; + } + + for (counter = 0 ; counter < pci_reg_info.reg_num ; counter++) { + MSG(IOCTL_FUNC, minor, "offset_addr:0x%lx, offset_addr:0x%lx, access_size:0x%lx", + *prm_data_p, offset_addr, access_size); + if(pci_reg_info.reg_type == FMB_TYPE_DMA){ + read_data = Fmb_hw_reg_read_dma(hw_priv_p, offset_addr); + MSG(DEBUG_LVL, minor, "get dma register"); + } else if(pci_reg_info.reg_type == FMB_TYPE_LSI){ + read_data = Fmb_hw_reg_read_lsi_master(hw_priv_p, offset_addr); + MSG(DEBUG_LVL, minor, "get lsi register"); + } + result = copy_to_user(prm_data_p, &read_data, sizeof(unsigned long)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_pci_reg_info)"); + return -EFAULT; + } + prm_data_p++; + offset_addr += 2; + } + MSG(DRIVER_FUNC_LVL, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_SET_PCI_REG Command Function +* +* @param[in] priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ + +static int fmb_api_set_pci_reg(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int result; + unsigned long write_data; + unsigned long* prm_data_p; + unsigned long counter; + unsigned long offset_addr; + unsigned long access_size; + struct fmb_pci_reg_info pci_reg_info; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + result = copy_from_user(&pci_reg_info, (void*)argp, sizeof(struct fmb_pci_reg_info)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_pci_reg_info)"); + return -EFAULT; + } + + prm_data_p = pci_reg_info.prm_data; + + offset_addr = pci_reg_info.offset; + access_size = pci_reg_info.reg_num * sizeof(unsigned long); + + if (Fmb_hw_check_addr_pci(hw_priv_p, pci_reg_info.reg_type, offset_addr, access_size)){ + MSG(INTERNAL_ERR_LVL, minor, "PCI access area error"); + return -EINVAL; + } + + for (counter = 0 ; counter < pci_reg_info.reg_num ; counter++) { + MSG(IOCTL_FUNC, minor, "offset_addr:0x%lx, offset_addr:0x%lx, access_size:0x%lx, write_data:0x%lx", + *prm_data_p, offset_addr, access_size, write_data); + result = copy_from_user(&write_data, prm_data_p, sizeof(unsigned long)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_pci_reg_info)"); + return -EFAULT; + } + if(pci_reg_info.reg_type == FMB_TYPE_DMA){ + Fmb_hw_reg_write_dma(hw_priv_p, offset_addr, write_data ); + MSG(DEBUG_LVL, minor, "set dma register"); + } else if(pci_reg_info.reg_type == FMB_TYPE_LSI){ + Fmb_hw_reg_write_lsi_master(hw_priv_p, offset_addr, write_data ); + MSG(DEBUG_LVL, minor, "set lsi master register"); + } + prm_data_p++; + offset_addr += 2; + } + MSG(DRIVER_FUNC_LVL, minor, "END"); + return 0; +} + +/** +* @brief ioctl() FMB_API_GET_VERSION Command Function +* +* @param[in] priv_p private data pointer +* @param[in] argp command parameter pointer +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @note None +* @attention None +*/ + +static int fmb_api_get_version(struct fmb_hard_private* hw_priv_p, + unsigned long argp) +{ + int minor; + int cnt; + int result; + int ret; + unsigned short read_firm_ver; + unsigned short* firm_version_data_p; + unsigned char* drv_ver_p; + unsigned char* drv_version_data_p; + struct fmb_version_info version_info; + struct fmb_core_private* priv_p; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + ret = 0; + + MSG(CODEC_FUNC, minor, "START"); + MSG(DRIVER_FUNC_LVL, minor, "START"); + + result = copy_from_user(&version_info, (void*)argp, sizeof(struct fmb_version_info)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed in a copy from user's area.(fmb_version_info)"); + return -EFAULT; + } + + /* get Driver Version */ + drv_version_data_p = version_info.driver_ver; + drv_ver_p = VERSION; + + result = copy_to_user(drv_version_data_p, drv_ver_p, sizeof(VERSION)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed (fmb_version_info)\n"); + return -EFAULT; + } + + /* get LSI Core Firm Version */ + firm_version_data_p = version_info.firm_ver; + + for (cnt = 0; cnt < (FMB_VERSION_REG_SIZE / sizeof(unsigned short)); cnt++) { + read_firm_ver = Fmb_hw_reg_read_lsi(hw_priv_p, FMB_VERSION_BASE + (cnt * sizeof(unsigned short))); + result = copy_to_user(firm_version_data_p, &read_firm_ver, sizeof(unsigned short)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed (fmb_version_info)\n"); + return -EFAULT; + } + firm_version_data_p++; + } + + result = copy_to_user((void*)argp, &version_info, sizeof(struct fmb_version_info)); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "Failed (fmb_version_info)\n"); + return -EFAULT; + } + MSG(DRIVER_FUNC_LVL, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return ret; +} + +/** +* @brief Stream Receive Function from LSI. +* @param[in] hw_priv_p private data pointer +* @param[in] *fille_p File pointer +* @param[in,out] *buff_p Data pointer +* @param[in] len Data length +* @param[in,out] *offset Object pointer +* @return Size of stream receive data +* @return -EFAULT user buffer(argp) access error +* @return -ETIMEDOUT timeout +* @return -ERESTARTSYS internal error +* @return -EIO IO error +* @note None +* @attention None +*/ +static ssize_t fmb_api_read_stream(struct fmb_hard_private* hw_priv_p, struct file* file_p, + const char __user* buff_p, size_t len, loff_t* offset) +{ + int minor; + struct fmb_dma_buf* dma_buf_p; + unsigned long copy_size; + unsigned long remain_size; + unsigned long flags; + long dma_timeout; + char* copy_addr; + size_t read_size; + struct fmb_dma_queue* dma_queue_p; + struct fmb_core_private* priv_p; + int result; + + + read_size = 0; + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + dma_queue_p = &priv_p->dma_rcv_queue.dma_queue; + + MSG(INTERNAL_LOG, minor, "START"); + + if (down_interruptible(&priv_p->dma_rcv_queue.mutex_read) != 0) { + MSG(ERR_LVL, minor, "fmb_api_read_stream: a signal occurred before mutex acquisition."); + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + Fmb_core_clear_dma_rcv( priv_p ); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_enable_dma_rcv( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + return -ERESTARTSYS; + } + + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + + switch (dma_queue_p->dma_status) { + case FMB_DMA_STOP: + if (len != 0) { + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + dma_queue_p->dma_status = FMB_DMA_START; + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: DMA status change STOP -> START."); + + Fmb_core_clear_dma_rcv(priv_p); + + if (dma_queue_p->copy_data_p != NULL) { + + dma_buf_p = dma_queue_p->copy_data_p; + dma_buf_p->copy_size = 0; + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: add free queue."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + + Fmb_core_add_free_dma_buf(priv_p, dma_buf_p, dma_queue_p, NULL); + + dma_queue_p->copy_data_p = NULL; + } + + Fmb_core_enable_dma_rcv(priv_p); + + } + else { + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: received EOF in STOP state."); + + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(INTERNAL_LOG, minor, "END"); + return 0; + } + break; + + default: + if (len == 0) { + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: DMA status change START -> END_WAIT."); + + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: Got up!(All data transfer was over.)"); + + if (dma_queue_p->copy_data_p != NULL) { + + dma_buf_p = dma_queue_p->copy_data_p; + copy_addr = dma_buf_p->addr_l + dma_buf_p->copy_size; + copy_size = FMB_DMA_RCV_BUF_SIZE - dma_buf_p->copy_size; + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: copy from existing buffer."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: addr = 0x%08x\n", (unsigned int)copy_addr); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: ize = 0x%08lx\n", copy_size); + + result = copy_to_user((void*)buff_p, copy_addr, copy_size); + if (result) { + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + Fmb_core_clear_dma_rcv( priv_p ); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_enable_dma_rcv( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(KERN_ERR_LVL, minor, "fmb_api_read_stream: Failed in a copy to user's area."); + return -EFAULT; + } + + *offset += copy_size; + read_size += copy_size; + dma_buf_p->copy_size = 0; + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: add free queue."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + + Fmb_core_add_free_dma_buf(priv_p, dma_buf_p, dma_queue_p, &priv_p->dma_rcv_queue.lock); + + dma_queue_p->copy_data_p = NULL; + } + + dma_queue_p->dma_status = FMB_DMA_STOP; + priv_p->dma_rcv_queue.dma_comp_size = 0; + + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(INTERNAL_LOG, minor, "END"); + return read_size; + + } + else { + } + break; + } + + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + + remain_size = len; + + while(remain_size != 0) { + + if (dma_queue_p->copy_data_p == NULL) { + Fmb_core_start_dma_rcv(priv_p, &priv_p->dma_rcv_queue.lock); + + dma_timeout = (priv_p->read_dma_count * HZ); + +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout(priv_p->dma_rcv_queue.comp_waitq, + (FMB_DMA_RCV_BUF_SIZE <= priv_p->dma_rcv_queue.dma_comp_size), dma_timeout); +#else + result = wait_event_timeout(priv_p->dma_rcv_queue.comp_waitq, + (FMB_DMA_RCV_BUF_SIZE <= priv_p->dma_rcv_queue.dma_comp_size), dma_timeout); +#endif + if (result <= 0) { + + if (result == 0) { + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + + if (priv_p->read_dma_flg == FMB_DATA_DMAFLAG_ON) { + Fmb_core_clear_dma_rcv( priv_p ); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_enable_dma_rcv( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(INTERNAL_ERR_LVL, minor, "fmb_api_read_stream: ##### DMA transfer timeout.#####"); + return -ETIMEDOUT; + } + + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + + continue; + } + else { + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + Fmb_core_clear_dma_rcv( priv_p ); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_enable_dma_rcv( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(ERR_LVL, minor, "fmb_api_read_stream: a signal occurred before all data transfer."); + return -ERESTARTSYS; + } + } + + if (dma_queue_p->dma_status != FMB_DMA_START) { + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(INTERNAL_ERR_LVL, minor, "fmb_api_read_stream: ccanceled before DMA transfer completion."); + return read_size; + } + + dma_buf_p = Fmb_core_get_busy_dma_buf(priv_p, dma_queue_p, &priv_p->dma_rcv_queue.lock); + if (dma_buf_p == NULL) { + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + Fmb_core_clear_dma_rcv( priv_p ); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_enable_dma_rcv( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(INTERNAL_ERR_LVL, minor, "fmb_api_read_stream: no busy buffer."); + return -EIO; + } + + dma_buf_p->copy_size = 0; + copy_addr = dma_buf_p->addr_l; + copy_size = min(remain_size, (unsigned long)FMB_DMA_RCV_BUF_SIZE); + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: copy from new buffer."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: addr = 0x%08x\n", (unsigned int)copy_addr); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: ize = 0x%08lx\n", copy_size); + } + else { + dma_buf_p = dma_queue_p->copy_data_p; + copy_addr = dma_buf_p->addr_l + dma_buf_p->copy_size; + copy_size = min(remain_size, (FMB_DMA_RCV_BUF_SIZE - dma_buf_p->copy_size)); + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: copy from existing buffer."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: addr = 0x%08x\n", (unsigned int)copy_addr); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: ize = 0x%08lx\n", copy_size); + } + + dma_queue_p->copy_data_p = dma_buf_p; + + result = copy_to_user((void*)buff_p, copy_addr, copy_size); + if (result) { + spin_lock_irqsave(&priv_p->dma_rcv_queue.lock, flags); + Fmb_core_clear_dma_rcv( priv_p ); + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_enable_dma_rcv( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_rcv_queue.lock, flags); + up(&priv_p->dma_rcv_queue.mutex_read); + MSG(KERN_ERR_LVL, minor, "fmb_api_read_stream: Failed in a copy to user's area."); + return -EFAULT; + } + + buff_p += copy_size; + + if ((copy_size + dma_buf_p->copy_size) < FMB_DMA_RCV_BUF_SIZE) { + dma_buf_p->copy_size += copy_size; + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: skip add free queue."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: remain = 0x%08lx\n.", (FMB_DMA_RCV_BUF_SIZE - dma_buf_p->copy_size)); + } + else { + dma_buf_p->copy_size = 0; + + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: add free queue."); + MSG(DEBUG_LVL, minor, "fmb_api_read_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + + if (priv_p->dma_rcv_queue.dma_comp_size >= FMB_DMA_RCV_BUF_SIZE) { + priv_p->dma_rcv_queue.dma_comp_size -= FMB_DMA_RCV_BUF_SIZE; + } + else { + priv_p->dma_rcv_queue.dma_comp_size = 0; + } + Fmb_core_add_free_dma_buf(priv_p, dma_buf_p, dma_queue_p, &priv_p->dma_rcv_queue.lock); + + dma_queue_p->copy_data_p = NULL; + } + + *offset += copy_size; + read_size += copy_size; + + remain_size -= copy_size; + + } + + up(&priv_p->dma_rcv_queue.mutex_read); + + MSG(INTERNAL_LOG, minor, "END"); + return read_size; +} + +/** +* @brief Stream Send Function to LSI. +* @param[in] hw_priv_p private data pointer +* @param[in] *fille_p File pointer +* @param[in] *buff_p Data pointer +* @param[in] len Data length +* @param[in,out] *offset Object pointer +* @return Size of stream send data +* @return -EFAULT user buffer(argp) access error +* @return -ETIMEDOUT timeout +* @return -ERESTARTSYS internal error +* @note None +* @attention None +*/ +static ssize_t fmb_api_write_stream(struct fmb_hard_private* hw_priv_p, struct file* file_p, + const char __user* buff_p, size_t len, loff_t* offset) +{ + int minor; + struct fmb_dma_buf* dma_buf_p; + unsigned long copy_size; + unsigned long remain_size; + unsigned long flags; + long dma_timeout; + char* copy_addr; + struct fmb_dma_queue* dma_queue_p; + struct fmb_core_private* priv_p; + int result; + + minor = hw_priv_p->minor; + priv_p = hw_priv_p->core_priv_p; + dma_queue_p = &priv_p->dma_snd_queue.dma_queue; + + MSG(INTERNAL_LOG, minor, "START"); + + if (down_interruptible(&priv_p->dma_snd_queue.mutex_write) != 0) { + MSG(ERR_LVL, minor, "fmb_api_write_stream: a signal occurred before mutex acquisition."); + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + Fmb_core_clear_dma_snd( priv_p ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + Fmb_core_enable_dma_snd( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + return -ERESTARTSYS; + } + + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + + switch (dma_queue_p->dma_status) { + case FMB_DMA_STOP: + if (len != 0) { + dma_queue_p->dma_status = FMB_DMA_START; + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: DMA status change STOP -> START."); + + Fmb_core_clear_dma_snd(priv_p); + + if (dma_queue_p->copy_data_p != NULL) { + dma_buf_p = dma_queue_p->copy_data_p; + Fmb_core_add_free_dma_buf(priv_p, dma_buf_p, dma_queue_p, NULL); + } + + Fmb_core_enable_dma_snd(priv_p); + } + else { + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: received EOF in STOP state."); + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_LOG, minor, "END"); + return 0; + } + break; + case FMB_DMA_START: + if (len == 0) { + + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: received EOF in START state."); + + if ((dma_queue_p->b_num != 0) || (dma_queue_p->dma_data_p != NULL) || (dma_queue_p->copy_data_p != NULL)) { + + if (dma_queue_p->copy_data_p != NULL) { + dma_queue_p->copy_data_p->trans_size = FMB_DMA_SND_BUF_SIZE; + + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: add busy queuee."); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: buf = 0x%08x\n.", (unsigned int)dma_queue_p->copy_data_p); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: size = 0x%08lx\n.", dma_queue_p->copy_data_p->trans_size); + + Fmb_core_add_busy_dma_buf(priv_p, dma_queue_p->copy_data_p, dma_queue_p, NULL); + dma_queue_p->copy_data_p = NULL; + + Fmb_core_start_dma_snd(priv_p, NULL); + } + + dma_queue_p->dma_status = FMB_DMA_END_WAIT; + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: DMA status change START -> END_WAIT."); + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: Wait for all data transfer...zzz..."); + + while (1) { + dma_timeout = (priv_p->write_dma_count * HZ); + +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout( dma_queue_p->comp_waitq, + dma_queue_p->dma_status == FMB_DMA_END, dma_timeout); +#else + result = wait_event_timeout( dma_queue_p->comp_waitq, + dma_queue_p->dma_status == FMB_DMA_END, dma_timeout); +#endif + if (result > 0) { + + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + + dma_queue_p->dma_status = FMB_DMA_STOP; + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: DMA status change END -> START"); + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + break; + } + else { + if (result == 0) { + + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + + if (priv_p->write_dma_flg == FMB_DATA_DMAFLAG_ON) { + Fmb_core_clear_dma_snd( priv_p ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + Fmb_core_enable_dma_snd( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_ERR_LVL, minor, "fmb_api_write_stream: ##### DMA transfer timeout.#####"); + return -ETIMEDOUT; + } + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + continue; + } + else { + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + Fmb_core_clear_dma_snd( priv_p ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + Fmb_core_enable_dma_snd( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + up(&priv_p->dma_snd_queue.mutex_write); + MSG(ERR_LVL, minor, "fmb_api_write_stream: a signal occurred before all data transfer."); + return -ERESTARTSYS; + } + } + } + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: Got up!(All data transfer was over.)"); + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_LOG, minor, "END"); + return 0; + } + else { + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + } + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_LOG, minor, "END"); + return 0; + } + else { + } + break; + case FMB_DMA_END_WAIT: + case FMB_DMA_END: + if (len == 0) { + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: received EOF in END_WAIT/END state."); + dma_queue_p->dma_status = FMB_DMA_STOP; + } + else { + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: demanded write() in END_WAIT/END state."); + } + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_LOG, minor, "END"); + return 0; + break; + } + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + remain_size = len; + + while(remain_size != 0) { + + if (dma_queue_p->copy_data_p == NULL) { + while (1) { + dma_timeout = (priv_p->write_dma_count * HZ); + +#ifndef FMB_DEBUG_GDB + result = wait_event_interruptible_timeout( + dma_queue_p->buf_waitq, + (dma_buf_p = Fmb_core_get_free_dma_buf(priv_p, dma_queue_p, &priv_p->dma_snd_queue.lock))!= NULL, + dma_timeout); +#else + result = wait_event_timeout( + dma_queue_p->buf_waitq, + (dma_buf_p = Fmb_core_get_free_dma_buf(priv_p, dma_queue_p, &priv_p->dma_snd_queue.lock))!= NULL, + dma_timeout); +#endif + if (result > 0) { + + break; + } + else { + if (result == 0) { + + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + + if (priv_p->write_dma_flg == FMB_DATA_DMAFLAG_ON) { + Fmb_core_clear_dma_snd( priv_p ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + Fmb_core_enable_dma_snd( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_ERR_LVL, minor, "fmb_api_write_stream: ##### DMA transfer timeout.#####"); + return -ETIMEDOUT; + } + + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + + continue; + } + else { + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + Fmb_core_clear_dma_snd( priv_p ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + Fmb_core_enable_dma_snd( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + up(&priv_p->dma_snd_queue.mutex_write); + MSG(ERR_LVL, minor, "fmb_api_write_stream: a signal occurred before all data transfer."); + return -ERESTARTSYS; + } + } + } + + if (dma_queue_p->dma_status != FMB_DMA_START) { + Fmb_core_add_free_dma_buf(priv_p, dma_buf_p, &priv_p->dma_snd_queue.dma_queue, &priv_p->dma_snd_queue.lock); + + up(&priv_p->dma_snd_queue.mutex_write); + MSG(INTERNAL_ERR_LVL, minor, "fmb_api_write_stream: skip write.(received a stop demand)"); + return (len - remain_size); + } + + dma_buf_p->copy_size = 0; + copy_addr = dma_buf_p->addr_l; + memset(copy_addr, 0, FMB_DMA_SND_BUF_SIZE); + copy_size = min(remain_size, (unsigned long)FMB_DMA_SND_BUF_SIZE); + } + else { + dma_buf_p = dma_queue_p->copy_data_p; + copy_addr = dma_buf_p->addr_l + dma_buf_p->copy_size; + copy_size = min(remain_size, (FMB_DMA_SND_BUF_SIZE - dma_buf_p->copy_size)); + + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: copy to existing buffer."); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: buf = 0x%08x\n.", (unsigned int)copy_addr); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: size = 0x%08lx\n.", copy_size); + } + + result = copy_from_user(copy_addr, buff_p, copy_size); + if (result) { + spin_lock_irqsave(&priv_p->dma_snd_queue.lock, flags); + Fmb_core_clear_dma_snd( priv_p ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + Fmb_core_enable_dma_snd( priv_p ); + spin_unlock_irqrestore(&priv_p->dma_snd_queue.lock, flags); + up(&priv_p->dma_snd_queue.mutex_write); + MSG(KERN_ERR_LVL, minor, "fmb_api_write_stream: Failed in a copy from user's area"); + return -EFAULT; + } + + buff_p += copy_size; + + if ((copy_size + dma_buf_p->copy_size) < FMB_DMA_SND_BUF_SIZE) { + dma_buf_p->copy_size += copy_size; + dma_queue_p->copy_data_p = dma_buf_p; + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: skip add busy queue."); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: remain = 0x%08lx\n.", (FMB_DMA_SND_BUF_SIZE - dma_buf_p->copy_size)); + } + else { + + dma_buf_p->trans_size = FMB_DMA_SND_BUF_SIZE; + + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: add busy queue."); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: buf = 0x%08x\n.", (unsigned int)dma_buf_p); + MSG(DEBUG_LVL, minor, "fmb_api_write_stream: remain = 0x%08lx\n.", dma_buf_p->trans_size); + + Fmb_core_add_busy_dma_buf(priv_p, dma_buf_p, dma_queue_p, &priv_p->dma_snd_queue.lock); + + dma_queue_p->copy_data_p = NULL; + + Fmb_core_start_dma_snd(priv_p, &priv_p->dma_snd_queue.lock); + } + + remain_size -= copy_size; + } + + *offset += (len - remain_size); + + up(&priv_p->dma_snd_queue.mutex_write); + + MSG(INTERNAL_LOG, minor, "END"); + return (len - remain_size); +} + + +/********************************************************/ +/* systemcall basic API Function */ +/********************************************************/ + +/** +* @brief ioctl() Command Function +* @param[in] fmb_hard_private_data_p hard private data pointer +* @param[in] cmd Command number from application +* @param[in,out] arg Argument from application +* @return 0 normal end +* @return -EFAULT user buffer(argp) access error +* @return -EINVAL invalid content of parameter +* @return -ETIMEDOUT timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +int Fmb_api_ioctl(struct fmb_hard_private* fmb_hard_private_data_p, + unsigned int cmd, unsigned long arg) +{ + int minor; + int rc; + + rc = 0; + minor = fmb_hard_private_data_p->minor; + MSG(INTERNAL_FUNC, minor, "start"); + + switch (cmd) { + case FMB_API_GET_PARAM: + rc = fmb_api_get_param(fmb_hard_private_data_p, arg); + break; + case FMB_API_SET_PARAM: + rc = fmb_api_set_param(fmb_hard_private_data_p, arg); + break; + case FMB_API_SEND_SYS_CMD: + rc = fmb_api_send_sys_cmd(fmb_hard_private_data_p, arg); + break; + case FMB_API_SEND_VIDEO_CMD: + rc = fmb_api_send_video_cmd(fmb_hard_private_data_p, arg); + break; + case FMB_API_SEND_AUDIO_CMD: + rc = fmb_api_send_audio_cmd(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_SYS_CMD_ACK: + rc = fmb_api_get_sys_cmd_ack(fmb_hard_private_data_p, arg); + break; + case FMB_API_RESET_CMD_INFO: + rc = fmb_api_reset_cmd_info(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_SYS_MSG: + rc = fmb_api_get_sys_msg(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_VIDEO_MSG: + rc = fmb_api_get_video_msg(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_AUDIO_MSG: + rc = fmb_api_get_audio_msg(fmb_hard_private_data_p, arg); + break; + case FMB_API_INIT_PREPARE_FIRM: + rc = fmb_api_init_prepare_firm(fmb_hard_private_data_p); + break; + case FMB_API_WRITE_FIRM: + rc = fmb_api_write_firm(fmb_hard_private_data_p, arg); + break; + case FMB_API_BOOT_UP_FIRM: + rc = fmb_api_boot_up_firm(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_FACTOR: + rc = fmb_api_get_factor(fmb_hard_private_data_p, arg); + break; + case FMB_API_RESET_FACTOR: + rc = fmb_api_reset_factor(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_ASYNC_INFO: + rc = fmb_api_get_async_info(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_LSI_REG: + rc = fmb_api_get_lsi_reg(fmb_hard_private_data_p, arg); + break; + case FMB_API_SET_LSI_REG: + rc = fmb_api_set_lsi_reg(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_INTERNAL_DATA: + rc = fmb_api_get_internal_data(fmb_hard_private_data_p, arg); + break; + case FMB_API_SET_INTERNAL_DATA: + rc = fmb_api_set_internal_data(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_PCI_REG: + rc = fmb_api_get_pci_reg(fmb_hard_private_data_p, arg); + break; + case FMB_API_SET_PCI_REG: + rc = fmb_api_set_pci_reg(fmb_hard_private_data_p, arg); + break; + case FMB_API_GET_VERSION: + rc = fmb_api_get_version(fmb_hard_private_data_p, arg); + break; + default: + rc = -EINVAL; + MSG(INTERNAL_ERR_LVL, minor, "ioctl():Command is not supported. "); + break; + } + MSG(INTERNAL_FUNC, minor, "end"); + return rc; +} + +/** +* @brief Device Open Function +* @param[in] *ip Information in filesystem +* @param[in] *fp File pointer +* @return TBD +* @note None +* @attention None +*/ + +/** +* @brief Device Close Function +* @param[in] *ip Information in filesystem +* @param[in] *fp File pointer +* @return TBD +* @note None +* @attention None +*/ + +/** +* @brief Stream Receive Function from LSI. +* @param[in] hw_priv_p private data pointer +* @param[in] *fille_p File pointer +* @param[in,out] *buff_p Data pointer +* @param[in] len Data length +* @param[in,out] *offset Object pointer +* @return Size of stream receive data +* @return -EFAULT user buffer(argp) access error +* @return -ETIMEDOUT timeout +* @return -ERESTARTSYS internal error +* @return -EIO IO error +* @note None +* @attention None +*/ +ssize_t Fmb_api_read(struct fmb_hard_private* fmb_hard_private_data_p, struct file* file_p, + const char __user* buff_p, size_t len, loff_t* offset) +{ + int minor; + int rc; + + rc = 0; + minor = fmb_hard_private_data_p->minor; + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_FUNC, minor, "START"); + + rc = fmb_api_read_stream(fmb_hard_private_data_p, file_p, buff_p, len, offset); + + MSG(INTERNAL_FUNC, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return rc; +} + +/** +* @brief Stream Send Function to LSI. +* @param[in] hw_priv_p private data pointer +* @param[in] *fille_p File pointer +* @param[in] *buff_p Data pointer +* @param[in] len Data length +* @param[in,out] *offset Object pointer +* @return Size of stream send data +* @return -EFAULT user buffer(argp) access error +* @return -ETIMEDOUT timeout +* @return -ERESTARTSYS internal error +* @return -EAGAIN try again +* @note None +* @attention None +*/ +ssize_t Fmb_api_write(struct fmb_hard_private* fmb_hard_private_data_p, struct file* file_p, + const char __user* buff_p, size_t len, loff_t* offset) +{ + int minor; + int rc; + + rc = 0; + minor = fmb_hard_private_data_p->minor; + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_FUNC, minor, "START"); + + rc = fmb_api_write_stream(fmb_hard_private_data_p, file_p, buff_p, len, offset); + + MSG(INTERNAL_FUNC, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return rc; +} + diff --git a/fmb_driver/fmb_api.h b/fmb_driver/fmb_api.h new file mode 100644 index 0000000..693cc41 --- /dev/null +++ b/fmb_driver/fmb_api.h @@ -0,0 +1,123 @@ +/**
+* @brief User API definition header file for MB86 LSI Linux driver.
+* @since 2009/01/08
+* @note None
+* @attention None
+* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B>
+*/
+
+/*
+ * 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.
+ */
+
+/****************************************************************************/
+#ifndef __FMB_API_H__
+#define __FMB_API_H__
+
+#include "fmb.h"
+
+/********************************************************/
+/* LSI Core Parameter Table */
+/********************************************************/
+
+struct fmb_param_table {
+ unsigned long offset;
+ unsigned short mask;
+ unsigned short shift;
+ unsigned long valid;
+};
+
+struct fmb_param_head_table {
+ unsigned short id_up_16bit;
+ const struct fmb_param_table* second_table_addr;
+ unsigned long second_table_size;
+};
+
+/********************************************************/
+/* ioctl External Function */
+/********************************************************/
+
+/**
+* @brief ioctl() Command Function
+* @param[in] priv_p hard private data pointer
+* @param[in] cmd Command number from application
+* @param[in,out] arg Argument from application
+* @return 0 normal end
+* @return -EFAULT user buffer(argp) access error
+* @return -EINVAL invalid content of parameter
+* @return -ETIMEDOUT timeout
+* @return -ERESTARTSYS internal error
+* @return -EAGAIN try again
+* @note None
+*/
+int Fmb_api_ioctl(struct fmb_hard_private* fmb_hard_private_data_p,
+ unsigned int cmd,
+ unsigned long arg
+);
+
+
+/********************************************************/
+/* systemcall basic API Function */
+/********************************************************/
+/**
+* @brief Device Open Function
+* @param[in] *ip Information in filesystem
+* @param[in] *fp File pointer
+* @return TBD
+* @note None
+* @attention None
+*
+int Fmb_api_open(struct inode* ip, struct file* fp);
+*/
+
+/**
+* @brief Device Close Function
+* @param[in] *ip Information in filesystem
+* @param[in] *fp File pointer
+* @return TBD
+* @note None
+* @attention None
+int Fmb_api_release(struct inode* ip, struct file* fp);
+*/
+
+/**
+* @brief Stream Receive Function from LSI.
+* @param[in] *fmb_hard_private Hard private data
+* @param[in] *fp File pointer
+* @param[in,out] *buffp Data pointer
+* @param[in] len Data length
+* @param[in] *offset Object pointer
+* @return TBD
+* @note None
+* @attention None
+*/
+ssize_t Fmb_api_read(struct fmb_hard_private* fmb_hard_private_data_p,
+ struct file* fill_p,
+ const char __user* buff_p,
+ size_t len,
+ loff_t* offset
+);
+
+/**
+* @brief Stream Send Function to LSI.
+* @param[in] *fmb_hard_private Hard private data
+* @param[in] *fp File pointer
+* @param[in,out] *buffp Data pointer
+* @param[in] len Data length
+* @param[in] *offset Object pointer
+* @return TBD
+* @note None
+* @attention None
+*/
+ssize_t Fmb_api_write(struct fmb_hard_private* fmb_hard_private_data_p,
+ struct file* fill_p,
+ const char __user* buff_p,
+ size_t len,
+ loff_t* offset
+);
+
+
+#endif /* ifndef __FMB_API_H__ */
diff --git a/fmb_driver/fmb_api_table.c b/fmb_driver/fmb_api_table.c new file mode 100644 index 0000000..4e22593 --- /dev/null +++ b/fmb_driver/fmb_api_table.c @@ -0,0 +1,740 @@ +/** +* @brief LSI Core Parameter Table file for MB86 LSI Linux driver . +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + + +/* + * 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. + */ + +/****************************************************************************/ +#include "fmb.h" +#include "fmb_api.h" + + +#define SIZEOF_ARRAY(array) (sizeof(array) / sizeof(array[0])) + +/****************************************************************************** + Name : Register table of MB86 additional parameter M + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_add_param_m[] = { + { 0x000800c0, 0x00ff, 0x0008, 1 }, + { 0x000800c0, 0x00ff, 0x0000, 1 }, + { 0x000800c2, 0x0001, 0x000e, 1 }, + { 0x000800c2, 0x0001, 0x000c, 1 }, + { 0x000800c2, 0x0001, 0x000a, 1 }, + { 0x000800c2, 0x0001, 0x0008, 1 }, + { 0x000800c2, 0x000f, 0x0000, 1 }, + { 0x000800c4, 0xffff, 0x0000, 1 }, + { 0x000800c6, 0xffff, 0x0000, 1 }, + { 0x000800c8, 0xffff, 0x0000, 1 }, + { 0x000800ca, 0xffff, 0x0000, 1 }, + { 0x000800cc, 0xffff, 0x0000, 1 }, + { 0x000800ce, 0xffff, 0x0000, 1 }, + { 0x000800d0, 0xffff, 0x0000, 1 }, + { 0x000800d2, 0xffff, 0x0000, 1 }, + { 0x000800e0, 0x1fff, 0x0000, 1 }, + { 0x000800e2, 0x1fff, 0x0000, 1 }, + { 0x000800e4, 0x1fff, 0x0000, 1 }, + { 0x000800ea, 0x00ff, 0x0008, 1 }, + { 0x000800ea, 0x00ff, 0x0000, 1 }, + { 0x000800ec, 0x00ff, 0x0000, 1 }, + { 0x000800ee, 0x00ff, 0x0000, 1 }, + { 0x000800f0, 0xffff, 0x0000, 1 }, + { 0x000800f2, 0xffff, 0x0000, 1 }, + { 0x000800f4, 0xffff, 0x0000, 1 }, + { 0x000800f6, 0xffff, 0x0000, 1 }, + { 0x000800f8, 0xffff, 0x0000, 1 }, + { 0x000800fa, 0xffff, 0x0000, 1 }, + { 0x000800fc, 0xffff, 0x0000, 1 }, + { 0x000800fe, 0xffff, 0x0000, 1 }, + { 0x00080100, 0xffff, 0x0000, 1 }, + { 0x00080102, 0xffff, 0x0000, 1 }, + { 0x00080104, 0xffff, 0x0000, 1 }, + { 0x00080106, 0xffff, 0x0000, 1 }, + { 0x00080108, 0xffff, 0x0000, 1 }, + { 0x0008010a, 0xffff, 0x0000, 1 }, + { 0x0008010c, 0xffff, 0x0000, 1 }, + { 0x0008010e, 0xffff, 0x0000, 1 }, + { 0x00080110, 0xffff, 0x0000, 1 }, + { 0x00080112, 0xffff, 0x0000, 1 }, + { 0x00080114, 0xffff, 0x0000, 1 }, + { 0x00080116, 0xffff, 0x0000, 1 }, + { 0x00080118, 0xffff, 0x0000, 1 }, + { 0x0008011a, 0xffff, 0x0000, 1 }, + { 0x0008011c, 0xffff, 0x0000, 1 }, + { 0x0008011e, 0xffff, 0x0000, 1 }, + { 0x00080120, 0xffff, 0x0000, 1 }, + { 0x00080122, 0xffff, 0x0000, 1 }, + { 0x00080124, 0xffff, 0x0000, 1 }, + { 0x00080126, 0xffff, 0x0000, 1 }, + { 0x00080128, 0xffff, 0x0000, 1 }, + { 0x0008012a, 0xffff, 0x0000, 1 }, + { 0x0008012c, 0xffff, 0x0000, 1 }, + { 0x0008012e, 0xffff, 0x0000, 1 }, + { 0x00080130, 0xffff, 0x0000, 1 }, + { 0x00080132, 0xffff, 0x0000, 1 }, + { 0x00080134, 0xffff, 0x0000, 1 }, + { 0x00080136, 0xffff, 0x0000, 1 }, + { 0x00080138, 0xffff, 0x0000, 1 }, + { 0x0008013a, 0xffff, 0x0000, 1 }, + { 0x0008013c, 0xffff, 0x0000, 1 }, + { 0x0008013e, 0xffff, 0x0000, 1 }, + { 0x00080140, 0xffff, 0x0000, 1 }, + { 0x00080142, 0xffff, 0x0000, 1 }, + { 0x00080144, 0xffff, 0x0000, 1 }, + { 0x00080146, 0xffff, 0x0000, 1 }, + { 0x00080148, 0xffff, 0x0000, 1 }, + { 0x0008014a, 0xffff, 0x0000, 1 }, + { 0x0008014c, 0xffff, 0x0000, 1 }, + { 0x0008014e, 0xffff, 0x0000, 1 }, + { 0x00080150, 0xffff, 0x0000, 1 }, + { 0x00080152, 0xffff, 0x0000, 1 }, + { 0x00080154, 0xffff, 0x0000, 1 }, + { 0x00080156, 0xffff, 0x0000, 1 }, + { 0x00080158, 0xffff, 0x0000, 1 }, + { 0x0008015a, 0xffff, 0x0000, 1 }, + { 0x0008015c, 0xffff, 0x0000, 1 }, + { 0x0008015e, 0xffff, 0x0000, 1 }, + { 0x00080160, 0xffff, 0x0000, 1 }, + { 0x00080162, 0xffff, 0x0000, 1 }, + { 0x00080164, 0xffff, 0x0000, 1 }, + { 0x00080166, 0xffff, 0x0000, 1 }, + { 0x00080168, 0xffff, 0x0000, 1 }, + { 0x0008016a, 0xffff, 0x0000, 1 }, + { 0x0008016c, 0xffff, 0x0000, 1 }, + { 0x0008016e, 0xffff, 0x0000, 1 }, + { 0x00080170, 0xffff, 0x0000, 1 }, + { 0x00080172, 0xffff, 0x0000, 1 }, + { 0x00080174, 0xffff, 0x0000, 1 }, + { 0x00080176, 0xffff, 0x0000, 1 }, + { 0x00080178, 0xffff, 0x0000, 1 }, + { 0x0008017a, 0xffff, 0x0000, 1 }, + { 0x0008017c, 0xffff, 0x0000, 1 }, + { 0x0008017e, 0xffff, 0x0000, 1 }, + { 0x00080180, 0xffff, 0x0000, 1 }, + { 0x00080182, 0xffff, 0x0000, 1 }, + { 0x00080184, 0xffff, 0x0000, 1 }, + { 0x00080186, 0xffff, 0x0000, 1 }, + { 0x00080188, 0xffff, 0x0000, 1 }, + { 0x0008018a, 0xffff, 0x0000, 1 }, + { 0x0008018c, 0xffff, 0x0000, 1 }, + { 0x0008018e, 0xffff, 0x0000, 1 }, + { 0x00080190, 0xffff, 0x0000, 1 }, + { 0x00080192, 0xffff, 0x0000, 1 }, + { 0x00080194, 0xffff, 0x0000, 1 }, + { 0x00080196, 0xffff, 0x0000, 1 }, + { 0x00080198, 0xffff, 0x0000, 1 }, + { 0x0008019a, 0xffff, 0x0000, 1 }, + { 0x0008019c, 0xffff, 0x0000, 1 }, + { 0x0008019e, 0xffff, 0x0000, 1 }, + { 0x000801a0, 0xffff, 0x0000, 1 }, + { 0x000801a2, 0xffff, 0x0000, 1 }, + { 0x000801a4, 0x0001, 0x000f, 1 }, + { 0x000801a4, 0x01ff, 0x0000, 1 }, + { 0x000801b0, 0xffff, 0x0000, 1 }, + { 0x000801b2, 0xffff, 0x0000, 1 }, + { 0x000801b4, 0x000f, 0x000c, 1 }, + { 0x000801b4, 0x000f, 0x0008, 1 }, + { 0x000801b4, 0x000f, 0x0004, 1 }, + { 0x000801b4, 0x000f, 0x0000, 1 }, + { 0x000801c0, 0xffff, 0x0000, 1 }, + { 0x000801c2, 0xffff, 0x0000, 1 }, + { 0x000801c4, 0xffff, 0x0000, 1 }, + { 0x000801c6, 0xffff, 0x0000, 1 }, +}; + +/****************************************************************************** + Name : Register Table of MB86 additional parameter V + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_add_param_v[] = { + { 0x000801e0, 0x0001, 0x000f, 1}, + { 0x000801e0, 0x0001, 0x0000, 1}, + { 0x000801e4, 0x0001, 0x0004, 1}, + { 0x000801ee, 0xffff, 0x0000, 1}, + { 0x000801f0, 0xffff, 0x0000, 1}, + { 0x000801f2, 0xffff, 0x0000, 1}, + { 0x000801f4, 0xffff, 0x0000, 1}, + { 0x000801f6, 0xffff, 0x0000, 1}, + { 0x000801f8, 0xffff, 0x0000, 1}, + { 0x000801fa, 0xffff, 0x0000, 1}, + { 0x000801fc, 0xffff, 0x0000, 1}, + { 0x000801fe, 0xffff, 0x0000, 1}, +}; + +/****************************************************************************** + Name : Register Table of MB86 additional parameter A + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_add_param_a[] = { + { 0x00001c00, 0xffff, 0x0000, 1 }, +}; + +/****************************************************************************** + Name : Register Table of MB86 initialization parameter M + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_init_param_m[] = { + { 0x00001000, 0x0003, 0x0008, 1 }, + { 0x00001000, 0x0003, 0x0000, 1 }, + { 0x00001002, 0x0001, 0x000f, 1 }, + { 0x00001002, 0x0001, 0x000a, 1 }, + { 0x00001002, 0x0003, 0x0008, 1 }, + { 0x00001002, 0x0001, 0x0007, 1 }, + { 0x00001002, 0x007f, 0x0000, 1 }, + { 0x00001004, 0x0001, 0x0008, 1 }, + { 0x00001004, 0x0001, 0x0002, 1 }, + { 0x00001004, 0x0003, 0x0000, 1 }, + { 0x00001006, 0xffff, 0x0000, 1 }, + { 0x00001008, 0x0003, 0x000c, 1 }, + { 0x00001008, 0x0003, 0x0008, 1 }, + { 0x00001008, 0x0003, 0x0004, 1 }, + { 0x00001008, 0x0003, 0x0000, 1 }, + { 0x0000100a, 0xffff, 0x0000, 1 }, + { 0x0000100c, 0xffff, 0x0000, 1 }, + { 0x0000100e, 0xffff, 0x0000, 1 }, + { 0x00001010, 0x0001, 0x000f, 1 }, + { 0x00001010, 0x01ff, 0x0000, 1 }, + { 0x00001012, 0xffff, 0x0000, 1 }, + { 0x00001014, 0xffff, 0x0000, 1 }, + { 0x00001016, 0x1fff, 0x0000, 1 }, + { 0x00001018, 0x1fff, 0x0000, 1 }, + { 0x0000101a, 0x1fff, 0x0000, 1 }, + { 0x0000101c, 0x1fff, 0x0000, 1 }, + { 0x0000101e, 0x1fff, 0x0000, 1 }, + { 0x00001020, 0x00ff, 0x0000, 1 }, + { 0x00001022, 0x00ff, 0x0008, 1 }, + { 0x00001022, 0x00ff, 0x0000, 1 }, + { 0x00001024, 0x0001, 0x0000, 1 }, + { 0x00001028, 0x001f, 0x0008, 1 }, + { 0x00001028, 0x001f, 0x0000, 1 }, + { 0x0000102A, 0x001f, 0x0000, 1 }, + { 0x00001080, 0x00ff, 0x0000, 1 }, + { 0x00001082, 0xffff, 0x0000, 1 }, + { 0x00001084, 0xffff, 0x0000, 1 }, + { 0x00001086, 0x0001, 0x000f, 1 }, + { 0x00001086, 0x01ff, 0x0000, 1 }, + { 0x00001088, 0xffff, 0x0000, 1 }, + { 0x0000108a, 0xffff, 0x0000, 1 }, + { 0x0000108c, 0x0001, 0x000f, 1 }, + { 0x0000108c, 0x01ff, 0x0000, 1 }, + { 0x00001100, 0xffff, 0x0000, 1 }, + { 0x00001102, 0xffff, 0x0000, 1 }, + { 0x00001104, 0x0001, 0x000f, 1 }, + { 0x00001104, 0x0001, 0x0000, 1 }, + { 0x00001106, 0x000f, 0x000c, 1 }, + { 0x00001106, 0x000f, 0x0008, 1 }, + { 0x00001106, 0x000f, 0x0004, 1 }, + { 0x00001106, 0x000f, 0x0000, 1 }, + { 0x00001110, 0x007f, 0x0000, 1 }, + { 0x00001112, 0x007f, 0x0000, 1 }, + { 0x00001114, 0x03ff, 0x0000, 1 }, + { 0x00001116, 0x007f, 0x0000, 1 }, + { 0x00001120, 0xffff, 0x0000, 1 }, + { 0x00001122, 0xffff, 0x0000, 1 }, + { 0x00001130, 0x0001, 0x0000, 1 }, + { 0x00001142, 0x0001, 0x0000, 1 }, + { 0x00001144, 0x0003, 0x000c, 1 }, + { 0x00001144, 0x0003, 0x0008, 1 }, + { 0x00001144, 0x0003, 0x0004, 1 }, + { 0x00001144, 0x0003, 0x0000, 1 }, + { 0x00001146, 0x0001, 0x0008, 1 }, + { 0x00001146, 0x0003, 0x0004, 1 }, + { 0x00001146, 0x0003, 0x0000, 1 }, + { 0x00001148, 0x0001, 0x0008, 1 }, + { 0x00001148, 0x0003, 0x0004, 1 }, + { 0x00001148, 0x0001, 0x0001, 1 }, + { 0x0000114a, 0x0001, 0x0000, 1 }, + { 0x0000114c, 0xffff, 0x0000, 1 }, + { 0x0000114e, 0xffff, 0x0000, 1 }, + { 0x00001150, 0xffff, 0x0000, 1 }, + { 0x00001152, 0xffff, 0x0000, 1 }, +}; + +/****************************************************************************** + Name : Register Table of MB86 initialization parameter V + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_init_param_v[] = { + { 0x00001404, 0x0001, 0x000d, 1 }, + { 0x00001404, 0x0001, 0x000c, 1 }, + { 0x00001404, 0x0001, 0x0009, 1 }, + { 0x00001404, 0x0001, 0x0008, 1 }, + { 0x00001404, 0x0001, 0x0007, 1 }, + { 0x00001404, 0x0001, 0x0006, 1 }, + { 0x00001404, 0x0001, 0x0005, 1 }, + { 0x00001404, 0x0001, 0x0004, 1 }, + { 0x00001404, 0x0001, 0x0003, 1 }, + { 0x00001404, 0x0003, 0x0000, 1 }, + { 0x00001406, 0xffff, 0x0000, 1 }, + { 0x00001408, 0xffff, 0x0000, 1 }, + { 0x0000140a, 0x0001, 0x000f, 1 }, + { 0x0000140a, 0x0001, 0x000e, 1 }, + { 0x0000140a, 0x0003, 0x000c, 1 }, + { 0x0000140a, 0x0007, 0x0008, 1 }, + { 0x0000140a, 0x00ff, 0x0000, 1 }, + { 0x0000140c, 0x00ff, 0x0000, 1 }, + { 0x0000140e, 0x0003, 0x000e, 1 }, + { 0x0000140e, 0x0001, 0x000a, 1 }, + { 0x0000140e, 0x0001, 0x0008, 1 }, + { 0x0000140e, 0x0001, 0x0000, 1 }, + { 0x00001410, 0x00ff, 0x0008, 1 }, + { 0x00001410, 0x00ff, 0x0000, 1 }, + { 0x00001412, 0x00ff, 0x0008, 1 }, + { 0x00001412, 0x00ff, 0x0000, 1 }, + { 0x00001416, 0x0001, 0x0000, 1 }, + { 0x00001418, 0x0001, 0x0008, 1 }, + { 0x00001418, 0x0001, 0x0000, 1 }, + { 0x0000141c, 0xffff, 0x0000, 1 }, + { 0x0000141e, 0xffff, 0x0000, 1 }, + { 0x00001420, 0xffff, 0x0000, 1 }, + { 0x00001422, 0xffff, 0x0000, 1 }, + { 0x00001424, 0x0001, 0x0008, 1 }, + { 0x00001424, 0x000f, 0x0000, 1 }, + { 0x00001430, 0x00ff, 0x0008, 1 }, + { 0x00001430, 0x00ff, 0x0000, 1 }, + { 0x00001432, 0x000f, 0x0008, 1 }, + { 0x00001432, 0x000f, 0x0000, 1 }, + { 0x00001434, 0x00ff, 0x0000, 1 }, + { 0x00001440, 0xffff, 0x0000, 1 }, + { 0x00001442, 0xffff, 0x0000, 1 }, + { 0x00001444, 0xffff, 0x0000, 1 }, + { 0x00001446, 0xffff, 0x0000, 1 }, + { 0x00001448, 0xffff, 0x0000, 1 }, + { 0x0000144a, 0xffff, 0x0000, 1 }, + { 0x0000144c, 0xffff, 0x0000, 1 }, + { 0x0000144e, 0xffff, 0x0000, 1 }, + { 0x00001450, 0xffff, 0x0000, 1 }, + { 0x00001452, 0xffff, 0x0000, 1 }, + { 0x00001454, 0xffff, 0x0000, 1 }, + { 0x00001456, 0xffff, 0x0000, 1 }, + { 0x00001458, 0xffff, 0x0000, 1 }, + { 0x0000145a, 0xffff, 0x0000, 1 }, + { 0x0000145c, 0xffff, 0x0000, 1 }, + { 0x0000145e, 0x00ff, 0x0000, 1 }, + { 0x00001460, 0x00ff, 0x0000, 1 }, + { 0x00001462, 0x00ff, 0x0000, 1 }, + { 0x00001464, 0x00ff, 0x0000, 1 }, + { 0x00001466, 0x00ff, 0x0000, 1 }, + { 0x00001468, 0x00ff, 0x0000, 1 }, + { 0x0000146a, 0x00ff, 0x0000, 1 }, + { 0x0000146c, 0x00ff, 0x0000, 1 }, + { 0x0000146e, 0x00ff, 0x0000, 1 }, + { 0x00001470, 0x00ff, 0x0000, 1 }, + { 0x00001472, 0x00ff, 0x0000, 1 }, + { 0x00001474, 0x00ff, 0x0000, 1 }, + { 0x00001476, 0x00ff, 0x0000, 1 }, + { 0x00001478, 0x00ff, 0x0000, 1 }, + { 0x0000147a, 0x00ff, 0x0000, 1 }, + { 0x0000147c, 0x00ff, 0x0000, 1 }, + { 0x0000147e, 0x00ff, 0x0000, 1 }, + { 0x00001480, 0xffff, 0x0000, 1 }, + { 0x00001482, 0xffff, 0x0000, 1 }, + { 0x00001484, 0xffff, 0x0000, 1 }, + { 0x00001486, 0xffff, 0x0000, 1 }, + { 0x00001488, 0xffff, 0x0000, 1 }, + { 0x0000148a, 0xffff, 0x0000, 1 }, + { 0x0000148c, 0xffff, 0x0000, 1 }, + { 0x0000148e, 0xffff, 0x0000, 1 }, + { 0x00001490, 0xffff, 0x0000, 1 }, + { 0x00001492, 0xffff, 0x0000, 1 }, + { 0x00001494, 0xffff, 0x0000, 1 }, + { 0x00001496, 0xffff, 0x0000, 1 }, + { 0x00001498, 0xffff, 0x0000, 1 }, + { 0x0000149a, 0xffff, 0x0000, 1 }, + { 0x0000149c, 0xffff, 0x0000, 1 }, + { 0x0000149e, 0xffff, 0x0000, 1 }, + { 0x000014a0, 0xffff, 0x0000, 1 }, + { 0x000014a2, 0xffff, 0x0000, 1 }, + { 0x000014a4, 0xffff, 0x0000, 1 }, + { 0x000014a6, 0xffff, 0x0000, 1 }, + { 0x000014a8, 0xffff, 0x0000, 1 }, + { 0x000014aa, 0xffff, 0x0000, 1 }, + { 0x000014ac, 0xffff, 0x0000, 1 }, + { 0x000014ae, 0xffff, 0x0000, 1 }, + { 0x000014b0, 0xffff, 0x0000, 1 }, + { 0x000014b2, 0xffff, 0x0000, 1 }, + { 0x000014b4, 0xffff, 0x0000, 1 }, + { 0x000014b6, 0xffff, 0x0000, 1 }, + { 0x000014b8, 0xffff, 0x0000, 1 }, + { 0x000014ba, 0xffff, 0x0000, 1 }, + { 0x000014bc, 0xffff, 0x0000, 1 }, + { 0x000014be, 0xffff, 0x0000, 1 }, + { 0x000014c0, 0xffff, 0x0000, 1 }, + { 0x000014c2, 0xffff, 0x0000, 1 }, + { 0x000014c4, 0xffff, 0x0000, 1 }, + { 0x000014c6, 0xffff, 0x0000, 1 }, + { 0x000014c8, 0xffff, 0x0000, 1 }, + { 0x000014ca, 0xffff, 0x0000, 1 }, + { 0x000014cc, 0xffff, 0x0000, 1 }, + { 0x000014ce, 0xffff, 0x0000, 1 }, + { 0x000014d0, 0xffff, 0x0000, 1 }, + { 0x000014d2, 0xffff, 0x0000, 1 }, + { 0x000014d4, 0xffff, 0x0000, 1 }, + { 0x000014d6, 0xffff, 0x0000, 1 }, + { 0x000014d8, 0xffff, 0x0000, 1 }, + { 0x000014da, 0xffff, 0x0000, 1 }, + { 0x000014dc, 0xffff, 0x0000, 1 }, + { 0x000014de, 0xffff, 0x0000, 1 }, + { 0x000014e0, 0xffff, 0x0000, 1 }, + { 0x000014e2, 0xffff, 0x0000, 1 }, + { 0x000014e4, 0xffff, 0x0000, 1 }, + { 0x000014e6, 0xffff, 0x0000, 1 }, + { 0x000014e8, 0xffff, 0x0000, 1 }, + { 0x000014ea, 0xffff, 0x0000, 1 }, + { 0x000014ec, 0xffff, 0x0000, 1 }, + { 0x000014ee, 0xffff, 0x0000, 1 }, + { 0x000014f0, 0xffff, 0x0000, 1 }, + { 0x000014f2, 0xffff, 0x0000, 1 }, + { 0x000014f4, 0xffff, 0x0000, 1 }, + { 0x000014f6, 0xffff, 0x0000, 1 }, + { 0x000014f8, 0xffff, 0x0000, 1 }, + { 0x000014fa, 0xffff, 0x0000, 1 }, + { 0x000014fc, 0xffff, 0x0000, 1 }, + { 0x000014fe, 0xffff, 0x0000, 1 }, + { 0x00001500, 0xffff, 0x0000, 1 }, + { 0x00001502, 0xffff, 0x0000, 1 }, + { 0x00001504, 0xffff, 0x0000, 1 }, + { 0x00001506, 0xffff, 0x0000, 1 }, + { 0x00001508, 0xffff, 0x0000, 1 }, + { 0x0000150a, 0xffff, 0x0000, 1 }, + { 0x0000150c, 0xffff, 0x0000, 1 }, + { 0x0000150e, 0xffff, 0x0000, 1 }, + { 0x00001510, 0xffff, 0x0000, 1 }, + { 0x00001512, 0xffff, 0x0000, 1 }, + { 0x00001514, 0xffff, 0x0000, 1 }, + { 0x00001516, 0xffff, 0x0000, 1 }, + { 0x00001518, 0xffff, 0x0000, 1 }, + { 0x0000151a, 0xffff, 0x0000, 1 }, + { 0x0000151c, 0xffff, 0x0000, 1 }, + { 0x0000151e, 0xffff, 0x0000, 1 }, + { 0x00001520, 0x0001, 0x000f, 1 }, + { 0x00001520, 0x0003, 0x000d, 1 }, + { 0x00001520, 0x00ff, 0x0000, 1 }, + { 0x00001522, 0x0fff, 0x0000, 1 }, + { 0x00001524, 0x0fff, 0x0000, 1 }, + { 0x00001526, 0x0fff, 0x0000, 1 }, + { 0x00001528, 0x0fff, 0x0000, 1 }, + { 0x0000152a, 0xffff, 0x0000, 1 }, + { 0x0000152c, 0xffff, 0x0000, 1 }, + { 0x0000152e, 0xffff, 0x0000, 1 }, + { 0x00001530, 0xffff, 0x0000, 1 }, + { 0x00001540, 0x0003, 0x000c, 1 }, + { 0x00001540, 0x0003, 0x0008, 1 }, + { 0x00001540, 0x0001, 0x0006, 1 }, + { 0x00001540, 0x0001, 0x0004, 1 }, + { 0x00001540, 0x0001, 0x0002, 1 }, + { 0x00001540, 0x0001, 0x0000, 1 }, + { 0x00001542, 0x07ff, 0x0000, 1 }, + { 0x00001544, 0x07ff, 0x0000, 1 }, + { 0x00001546, 0x0fff, 0x0000, 1 }, + { 0x00001548, 0x07ff, 0x0000, 1 }, + { 0x0000154a, 0x0fff, 0x0000, 1 }, + { 0x0000154c, 0x07ff, 0x0000, 1 }, + { 0x0000154e, 0x07ff, 0x0000, 1 }, + { 0x00001550, 0x0fff, 0x0000, 1 }, + { 0x00001552, 0x07ff, 0x0000, 1 }, + { 0x00001554, 0x07ff, 0x0000, 1 }, + { 0x00001556, 0x00ff, 0x0008, 1 }, + { 0x00001556, 0x00ff, 0x0000, 1 }, + { 0x00001558, 0x00ff, 0x0008, 1 }, + { 0x00001558, 0x00ff, 0x0000, 1 }, + { 0x0000155a, 0x00ff, 0x0000, 1 }, + { 0x0000155c, 0x07ff, 0x0000, 1 }, + { 0x0000155e, 0x07ff, 0x0000, 1 }, + { 0x00001560, 0x07ff, 0x0000, 1 }, + { 0x00001564, 0x0003, 0x0008, 1 }, + { 0x00001564, 0x0001, 0x0004, 1 }, + { 0x00001564, 0x0001, 0x0000, 1 }, + { 0x00001566, 0x0fff, 0x0000, 1 }, + { 0x00001568, 0x0fff, 0x0000, 1 }, + { 0x0000156a, 0x0fff, 0x0000, 1 }, + { 0x0000156c, 0x0fff, 0x0000, 1 }, + { 0x0000156e, 0x0fff, 0x0000, 1 }, + { 0x00001570, 0x0fff, 0x0000, 1 }, + { 0x00001572, 0x07ff, 0x0000, 1 }, + { 0x00001574, 0x07ff, 0x0000, 1 }, + { 0x00001576, 0x07ff, 0x0000, 1 }, + { 0x00001578, 0x07ff, 0x0000, 1 }, + { 0x0000157a, 0x0fff, 0x0000, 1 }, + { 0x0000157c, 0x0fff, 0x0000, 1 }, + { 0x0000157e, 0x0fff, 0x0000, 1 }, + { 0x00001580, 0x07ff, 0x0000, 1 }, + { 0x00001582, 0x07ff, 0x0000, 1 }, + { 0x00001584, 0x07ff, 0x0000, 1 }, + { 0x00001586, 0x0fff, 0x0000, 1 }, + { 0x00001588, 0x07ff, 0x0000, 1 }, + { 0x0000158a, 0x0fff, 0x0000, 1 }, + { 0x0000158c, 0x07ff, 0x0000, 1 }, + { 0x0000158e, 0x07ff, 0x0000, 1 }, + { 0x00001590, 0x0fff, 0x0000, 1 }, + { 0x00001592, 0x07ff, 0x0000, 1 }, + { 0x00001594, 0x07ff, 0x0000, 1 }, + { 0x00001596, 0x07ff, 0x0000, 1 }, + { 0x00001598, 0x07ff, 0x0000, 1 }, + { 0x0000159a, 0x07ff, 0x0000, 1 }, + { 0x0000159c, 0x07ff, 0x0000, 1 }, + { 0x00001564, 0x0001, 0x0001, 1 }, + { 0x00001540, 0x0001, 0x0001, 1 }, + { 0x00001426, 0x0003, 0x000e, 1 }, + { 0x00001426, 0x0003, 0x0008, 1 }, + { 0x00001426, 0x00ff, 0x0000, 1 }, + { 0x00001428, 0xffff, 0x0000, 1 }, + { 0x0000142a, 0xffff, 0x0000, 1 }, + { 0x0000142c, 0xffff, 0x0000, 1 }, + { 0x0000142e, 0xffff, 0x0000, 1 }, +}; + +/****************************************************************************** + Name : Register Table of MB86 initialization parameter A + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_init_param_a[] = { + { 0x00001802, 0x0fff, 0x0002, 1 }, + { 0x00001802, 0x0003, 0x0000, 1 }, + { 0x00001804, 0xffff, 0x0000, 1 }, + { 0x00001806, 0x0001, 0x000e, 1 }, + { 0x00001806, 0x0001, 0x000d, 1 }, + { 0x00001806, 0x0003, 0x000b, 1 }, + { 0x00001806, 0x0007, 0x0008, 1 }, + { 0x00001806, 0x0001, 0x0007, 1 }, + { 0x00001806, 0x0001, 0x0006, 1 }, + { 0x00001806, 0x0003, 0x0004, 1 }, + { 0x00001806, 0x0001, 0x0002, 1 }, + { 0x00001806, 0x0001, 0x0001, 1 }, + { 0x00001806, 0x0001, 0x0000, 1 }, + { 0x00001808, 0x0001, 0x000e, 1 }, + { 0x00001808, 0x0001, 0x000d, 1 }, + { 0x00001808, 0x0003, 0x000b, 1 }, + { 0x00001808, 0x0007, 0x0008, 1 }, + { 0x00001808, 0x0001, 0x0007, 1 }, + { 0x00001808, 0x0001, 0x0006, 1 }, + { 0x00001808, 0x0003, 0x0004, 1 }, + { 0x00001808, 0x0001, 0x0002, 1 }, + { 0x00001808, 0x0001, 0x0001, 1 }, + { 0x00001808, 0x0001, 0x0000, 1 }, + { 0x0000180a, 0xffff, 0x0000, 1 }, + { 0x0000180c, 0xffff, 0x0000, 1 }, + { 0x0000180e, 0x0001, 0x000f, 1 }, + { 0x0000180e, 0x0003, 0x0008, 1 }, + { 0x0000180e, 0x0001, 0x0000, 1 }, + { 0x00001810, 0xffff, 0x0000, 1 }, + { 0x00001812, 0xffff, 0x0000, 1 }, + { 0x00001818, 0xffff, 0x0000, 1 }, + { 0x0000181a, 0xffff, 0x0000, 1 }, + { 0x0000181c, 0xffff, 0x0000, 1 }, + { 0x0000181e, 0xffff, 0x0000, 1 }, + { 0x00001820, 0x0003, 0x0005, 1 }, + { 0x00001820, 0x0001, 0x0004, 1 }, + { 0x00001820, 0x0001, 0x0003, 1 }, + { 0x00001820, 0x0003, 0x0000, 1 }, + { 0x00001830, 0x0003, 0x0005, 1 }, + { 0x00001830, 0x0001, 0x0004, 1 }, + { 0x00001830, 0x0001, 0x0003, 1 }, + { 0x00001830, 0x0003, 0x0001, 1 }, + { 0x00001830, 0x0001, 0x0000, 1 }, + { 0x00001850, 0x00ff, 0x0008, 1 }, + { 0x00001850, 0x0001, 0x0005, 1 }, + { 0x00001850, 0x0003, 0x0003, 1 }, + { 0x00001850, 0x0003, 0x0001, 1 }, + { 0x00001850, 0x0001, 0x0000, 1 }, + { 0x00001852, 0xffff, 0x0000, 1 }, + { 0x00001860, 0x000f, 0x0000, 1 }, + { 0x00001880, 0x0007, 0x0005, 1 }, + { 0x00001880, 0x0003, 0x0003, 1 }, + { 0x00001880, 0x0001, 0x0002, 1 }, + { 0x00001880, 0x0003, 0x0000, 1 }, + { 0x000018b0, 0x0003, 0x0002, 1 }, + { 0x000018b0, 0x0003, 0x0000, 1 }, + { 0x000018c0, 0x0001, 0x000f, 1 }, + { 0x000018c0, 0x000f, 0x0000, 1 }, +}; + +/****************************************************************************** + Name : Register Table of MB86 vedio command + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_vedio_command[] = { + { 0x00000000, 0x0001, 0x000f, 1 }, + { 0x00000002, 0x00ff, 0x0000, 1 }, + { 0x00000004, 0x0001, 0x0004, 1 }, + { 0x00000004, 0x0001, 0x0002, 1 }, + { 0x00000004, 0x0003, 0x0000, 1 }, + { 0x00000006, 0x0003, 0x0000, 1 }, + { 0x00000008, 0xffff, 0x0000, 1 }, + { 0x0000000a, 0x0003, 0x0008, 1 }, + { 0x0000000a, 0x0003, 0x0000, 1 }, + { 0x0000000c, 0xffff, 0x0000, 1 }, + { 0x00000010, 0xffff, 0x0000, 1 }, + { 0x00000012, 0xffff, 0x0000, 1 }, + { 0x00000014, 0xffff, 0x0000, 1 }, + { 0x00000016, 0x0001, 0x0000, 1 }, + { 0x00000100, 0xffff, 0x0000, 1 }, + { 0x00000102, 0xffff, 0x0000, 1 }, + { 0x00000104, 0xffff, 0x0000, 1 }, + { 0x00000106, 0xffff, 0x0000, 1 }, + { 0x00000108, 0xffff, 0x0000, 1 }, + { 0x0000010a, 0xffff, 0x0000, 1 }, + { 0x0000010c, 0xffff, 0x0000, 1 }, + { 0x0000010e, 0xffff, 0x0000, 1 }, + { 0x00000110, 0xffff, 0x0000, 1 }, + { 0x00000112, 0xffff, 0x0000, 1 }, + { 0x00000114, 0xffff, 0x0000, 1 }, + { 0x00000116, 0xffff, 0x0000, 1 }, + { 0x00000118, 0xffff, 0x0000, 1 }, + { 0x0000011a, 0xffff, 0x0000, 1 }, + { 0x0000011c, 0xffff, 0x0000, 1 }, + { 0x0000011e, 0xffff, 0x0000, 1 }, + { 0x00000120, 0xffff, 0x0000, 1 }, + { 0x00000122, 0xffff, 0x0000, 1 }, + { 0x00000124, 0xffff, 0x0000, 1 }, + { 0x00000126, 0xffff, 0x0000, 1 }, + { 0x00000128, 0xffff, 0x0000, 1 }, + { 0x0000012a, 0xffff, 0x0000, 1 }, + { 0x0000012c, 0xffff, 0x0000, 1 }, + { 0x0000012e, 0xffff, 0x0000, 1 }, + { 0x00000130, 0xffff, 0x0000, 1 }, + { 0x00000132, 0xffff, 0x0000, 1 }, + { 0x00000134, 0xffff, 0x0000, 1 }, + { 0x00000136, 0xffff, 0x0000, 1 }, + { 0x00000138, 0xffff, 0x0000, 1 }, + { 0x0000013a, 0xffff, 0x0000, 1 }, + { 0x0000013c, 0xffff, 0x0000, 1 }, + { 0x0000013e, 0xffff, 0x0000, 1 }, + { 0x00000140, 0xffff, 0x0000, 1 }, + { 0x00000142, 0xffff, 0x0000, 1 }, + { 0x00000144, 0xffff, 0x0000, 1 }, + { 0x00000146, 0xffff, 0x0000, 1 }, + { 0x00000148, 0xffff, 0x0000, 1 }, + { 0x0000014a, 0xffff, 0x0000, 1 }, + { 0x0000014c, 0xffff, 0x0000, 1 }, + { 0x0000014e, 0xffff, 0x0000, 1 }, + { 0x00000150, 0xffff, 0x0000, 1 }, + { 0x00000152, 0xffff, 0x0000, 1 }, + { 0x00000154, 0xffff, 0x0000, 1 }, + { 0x00000156, 0xffff, 0x0000, 1 }, + { 0x00000158, 0xffff, 0x0000, 1 }, + { 0x0000015a, 0xffff, 0x0000, 1 }, + { 0x0000015c, 0xffff, 0x0000, 1 }, + { 0x0000015e, 0xffff, 0x0000, 1 }, + { 0x00000160, 0xffff, 0x0000, 1 }, + { 0x00000162, 0xffff, 0x0000, 1 }, + { 0x00000164, 0xffff, 0x0000, 1 }, + { 0x00000166, 0xffff, 0x0000, 1 }, + { 0x00000168, 0xffff, 0x0000, 1 }, + { 0x0000016a, 0xffff, 0x0000, 1 }, + { 0x0000016c, 0xffff, 0x0000, 1 }, + { 0x0000016e, 0xffff, 0x0000, 1 }, + { 0x00000170, 0xffff, 0x0000, 1 }, + { 0x00000172, 0xffff, 0x0000, 1 }, + { 0x00000174, 0xffff, 0x0000, 1 }, + { 0x00000176, 0xffff, 0x0000, 1 }, + { 0x00000178, 0xffff, 0x0000, 1 }, + { 0x0000017a, 0xffff, 0x0000, 1 }, + { 0x0000017c, 0xffff, 0x0000, 1 }, + { 0x0000017e, 0xffff, 0x0000, 1 }, + { 0x00000180, 0xffff, 0x0000, 1 }, + { 0x00000182, 0xffff, 0x0000, 1 }, + { 0x00000184, 0xffff, 0x0000, 1 }, + { 0x00000186, 0xffff, 0x0000, 1 }, + { 0x00000188, 0xffff, 0x0000, 1 }, + { 0x0000018a, 0xffff, 0x0000, 1 }, + { 0x0000018c, 0xffff, 0x0000, 1 }, + { 0x0000018e, 0xffff, 0x0000, 1 }, + { 0x00000190, 0xffff, 0x0000, 1 }, + { 0x00000192, 0xffff, 0x0000, 1 }, + { 0x00000194, 0xffff, 0x0000, 1 }, + { 0x00000196, 0xffff, 0x0000, 1 }, + { 0x00000198, 0xffff, 0x0000, 1 }, + { 0x0000019a, 0xffff, 0x0000, 1 }, + { 0x0000019c, 0xffff, 0x0000, 1 }, + { 0x0000019e, 0xffff, 0x0000, 1 }, + { 0x000001a0, 0xffff, 0x0000, 1 }, + { 0x000001a2, 0xffff, 0x0000, 1 }, + { 0x000001a4, 0xffff, 0x0000, 1 }, + { 0x000001a6, 0xffff, 0x0000, 1 }, + { 0x000001a8, 0xffff, 0x0000, 1 }, + { 0x000001aa, 0xffff, 0x0000, 1 }, + { 0x000001ac, 0xffff, 0x0000, 1 }, + { 0x000001ae, 0xffff, 0x0000, 1 }, + { 0x000001b0, 0xffff, 0x0000, 1 }, + { 0x000001b2, 0xffff, 0x0000, 1 }, + { 0x000001b4, 0xffff, 0x0000, 1 }, + { 0x000001b6, 0xffff, 0x0000, 1 }, + { 0x000001b8, 0xffff, 0x0000, 1 }, + { 0x000001ba, 0xffff, 0x0000, 1 }, + { 0x000001bc, 0xffff, 0x0000, 1 }, + { 0x000001be, 0xffff, 0x0000, 1 }, + { 0x000001c0, 0xffff, 0x0000, 1 }, + { 0x000001c2, 0xffff, 0x0000, 1 }, + { 0x000001c4, 0xffff, 0x0000, 1 }, + { 0x000001c6, 0xffff, 0x0000, 1 }, + { 0x000001c8, 0xffff, 0x0000, 1 }, + { 0x000001ca, 0xffff, 0x0000, 1 }, + { 0x000001cc, 0xffff, 0x0000, 1 }, + { 0x000001ce, 0xffff, 0x0000, 1 }, + { 0x000001d0, 0xffff, 0x0000, 1 }, + { 0x000001d2, 0xffff, 0x0000, 1 }, + { 0x000001d4, 0xffff, 0x0000, 1 }, + { 0x000001d6, 0xffff, 0x0000, 1 }, + { 0x000001d8, 0xffff, 0x0000, 1 }, + { 0x000001da, 0xffff, 0x0000, 1 }, + { 0x000001dc, 0xffff, 0x0000, 1 }, + { 0x000001de, 0xffff, 0x0000, 1 }, + { 0x000001e0, 0xffff, 0x0000, 1 }, + { 0x000001e2, 0xffff, 0x0000, 1 }, + { 0x000001e4, 0xffff, 0x0000, 1 }, + { 0x000001e6, 0xffff, 0x0000, 1 }, + { 0x000001e8, 0xffff, 0x0000, 1 }, + { 0x000001ea, 0xffff, 0x0000, 1 }, + { 0x000001ec, 0xffff, 0x0000, 1 }, + { 0x000001ee, 0xffff, 0x0000, 1 }, + { 0x000001f0, 0xffff, 0x0000, 1 }, + { 0x000001f2, 0xffff, 0x0000, 1 }, + { 0x000001f4, 0xffff, 0x0000, 1 }, + { 0x000001f6, 0xffff, 0x0000, 1 }, + { 0x000001f8, 0xffff, 0x0000, 1 }, + { 0x000001fa, 0xffff, 0x0000, 1 }, + { 0x000001fc, 0xffff, 0x0000, 1 }, + { 0x000001fe, 0xffff, 0x0000, 1 }, +}; + +/****************************************************************************** + Name : Register Table of MB86 audio command + Function : To define the register address and field data for MB86 +*******************************************************************************/ +const struct fmb_param_table fmb_audio_command[] = { + { 0x00000000, 0x0001, 0x000f, 1 }, + { 0x00000002, 0x0001, 0x0000, 1 }, + { 0x00000006, 0x0003, 0x0000, 1 }, + { 0x00000008, 0xffff, 0x0000, 1 }, + { 0x0000000a, 0xffff, 0x0000, 1 }, + { 0x00000010, 0x0003, 0x0000, 1 }, + { 0x00000012, 0x00ff, 0x0008, 1 }, + { 0x00000012, 0x00ff, 0x0000, 1 }, + { 0x00000014, 0xffff, 0x0000, 1 }, + { 0x00000016, 0xffff, 0x0000, 1 }, + { 0x00000018, 0xffff, 0x0000, 1 }, + { 0x0000001a, 0xffff, 0x0000, 1 }, +}; + +const struct fmb_param_head_table g_Fmb_param_table[] = { + { 0x0000, &fmb_add_param_m[0], SIZEOF_ARRAY(fmb_add_param_m) }, + { 0x0001, &fmb_add_param_v[0], SIZEOF_ARRAY(fmb_add_param_v) }, + { 0x0002, &fmb_add_param_a[0], SIZEOF_ARRAY(fmb_add_param_a) }, + { 0x0003, &fmb_init_param_m[0], SIZEOF_ARRAY(fmb_init_param_m) }, + { 0x0004, &fmb_init_param_v[0], SIZEOF_ARRAY(fmb_init_param_v) }, + { 0x0005, &fmb_init_param_a[0], SIZEOF_ARRAY(fmb_init_param_a) }, + { 0x0006, &fmb_vedio_command[0], SIZEOF_ARRAY(fmb_vedio_command)}, + { 0x0007, &fmb_audio_command[0], SIZEOF_ARRAY(fmb_audio_command)}, + { 0x0008, NULL, 0 } +}; diff --git a/fmb_driver/fmb_core.c b/fmb_driver/fmb_core.c new file mode 100644 index 0000000..64c42ec --- /dev/null +++ b/fmb_driver/fmb_core.c @@ -0,0 +1,6609 @@ +/** + * @brief LSI Core-dependent part of MB86 Linux driver + * @since 2009/01/08 + * @note None + * @attention None + * <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> + */ + +/* + * 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 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. + */ + +/****************************************************************************/ +#include "fmb.h" +#include "fmb_hw.h" +#include <linux/semaphore.h> +#include <linux/delay.h> + +PREPARE_DEBUG_FOR_FUNC(); + +int g_Dmacount_read = FMB_DATA_DMACOUNT_READ_DEF; +module_param(g_Dmacount_read, int, S_IRUGO); +int g_Dmacount_write = FMB_DATA_DMACOUNT_WRITE_DEF; +module_param(g_Dmacount_write, int, S_IRUGO); + +/********************************************************/ +/* GROBAL VALUES */ +/********************************************************/ +static struct fmb_core_private s_Fmb_core_private_list[FMB_MAX_CARDS]; + +/********************************************************/ +/* FUNCTION PROTOTYPE */ +/********************************************************/ +static void fmb_core_private_data_release( struct fmb_core_private* priv_p ); + +/** + * @brief Allocates the DMA buffer(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return 0 success<br> + * @return -1 fail<br> + * @note None + * @attention None + */ +static int fmb_core_alloc_dma_buffer_snd( struct fmb_core_private* priv_p ) +{ + int n; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* Get buffer */ + for (n = 0; n < FMB_DMA_SND_BUF_CNT; n++) { + dma_addr_t dma_addr; + priv_p->dma_snd_queue.buf[n].addr_l = pci_alloc_consistent( + priv_p->hw_priv_p->pci_dev_p, + FMB_DMA_SND_BUF_SIZE, + &dma_addr ); + if (priv_p->dma_snd_queue.buf[n].addr_l == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate DMA snd buffer. n = %d", n ); + break; + } + priv_p->dma_snd_queue.buf[n].addr_p = dma_addr; + } + if (n < FMB_DMA_SND_BUF_CNT) { + for (; n >= 0; --n) { + MSG( DEBUG_LVL, minor, "Release DMA snd buffer. n = %d", n ); + pci_free_consistent( priv_p->hw_priv_p->pci_dev_p, + FMB_DMA_SND_BUF_SIZE, + priv_p->dma_snd_queue.buf[n].addr_l, + priv_p->dma_snd_queue.buf[n].addr_p ); + } + return -1; + } + + MSG( INTERNAL_LOG, minor, "END" ); + + return 0; +} + +/** + * @brief Allocates the DMA buffer(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return 0 success<br> + * -1 fail<br> + * @note None + * @attention None + */ +static int fmb_core_alloc_dma_buffer_rcv( struct fmb_core_private* priv_p ) +{ + int n; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* Get buffer */ + for (n = 0; n < FMB_DMA_RCV_BUF_CNT; n++) { + dma_addr_t dma_addr; + priv_p->dma_rcv_queue.buf[n].addr_l = pci_alloc_consistent( + priv_p->hw_priv_p->pci_dev_p, + FMB_DMA_RCV_BUF_SIZE, + &dma_addr ); + if (priv_p->dma_rcv_queue.buf[n].addr_l == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate DMA rcv buffer. n = %d", n ); + break; + } + priv_p->dma_rcv_queue.buf[n].addr_p = dma_addr; + } + if (n < FMB_DMA_RCV_BUF_CNT) { + for (; n >= 0; --n) { + MSG( DEBUG_LVL, minor, "Release DMA rcv buffer. n = %d", n ); + pci_free_consistent( priv_p->hw_priv_p->pci_dev_p, + FMB_DMA_RCV_BUF_SIZE, + priv_p->dma_rcv_queue.buf[n].addr_l, + priv_p->dma_rcv_queue.buf[n].addr_p ); + } + return -1; + } + + MSG( INTERNAL_LOG, minor, "END" ); + + return 0; +} + +/** + * @brief Clears all DMA channels. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_clear_dma_all( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00000704 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00000708 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00000700 ); + + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_DEC_CNT, 0x00000001 ); + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_DEC_CNT, 0x00000002 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000604 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000608 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000600 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000608 ); + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_DEC_CNT, 0x00000000 ); + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Clears the DMA channel(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_clear_dma_snd( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000604 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000608 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000600 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00000608 ); + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Clears the DMA channel(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_clear_dma_rcv( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00000704 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00000708 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00000700 ); + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Enables the DMA channel(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_enable_dma_snd( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_DEC_CNT, 0x00000001 ); + mdelay( 1 ); /* wait 1ms */ + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_DEC_CNT, 0x00000002 ); + mdelay( 1 ); /* wait 1ms */ + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Enables the DMA channel(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_enable_dma_rcv( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_ENC_CNT, 0x00000001 ); + mdelay( 1 ); /* wait 1ms */ + Fmb_hw_reg_write_lsi_master( hw_priv_p, FPCI_ENC_CNT, 0x00000002 ); + mdelay( 1 ); /* wait 1ms */ + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a busy DMA buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return the pointer to the busy DMA buffer + * @note None + * @attention None + */ +struct fmb_dma_buf* Fmb_core_get_busy_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p) +{ + struct fmb_dma_buf* tmp_p; + unsigned long flags; + int minor; + + flags = 0; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + if (queue_p->b_head_p == NULL) { + MSG( INTERNAL_LOG, minor, "busy=%d free=%d", queue_p->b_num, queue_p->f_num ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + MSG( INTERNAL_LOG, minor, "END" ); + return NULL; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* in case of queue tail */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + } + else { + queue_p->b_head_p = tmp_p->next_p; + } + + tmp_p->next_p = NULL; + queue_p->b_num--; + MSG( INTERNAL_LOG, minor, "busy=%d free=%d", queue_p->b_num, queue_p->f_num ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_LOG, minor, "END" ); + return tmp_p; + } +} + +/** + * @brief Dequeues a free DMA buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return the pointer to the free DMA buffer + * @note None + * @attention None + */ +struct fmb_dma_buf* Fmb_core_get_free_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p) +{ + struct fmb_dma_buf* tmp_p; + unsigned long flags; + int minor; + + flags = 0; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + if (queue_p->f_head_p == NULL) { + MSG( INTERNAL_LOG, minor, "busy=%d free=%d", queue_p->b_num, queue_p->f_num ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + MSG( INTERNAL_LOG, minor, "END" ); + return NULL; + } + else { + tmp_p = queue_p->f_head_p; + if (tmp_p->next_p == NULL) { + /* in case of queue tail */ + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + } + else { + queue_p->f_head_p = tmp_p->next_p; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + MSG( INTERNAL_LOG, minor, "busy=%d free=%d", queue_p->b_num, queue_p->f_num ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + MSG( INTERNAL_LOG, minor, "END" ); + return tmp_p; + } +} + +/** + * @brief Enqueues the free DMA buffer to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] buf_p the pointer to the free DMA buffer + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_buf* buf_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p) +{ + unsigned long flags; + int minor; + + flags = 0; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + if (queue_p->f_head_p == NULL) { + /* in case there is no buffer in the queue */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + queue_p->f_num++; + + MSG( INTERNAL_LOG, minor, "wake up process of waiting for DMA buffer." ); + wake_up( &queue_p->buf_waitq ); + + } + else { + /* in case there are some buffers in the queue */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + queue_p->f_num++; + } + + MSG( INTERNAL_LOG, minor, "busy=%d free=%d", queue_p->b_num, queue_p->f_num ); + + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the busy DMA buffer to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] buf_p the pointer to the busy DMA buffer + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_buf* buf_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p) +{ + unsigned long flags; + int minor; + + flags = 0; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + if (queue_p->b_head_p == NULL) { + /* in case there is no buffer in the queue */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + else { + /* in case there are some buffers in the queue */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + + MSG( INTERNAL_LOG, minor, "busy=%d free=%d", queue_p->b_num, queue_p->f_num ); + + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the DMA queue(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock for the DMA queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_dma_queue_snd( struct fmb_core_private* priv_p, + spinlock_t* lock_p ) +{ + int i; + unsigned long flags; + struct fmb_dma_queue* queue_p; + int minor; + + flags = 0; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + queue_p = &priv_p->dma_snd_queue.dma_queue; + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + queue_p->dma_status = FMB_DMA_STOP; + MSG( INTERNAL_LOG, minor, "DMA1 status change *** -> STOP" ); + + queue_p->dma_data_p = NULL; + queue_p->copy_data_p = NULL; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + queue_p->f_num = 0; + queue_p->b_num = 0; + + /* enqueue all buffers to the free DMA queue */ + for (i = 0 ; i < FMB_DMA_SND_BUF_CNT ; i++) { + Fmb_core_add_free_dma_buf( priv_p, &(priv_p->dma_snd_queue.buf[i]), queue_p, NULL ); + } + + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the DMA queue(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock for the DMA queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_dma_queue_rcv( struct fmb_core_private* priv_p, + spinlock_t* lock_p ) +{ + int i; + unsigned long flags; + struct fmb_dma_queue* queue_p; + int minor; + + flags = 0; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + queue_p = &priv_p->dma_rcv_queue.dma_queue; + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + priv_p->dma_rcv_queue.dma_comp_size = 0; + queue_p->dma_status = FMB_DMA_STOP; + MSG( INTERNAL_LOG, minor, "DMA2 status change *** -> STOP" ); + + queue_p->dma_data_p = NULL; + queue_p->copy_data_p = NULL; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + queue_p->f_num = 0; + queue_p->b_num = 0; + + for (i = 0 ; i < FMB_DMA_RCV_BUF_CNT ; i++) { + Fmb_core_add_free_dma_buf( priv_p, &(priv_p->dma_rcv_queue.buf[i]), queue_p, NULL ); + } + + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Releases the DMA buffer(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +static void fmb_core_release_dma_buffer_snd( + struct fmb_core_private* priv_p +) +{ + int n; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + for (n = 0; n < FMB_DMA_SND_BUF_CNT; n++) { + pci_free_consistent( priv_p->hw_priv_p->pci_dev_p, + FMB_DMA_SND_BUF_SIZE, + priv_p->dma_snd_queue.buf[n].addr_l, + priv_p->dma_snd_queue.buf[n].addr_p ); + } + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** + * @brief Releases the DMA buffer(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +static void fmb_core_release_dma_buffer_rcv( + struct fmb_core_private* priv_p +) +{ + int n; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + for (n = 0; n < FMB_DMA_RCV_BUF_CNT; n++) { + pci_free_consistent( priv_p->hw_priv_p->pci_dev_p, + FMB_DMA_RCV_BUF_SIZE, + priv_p->dma_rcv_queue.buf[n].addr_l, + priv_p->dma_rcv_queue.buf[n].addr_p ); + } + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** + * @brief Initializes the DMA queue(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return 0 success<br> + * -1 fail<br> + * @note None + * @attention None + */ +static int fmb_core_init_dma_queue_snd( + struct fmb_core_private* priv_p +) +{ + int i; + int result; + unsigned long flags; + struct fmb_dma_queue* queue_p = &priv_p->dma_snd_queue.dma_queue; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + spin_lock_init( &priv_p->dma_snd_queue.lock ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->dma_snd_queue.lock, flags ); + + init_MUTEX( &priv_p->dma_snd_queue.mutex_write ); + init_waitqueue_head( &queue_p->buf_waitq ); + init_waitqueue_head( &queue_p->comp_waitq ); + + queue_p->dma_status = FMB_DMA_STOP; + MSG( INTERNAL_LOG, minor, "DMA1 status change *** -> STOP" ); + + queue_p->dma_data_p = NULL; + queue_p->copy_data_p = NULL; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + queue_p->f_num = 0; + queue_p->b_num = 0; + + for (i = 0 ; i < FMB_DMA_SND_BUF_CNT ; i++) { + priv_p->dma_snd_queue.buf[i].addr_l = NULL; + priv_p->dma_snd_queue.buf[i].trans_size = 0; + priv_p->dma_snd_queue.buf[i].copy_size = 0; + priv_p->dma_snd_queue.buf[i].next_p = NULL; + } + + result = fmb_core_alloc_dma_buffer_snd( priv_p ); + if (result < 0) { + MSG( INTERNAL_ERR_LVL, minor, "cannot allocate DMA memory" ); + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->dma_snd_queue.lock, flags ); + return -1; + } + + for (i = 0 ; i < FMB_DMA_SND_BUF_CNT ; i++) { + Fmb_core_add_free_dma_buf( priv_p, &(priv_p->dma_snd_queue.buf[i]), queue_p, NULL ); + } + + Fmb_core_enable_dma_snd( priv_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->dma_snd_queue.lock, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); + + return 0; +} + +/** + * @brief Initializes the DMA queue(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return 0 success<br> + * -1 fail<br> + * @note None + * @attention None + */ +static int fmb_core_init_dma_queue_rcv( + struct fmb_core_private* priv_p +) +{ + int i; + int result; + unsigned long flags; + struct fmb_dma_queue* queue_p = &priv_p->dma_rcv_queue.dma_queue; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + spin_lock_init( &priv_p->dma_rcv_queue.lock ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->dma_rcv_queue.lock, flags ); + + priv_p->dma_rcv_queue.dma_comp_size = 0; + init_waitqueue_head( &priv_p->dma_rcv_queue.comp_waitq ); + + init_MUTEX( &priv_p->dma_rcv_queue.mutex_read ); + + init_waitqueue_head( &queue_p->buf_waitq ); + init_waitqueue_head( &queue_p->comp_waitq ); + + queue_p->dma_status = FMB_DMA_STOP; + MSG( INTERNAL_LOG, minor, "DMA2 status change *** -> STOP" ); + + queue_p->dma_data_p = NULL; + queue_p->copy_data_p = NULL; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + queue_p->f_num = 0; + queue_p->b_num = 0; + + for (i = 0 ; i < FMB_DMA_RCV_BUF_CNT ; i++) { + priv_p->dma_rcv_queue.buf[i].addr_l = NULL; + priv_p->dma_rcv_queue.buf[i].trans_size = FMB_DMA_RCV_BUF_SIZE; + priv_p->dma_rcv_queue.buf[i].copy_size = 0; + priv_p->dma_rcv_queue.buf[i].next_p = NULL; + } + + result = fmb_core_alloc_dma_buffer_rcv( priv_p ); + if (result < 0) { + MSG( INTERNAL_ERR_LVL, minor, "cannot allocate DMA memory" ); + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->dma_rcv_queue.lock, flags ); + return -1; + } + + for (i = 0 ; i < FMB_DMA_RCV_BUF_CNT ; i++) { + Fmb_core_add_free_dma_buf( priv_p, &(priv_p->dma_rcv_queue.buf[i]), queue_p, NULL ); + } + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->dma_rcv_queue.lock, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); + + return 0; +} + +/** + * @brief Releases the DMA queue(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return 0 success<br> + * -1 fail<br> + * @note None + * @attention None + */ +static void fmb_core_release_dma_queue_snd( + struct fmb_core_private* priv_p +) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + fmb_core_release_dma_buffer_snd( priv_p ); + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** + * @brief Releases the DMA queue(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return 0 success<br> + * -1 fail<br> + * @note None + * @attention None + */ +static void fmb_core_release_dma_queue_rcv( + struct fmb_core_private* priv_p +) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + fmb_core_release_dma_buffer_rcv( priv_p ); + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** + * @brief Starts the DMA access(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock + * @return None + * @note None + * @attention None + */ +void Fmb_core_start_dma_snd( + struct fmb_core_private* priv_p, + spinlock_t* lock_p +) +{ + struct fmb_hard_private* hw_priv_p; + struct fmb_dma_buf* dma_buf_p; + unsigned long flags; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + flags = 0; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + if (priv_p->dma_snd_queue.dma_queue.dma_data_p != NULL) { + MSG( INTERNAL_LOG, minor, "Skip DMA...(In DMA transfer, buf:0x%08x)", + (unsigned int)priv_p->dma_snd_queue.dma_queue.dma_data_p ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + return; + } + + dma_buf_p = Fmb_core_get_busy_dma_buf( priv_p, &priv_p->dma_snd_queue.dma_queue, NULL); + if (dma_buf_p == NULL) { + MSG( INTERNAL_LOG, minor, "Skip DMA...(No busy buffer)" ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + return; + } + + priv_p->dma_snd_queue.dma_queue.dma_data_p = dma_buf_p; + + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00030600 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1PCIADR, dma_buf_p->addr_p ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1TCOUNT, dma_buf_p->trans_size ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00030601 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA1CMDSTS, 0x00030603 ); + + MSG(DMA1MSG_LVL, minor, "DMA snd"); + MSG( INTERNAL_LOG, minor, "Start DMA!" ); + MSG( INTERNAL_LOG, minor, "buf = 0x%08x", (unsigned int)dma_buf_p ); + MSG( INTERNAL_LOG, minor, "addr(p) = 0x%08x", (unsigned int)dma_buf_p->addr_p ); + MSG( INTERNAL_LOG, minor, "size = 0x%08x", (unsigned int)dma_buf_p->trans_size ); + MSG( INTERNAL_LOG, minor, "cmd/stat = 0x%08lx", Fmb_hw_reg_read_dma( hw_priv_p, DMA1CMDSTS ) ); + + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Starts the DMA access(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock + * @return None + * @note None + * @attention None + */ +void Fmb_core_start_dma_rcv( + struct fmb_core_private* priv_p, + spinlock_t* lock_p +) +{ + struct fmb_hard_private* hw_priv_p; + struct fmb_dma_buf* dma_buf_p; + unsigned long flags; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + flags = 0; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + if (lock_p != NULL) { + spin_lock_irqsave( lock_p, flags ); + } + + if (priv_p->dma_rcv_queue.dma_queue.dma_status == FMB_DMA_STOP) { + MSG( INTERNAL_LOG, minor, "Skip DMA...(DMA status is stop!)" ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + return; + } + + if (priv_p->dma_rcv_queue.dma_queue.dma_data_p != NULL) { + MSG( INTERNAL_LOG, minor, "Skip DMA...(In DMA transfer, buf:0x%08x)", + (unsigned int)priv_p->dma_rcv_queue.dma_queue.dma_data_p ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + return; + } + + dma_buf_p = Fmb_core_get_free_dma_buf( priv_p, &priv_p->dma_rcv_queue.dma_queue, NULL ); + if ( dma_buf_p == NULL) { + MSG( INTERNAL_LOG, minor, "Skip DMA...(No free buffer)" ); + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + return; + } + + priv_p->dma_rcv_queue.dma_queue.dma_data_p = dma_buf_p; + + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00030700 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0PCIADR, dma_buf_p->addr_p ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0TCOUNT, dma_buf_p->trans_size ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00030701 ); + Fmb_hw_reg_write_dma( hw_priv_p, DMA0CMDSTS, 0x00030703 ); + + MSG(DMA0MSG_LVL, minor, "DMA rcv"); + MSG( INTERNAL_LOG, minor, "Start DMA!" ); + MSG( INTERNAL_LOG, minor, " buf = 0x%08x", (unsigned int)dma_buf_p ); + MSG( INTERNAL_LOG, minor, " addr(p) = 0x%08x", (unsigned int)dma_buf_p->addr_p ); + MSG( INTERNAL_LOG, minor, " size = 0x%08x", (unsigned int)dma_buf_p->trans_size ); + MSG( INTERNAL_LOG, minor, " cmd/status = 0x%08lx", Fmb_hw_reg_read_dma( hw_priv_p, DMA0CMDSTS ) ); + + /* spin unlock */ + if (lock_p != NULL) { + spin_unlock_irqrestore( lock_p, flags ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief The tasklet for the DMA completion(HOST -> LSI). + * @param[in] arg the pointer to the hw private data + * @return None + * @note None + * @attention None + */ +static void fmb_core_dma_snd_tasklet( unsigned long data ) +{ + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + struct fmb_dma_buf* dma_buf_p; + unsigned long flags; + int minor; + + hw_priv_p = (struct fmb_hard_private*)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_LOG, minor, "++++++++++++++++++++++++++++++++++++++++" ); + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->dma_snd_queue.lock, flags ); + + dma_buf_p = priv_p->dma_snd_queue.dma_queue.dma_data_p; + priv_p->dma_snd_queue.dma_queue.dma_data_p = NULL; + + MSG( INTERNAL_LOG, minor, "buf = 0x%08x", (unsigned int)dma_buf_p ); + + if ( ( priv_p->dma_snd_queue.dma_queue.dma_status == FMB_DMA_END_WAIT + || priv_p->dma_snd_queue.dma_queue.dma_status == FMB_DMA_END) + && (priv_p->dma_snd_queue.dma_queue.b_num == 0) ) { + priv_p->dma_snd_queue.dma_queue.dma_status = FMB_DMA_END; + MSG( INTERNAL_LOG, minor, "DMA1 status change END_WAIT/END -> END" ); + + MSG( INTERNAL_LOG, minor, "wake up process waiting for DMA completion." ); + wake_up( &priv_p->dma_snd_queue.dma_queue.comp_waitq ); + } + + if (dma_buf_p != NULL) { + Fmb_core_add_free_dma_buf( priv_p, dma_buf_p, &priv_p->dma_snd_queue.dma_queue, NULL ); + } + + Fmb_core_start_dma_snd( priv_p, NULL ); + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->dma_snd_queue.lock, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); + MSG( INTERNAL_LOG, minor, "++++++++++++++++++++++++++++++++++++++++" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief The tasklet for the DMA completion(HOST -> LSI). + * @param[in] arg the pointer to the hw private data + * @return None + * @note None + * @attention None + */ +static void fmb_core_dma_rcv_tasklet( unsigned long data ) +{ + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + struct fmb_dma_buf* dma_buf_p; + unsigned long flags; + int minor; + + hw_priv_p = (struct fmb_hard_private*)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_LOG, minor, "++++++++++++++++++++++++++++++++++++++++" ); + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->dma_rcv_queue.lock, flags ); + + dma_buf_p = priv_p->dma_rcv_queue.dma_queue.dma_data_p; + priv_p->dma_rcv_queue.dma_queue.dma_data_p = NULL; + + MSG( INTERNAL_LOG, minor, "buf = 0x%08x", (unsigned int)dma_buf_p ); + + if (dma_buf_p != NULL) { + dma_buf_p->copy_size = 0; + Fmb_core_add_busy_dma_buf( priv_p, dma_buf_p, &priv_p->dma_rcv_queue.dma_queue, NULL ); + + priv_p->dma_rcv_queue.dma_comp_size += dma_buf_p->trans_size; + + if (priv_p->dma_rcv_queue.dma_comp_size >= FMB_DMA_RCV_BUF_SIZE) { + MSG( INTERNAL_LOG, minor, "wake up process of wait for data transfer."); + wake_up( &priv_p->dma_rcv_queue.comp_waitq ); + } + } + Fmb_core_start_dma_rcv( priv_p, NULL ); + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->dma_rcv_queue.lock, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); + MSG( INTERNAL_LOG, minor, "++++++++++++++++++++++++++++++++++++++++" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** + * @brief Called from the interrupt handler when the interrupt source<br> + * is DMA(HOST->LSI) completion.<br> + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_dma_snd_irq( struct fmb_core_private* priv_p ) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + tasklet_schedule( &priv_p->dma_comp_snd_tasklet ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Called from the interrupt handler when the interrupt source<br> + * is DMA(LSI->HOST) completion.<br> + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_dma_rcv_irq( struct fmb_core_private* priv_p ) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + tasklet_hi_schedule( &priv_p->dma_comp_rcv_tasklet ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/********************************************************/ +/* */ +/* LSI core register processing function */ +/* */ +/********************************************************/ + +/********************************************************/ +/* */ +/* Message buffer processing function */ +/* */ +/********************************************************/ +/** +* @brief increment factor_num +* +* @param None +* @return None +* @note None +* @attension None +*/ +static void fmb_core_inc_factor_num( struct fmb_core_private* priv_p ) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->lock_factor_num, flags ); + + priv_p->factor_num++; + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->lock_factor_num, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief decrement factor_num +* +* @param None +* @return None +* @note None +* @attension None +*/ +static void fmb_core_dec_factor_num( struct fmb_core_private* priv_p ) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->lock_factor_num, flags ); + + priv_p->factor_num--; + if (priv_p->factor_num < 0) { + priv_p->factor_num = 0; + } + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->lock_factor_num, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief subtract factor_num +* +* @param[in] subtract value +* @return None +* @note None +* @attension None +*/ +static void fmb_core_sub_factor_num( struct fmb_core_private* priv_p, int val ) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->lock_factor_num, flags ); + + priv_p->factor_num = priv_p->factor_num - val; + if (priv_p->factor_num < 0) { + priv_p->factor_num = 0; + } + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->lock_factor_num, flags ); + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief set factor_num +* +* @param[in] set value +* @return None +* @note None +* @attension None +*/ +void Fmb_core_set_factor_num( struct fmb_core_private* priv_p, int val ) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->lock_factor_num, flags ); + + priv_p->factor_num = val; + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->lock_factor_num, flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** +* @brief get factor_num +* +* @param None +* @return factor_num +* @note None +* @attension None +*/ +int Fmb_core_get_factor_num( struct fmb_core_private* priv_p ) +{ + unsigned long flags; + int factor_num; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &priv_p->lock_factor_num, flags ); + + factor_num = priv_p->factor_num; + + /* spin unlock */ + spin_unlock_irqrestore( &priv_p->lock_factor_num, flags ); + + return factor_num; + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a busy system message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy system message buffer + * @note None + * @attention None + */ +struct fmb_sys_msg_buf* + Fmb_core_get_busy_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ) +{ + struct fmb_sys_msg_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + }else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + }else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + fmb_core_dec_factor_num( priv_p ); + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy system message buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p, + struct fmb_sys_msg_buf* buf_p ) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + }else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->sys_msg_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free system message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free system message buffer + * @note None + * @attention None + */ +static struct fmb_sys_msg_buf* + fmb_core_get_free_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ) +{ + struct fmb_sys_msg_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of system message buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free system message buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system message buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_msg_sys_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p, + struct fmb_sys_msg_buf* buf_p ) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + }else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free system message buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p, + struct fmb_sys_msg_buf* buf_p ) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_msg_sys_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the system message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_msg_sys_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the system message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + Fmb_core_add_free_msg_sys_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a busy video message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy video message buffer + * @note None + * @attention None + */ +struct fmb_video_msg_buf* + Fmb_core_get_busy_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p ) +{ + struct fmb_video_msg_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + fmb_core_dec_factor_num( priv_p ); + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy video message buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p, + struct fmb_video_msg_buf* buf_p ) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->video_msg_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "START" ); +} + +/** + * @brief Dequeues a free video message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free video message buffer + * @note None + * @attention None + */ +struct fmb_video_msg_buf* + Fmb_core_get_free_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p ) +{ + struct fmb_video_msg_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of video message buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free video message buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video message buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_msg_video_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p, + struct fmb_video_msg_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free video message buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p, + struct fmb_video_msg_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_msg_video_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief Resets the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_msg_video_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + queue_p->msg_buf[i].msg.msg = kmalloc( FMB_VIDEO_MSG_REG_SIZE, GFP_KERNEL ); + if (queue_p->msg_buf[i].msg.msg == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate video message buffer. i = %d", i ); + break; + } + Fmb_core_add_free_msg_video_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + if (i < FMB_MSG_BUF_SIZE) { + for (; i >= 0; --i) { + MSG( DEBUG_LVL, minor, "Release video message buffer. i = %d", i ); + kfree( queue_p->msg_buf[i].msg.msg ); + } + return -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; +} + +/** + * @brief Releases the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* release memorry */ + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + kfree( queue_p->msg_buf[i].msg.msg ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief Dequeues a busy audio message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy audio message buffer + * @note None + * @attention None + */ +struct fmb_audio_msg_buf* + Fmb_core_get_busy_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p) +{ + struct fmb_audio_msg_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + fmb_core_dec_factor_num( priv_p ); + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy audio message buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p, + struct fmb_audio_msg_buf* buf_p) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->audio_msg_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free audio message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free audio message buffer + * @note None + * @attention None + */ +struct fmb_audio_msg_buf* + Fmb_core_get_free_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p) +{ + struct fmb_audio_msg_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of audio message buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free audio message buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio message buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_msg_audio_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p, + struct fmb_audio_msg_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free audio message buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p, + struct fmb_audio_msg_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_msg_audio_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the audio message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_msg_audio_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the audio message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + queue_p->msg_buf[i].msg.msg = kmalloc( FMB_AUDIO_MSG_REG_SIZE, GFP_KERNEL ); + if (queue_p->msg_buf[i].msg.msg == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate audio message buffer. i = %d", i ); + break; + } + Fmb_core_add_free_msg_audio_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + if (i < FMB_MSG_BUF_SIZE) { + for (; i >= 0; --i) { + MSG( DEBUG_LVL, minor, "Release audio message buffer. i = %d", i ); + kfree( queue_p->msg_buf[i].msg.msg ); + } + return -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; +} + +/** + * @brief Releases the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* release memorry */ + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + kfree( queue_p->msg_buf[i].msg.msg ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief Dequeues a busy system command ACK buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy system command ACK buffer + * @note None + * @attention None + */ +struct fmb_cmd_ack_sys_buf* + Fmb_core_get_busy_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p) +{ + struct fmb_cmd_ack_sys_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + fmb_core_dec_factor_num( priv_p ); + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy system command ACK buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command ACK buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p, + struct fmb_cmd_ack_sys_buf* buf_p) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->sys_cmd_ack_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free system command ACK buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free system command ACK buffer + * @note None + * @attention None + */ +struct fmb_cmd_ack_sys_buf* + Fmb_core_get_free_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p) +{ + struct fmb_cmd_ack_sys_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of system command ack buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free system command ACK buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command ACK buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_cmd_ack_sys_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p, + struct fmb_cmd_ack_sys_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free system command ACK buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command ACK buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p, + struct fmb_cmd_ack_sys_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_cmd_ack_sys_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the system command ACK buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_cmd_ack_sys_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the system command ACK buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + Fmb_core_add_free_cmd_ack_sys_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief Dequeues a busy xerror info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy xerror info buffer + * @note None + * @attention None + */ +struct fmb_xerror_info_buf* + Fmb_core_get_busy_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p) +{ + struct fmb_xerror_info_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + fmb_core_dec_factor_num( priv_p ); + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy XERROR info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the XERROR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p, + struct fmb_xerror_info_buf* buf_p) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->xerror_info_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free XERROR info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free XERROR info buffer + * @note None + * @attention None + */ +struct fmb_xerror_info_buf* + Fmb_core_get_free_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p) +{ + struct fmb_xerror_info_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of error info buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free XERROR info buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the XERROR info buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_xerror_info_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p, + struct fmb_xerror_info_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free XERROR info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the XERROR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p, + struct fmb_xerror_info_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_xerror_info_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the XERROR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_xerror_info_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the XERROR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 sucsess + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + queue_p->msg_buf[i].msg.data = kmalloc( FMB_XERROR_INFO_REG_SIZE, GFP_KERNEL ); + if (queue_p->msg_buf[i].msg.data == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate XERROR info buffer. i = %d", i ); + break; + } + Fmb_core_add_free_xerror_info_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + if (i < FMB_MSG_BUF_SIZE) { + for (; i >= 0; --i) { + MSG( DEBUG_LVL, minor, "Release XERROR info buffer. i = %d", i ); + kfree( queue_p->msg_buf[i].msg.data ); + } + return -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; +} + +/** + * @brief Releases the XERROR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* release memorry */ + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + kfree( queue_p->msg_buf[i].msg.data ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a busy VUDATA info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy VUDATA info buffer + * @note None + * @attention None + */ +struct fmb_vudata_info_buf* + Fmb_core_get_busy_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p) +{ + struct fmb_vudata_info_buf* tmp_p = NULL; + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + fmb_core_dec_factor_num( priv_p ); + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy VUDATA info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the VUDATA info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p, + struct fmb_vudata_info_buf* buf_p) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->vudata_info_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free VUDATA info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free VUDATA info buffer + * @note None + * @attention None + */ +struct fmb_vudata_info_buf* + Fmb_core_get_free_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p) +{ + struct fmb_vudata_info_buf* tmp_p = NULL; + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of vudata message buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free VUDATA info buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the VUDATA info buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_vudata_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p, + struct fmb_vudata_info_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free VUDATA info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the VUDATA info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p, + struct fmb_vudata_info_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_vudata_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief Resets the VUDATA info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_vudata_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the VUDATA info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + queue_p->msg_buf[i].msg.data = kmalloc( FMB_VUDATA_INFO_REG_SIZE, GFP_KERNEL ); + if (queue_p->msg_buf[i].msg.data == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate VUDATA info buffer. i = %d", i ); + break; + } + Fmb_core_add_free_vudata_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + if (i < FMB_MSG_BUF_SIZE) { + for (; i >= 0; --i) { + MSG( DEBUG_LVL, minor, "Release VUDATA info buffer. i = %d", i ); + kfree( queue_p->msg_buf[i].msg.data ); + } + return -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; +} + +/** + * @brief Releases the VUDATA info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* release memorry */ + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + kfree( queue_p->msg_buf[i].msg.data ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the busy EDERR info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the EDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p, + struct fmb_ederr_info_buf* buf_p) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->ederr_info_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free EDERR info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free EDERR info buffer + * @note None + * @attention None + */ +struct fmb_ederr_info_buf* + Fmb_core_get_free_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p) +{ + struct fmb_ederr_info_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of error info buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free EDERR info buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the EDERR info buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_ederr_info_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p, + struct fmb_ederr_info_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free EDERR info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the EDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p, + struct fmb_ederr_info_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_ederr_info_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the EDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_ederr_info_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the EDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 sucsess + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + queue_p->msg_buf[i].msg.data = kmalloc( FMB_EDERR_INFO_REG_SIZE, GFP_KERNEL ); + if (queue_p->msg_buf[i].msg.data == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate EDERR info buffer. i = %d", i ); + break; + } + Fmb_core_add_free_ederr_info_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + if (i < FMB_MSG_BUF_SIZE) { + for (; i >= 0; --i) { + MSG( DEBUG_LVL, minor, "Release EDERR info buffer. i = %d", i ); + kfree( queue_p->msg_buf[i].msg.data ); + } + return -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; +} + +/** + * @brief Releases the EDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* release memorry */ + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + kfree( queue_p->msg_buf[i].msg.data ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the busy DDERR info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the DDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p, + struct fmb_dderr_info_buf* buf_p) +{ + unsigned long flags; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } + fmb_core_inc_factor_num( priv_p ); + wake_up( &hw_priv_p->poll_waitq ); + wake_up_interruptible( &priv_p->dderr_info_wait ); +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free DDERR info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free DDERR info buffer + * @note None + * @attention None + */ +struct fmb_dderr_info_buf* + Fmb_core_get_free_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p) +{ + struct fmb_dderr_info_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + fmb_core_dec_factor_num( priv_p ); + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of error info buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free DDERR info buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the DDERR info buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_dderr_info_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p, + struct fmb_dderr_info_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free DDERR info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the DDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p, + struct fmb_dderr_info_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_dderr_info_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the DDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_sub_factor_num( priv_p, queue_p->b_num ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + fmb_core_add_free_dderr_info_buf_no_lock( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the DDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 sucsess + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + queue_p->msg_buf[i].msg.data = kmalloc( FMB_DDERR_INFO_REG_SIZE, GFP_KERNEL ); + if (queue_p->msg_buf[i].msg.data == NULL) { + MSG( KERN_ERR_LVL, minor, "Failed to allocate DDERR info buffer. i = %d", i ); + break; + } + Fmb_core_add_free_dderr_info_buf( priv_p, queue_p, &(queue_p->msg_buf[i]) ); + } + if (i < FMB_MSG_BUF_SIZE) { + for (; i >= 0; --i) { + MSG( DEBUG_LVL, minor, "Release DDERR info buffer. i = %d", i ); + kfree( queue_p->msg_buf[i].msg.data ); + } + return -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; +} + +/** + * @brief Releases the DDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* release memorry */ + for (i = 0; i < FMB_MSG_BUF_SIZE; i++) { + kfree( queue_p->msg_buf[i].msg.data ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/********************************************************/ +/* */ +/* Command buffer processing function */ +/* */ +/********************************************************/ +/** + * @brief Dequeues a busy system command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy system command buffer + * @note None + * @attention None + */ +struct fmb_sys_cmd_buf* + Fmb_core_get_busy_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p) +{ + struct fmb_sys_cmd_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy system command buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p, + struct fmb_sys_cmd_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free system command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free system command buffer + * @note None + * @attention None + */ +struct fmb_sys_cmd_buf* + Fmb_core_get_free_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p) +{ + struct fmb_sys_cmd_buf* tmp_p = NULL; + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of system command buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free system command buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_cmd_sys_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p, + struct fmb_sys_cmd_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free system command buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p, + struct fmb_sys_cmd_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_cmd_sys_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets thesystem command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_CMD_BUF_SIZE; i++) { + fmb_core_add_free_cmd_sys_buf_no_lock( priv_p, queue_p, &(queue_p->cmd_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the system command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_CMD_BUF_SIZE; i++) { + Fmb_core_add_free_cmd_sys_buf( priv_p, queue_p, &(queue_p->cmd_buf[i]) ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Returns the queue head of the busy video command buffer. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the head of the busy queue + * @note None + * @attention None + */ +struct fmb_video_cmd_buf* + Fmb_core_ref_busy_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p) +{ + struct fmb_video_cmd_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->isactive && queue_p->b_head_p != NULL) { + tmp_p = queue_p->b_head_p; + } + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Dequeues a busy video command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy video command buffer + * @note None + * @attention None + */ +struct fmb_video_cmd_buf* + Fmb_core_get_busy_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p) +{ + struct fmb_video_cmd_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy video command buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p, + struct fmb_video_cmd_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free video command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free video command buffer + * @note None + * @attention None + */ +struct fmb_video_cmd_buf* + Fmb_core_get_free_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p) +{ + struct fmb_video_cmd_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of video command buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free video command buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video command buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_cmd_video_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p, + struct fmb_video_cmd_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free video command buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p, + struct fmb_video_cmd_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_cmd_video_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the video command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_CMD_BUF_SIZE; i++) { + fmb_core_add_free_cmd_video_buf_no_lock( priv_p, queue_p, &(queue_p->cmd_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the video command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_CMD_BUF_SIZE; i++) { + Fmb_core_add_free_cmd_video_buf( priv_p, queue_p, &(queue_p->cmd_buf[i]) ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a busy audio command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy audio command buffer + * @note None + * @attention None + */ +struct fmb_audio_cmd_buf* + Fmb_core_get_busy_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p) +{ + struct fmb_audio_cmd_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + if (tmp_p->next_p == NULL) { + /* case of a tail buffer */ + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->b_num = 0; + } + else { + queue_p->b_head_p = tmp_p->next_p; + queue_p->b_num--; + } + tmp_p->next_p = NULL; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the busy audio command buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p, + struct fmb_audio_cmd_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (!queue_p->isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + goto out; + } + + if (queue_p->b_head_p == NULL) { + /* if no busy buffer,add to head of list */ + queue_p->b_head_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num = 1; + wake_up( &queue_p->waitq ); + } + else { + /* add to tail of list */ + queue_p->b_tail_p->next_p = buf_p; + queue_p->b_tail_p = buf_p; + queue_p->b_tail_p->next_p = NULL; + queue_p->b_num++; + } +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Dequeues a free audio command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free audio command buffer + * @note None + * @attention None + */ +struct fmb_audio_cmd_buf* + Fmb_core_get_free_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p) +{ + struct fmb_audio_cmd_buf* tmp_p; + unsigned long flags; + int minor; + + tmp_p = NULL; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,use a head buffer */ + if (queue_p->b_head_p == NULL) { + MSG( DEBUG_LVL, minor, "No data." ); + goto out; + } + else { + tmp_p = queue_p->b_head_p; + queue_p->b_head_p = tmp_p->next_p; + if (tmp_p == queue_p->b_tail_p) { + queue_p->b_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->b_num--; + /* ToDo : The message level is reviewed later. */ + MSG( DEBUG_LVL, minor, "Overflow of audio command buffer" ); + goto out; + } + } + else { + tmp_p = queue_p->f_head_p; + queue_p->f_head_p = queue_p->f_head_p->next_p; + if (tmp_p == queue_p->f_tail_p) { + queue_p->f_tail_p = NULL; + } + tmp_p->next_p = NULL; + queue_p->f_num--; + } + +out: + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return tmp_p; +} + +/** + * @brief Enqueues the free audio command buffer to <br> + * the buffer queue(without spin lock). + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio command buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_free_cmd_audio_buf_no_lock( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p, + struct fmb_audio_cmd_buf* buf_p) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + if (queue_p->f_head_p == NULL) { + /* if no empty buffer,add to head of list */ + queue_p->f_head_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + else { + /* add to tail of list */ + queue_p->f_tail_p->next_p = buf_p; + queue_p->f_tail_p = buf_p; + queue_p->f_tail_p->next_p = NULL; + } + queue_p->f_num++; + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Enqueues the free audio command buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p, + struct fmb_audio_cmd_buf* buf_p) +{ + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + fmb_core_add_free_cmd_audio_buf_no_lock( priv_p, queue_p, buf_p ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Resets the audio command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p) +{ + unsigned long flags; + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* spin lock */ + spin_lock_irqsave( &(queue_p->lock), flags ); + + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_CMD_BUF_SIZE; i++) { + fmb_core_add_free_cmd_audio_buf_no_lock( priv_p, queue_p, &(queue_p->cmd_buf[i]) ); + } + wake_up( &queue_p->waitq ); + + /* spin unlock */ + spin_unlock_irqrestore( &(queue_p->lock), flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** + * @brief Initializes the audio command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* init spin lock */ + spin_lock_init( &queue_p->lock ); + + init_waitqueue_head( &queue_p->waitq ); + queue_p->isactive = 0; + queue_p->b_num = 0; + queue_p->f_num = 0; + queue_p->b_head_p = NULL; + queue_p->b_tail_p = NULL; + queue_p->f_head_p = NULL; + queue_p->f_tail_p = NULL; + + for (i = 0; i < FMB_CMD_BUF_SIZE; i++) { + Fmb_core_add_free_cmd_audio_buf( priv_p, queue_p, &(queue_p->cmd_buf[i]) ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/********************************************************/ +/* */ +/* LSI core dependence systemcall API function */ +/* */ +/********************************************************/ +/** +* ioctl() API internal function +*/ +/** + * @brief Returns the notification kind for received ASYNC notification. + * @param[in] priv_p the pointer to the core private data + * @return factor notification kind.<br> + * The lower 6bits each represents presence(1)/<br> + * absence(0) of particular notification:<br> + * - bit0 : system command ack message<br> + * - bit1 : system message<br> + * - bit2 : video message<br> + * - bit3 : audio message<br> + * - bit4 : xerror message<br> + * - bit5 : vudata message<br> + * @note None + * @attention None + */ +int Fmb_core_get_factor_check( struct fmb_core_private* priv_p ) +{ + int factor = FMB_FACTOR_NONE; + unsigned long flags; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /** check system message buffer active */ + spin_lock_irqsave( &priv_p->msg_sys_queue.lock, flags ); + if (priv_p->msg_sys_queue.isactive != 0 && priv_p->msg_sys_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The system message buffer active." ); + factor |= FMB_FACTOR_MSG_SYS; + } + spin_unlock_irqrestore( &priv_p->msg_sys_queue.lock, flags ); + + /** check video message buffer active */ + spin_lock_irqsave( &priv_p->msg_video_queue.lock, flags ); + if (priv_p->msg_video_queue.isactive != 0 && priv_p->msg_video_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The video message buffer active." ); + factor |= FMB_FACTOR_MSG_VIDEO; + } + spin_unlock_irqrestore( &priv_p->msg_video_queue.lock, flags ); + + /** check audio message buffer active */ + spin_lock_irqsave( &priv_p->msg_audio_queue.lock, flags ); + if (priv_p->msg_audio_queue.isactive != 0 && priv_p->msg_audio_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The audio message buffer active." ); + factor |= FMB_FACTOR_MSG_AUDIO; + } + spin_unlock_irqrestore( &priv_p->msg_audio_queue.lock, flags ); + + /** check system command ACK buffer active */ + spin_lock_irqsave( &priv_p->cmd_cack_sys_queue.lock, flags ); + if (priv_p->cmd_cack_sys_queue.isactive != 0 && priv_p->cmd_cack_sys_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The system command ACK buffer active." ); + factor |= FMB_FACTOR_CACK_SYS; + } + spin_unlock_irqrestore( &priv_p->cmd_cack_sys_queue.lock, flags ); + + /** check xerror info buffer active */ + spin_lock_irqsave( &priv_p->xerror_info_queue.lock, flags ); + if (priv_p->xerror_info_queue.isactive != 0 && priv_p->xerror_info_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The xerror info buffer active." ); + factor |= FMB_FACTOR_XERROR; + } + spin_unlock_irqrestore( &priv_p->xerror_info_queue.lock, flags ); + + /** check vudata info buffer active */ + spin_lock_irqsave( &priv_p->vudata_info_queue.lock, flags ); + if (priv_p->vudata_info_queue.isactive != 0 && priv_p->vudata_info_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The VUDATA info buffer active." ); + factor |= FMB_FACTOR_VUDATA; + } + spin_unlock_irqrestore( &priv_p->vudata_info_queue.lock, flags ); + + /** check ederr info buffer active */ + spin_lock_irqsave( &priv_p->ederr_info_queue.lock, flags ); + if (priv_p->ederr_info_queue.isactive != 0 && priv_p->ederr_info_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The EDERR info buffer active." ); + factor |= FMB_FACTOR_EDERR; + } + spin_unlock_irqrestore( &priv_p->ederr_info_queue.lock, flags ); + + /** check dderr info buffer active */ + spin_lock_irqsave( &priv_p->dderr_info_queue.lock, flags ); + if (priv_p->dderr_info_queue.isactive != 0 && priv_p->dderr_info_queue.b_num != 0) { + MSG( DEBUG_LVL, minor, "The DDERR info buffer active." ); + factor |= FMB_FACTOR_DDERR; + } + spin_unlock_irqrestore( &priv_p->dderr_info_queue.lock, flags ); + + MSG( INTERNAL_FUNC, minor, "END" ); + return factor; +} + +/** + * @brief Resets the private data. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_private_data_reset( struct fmb_core_private* priv_p ) +{ + int i; + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + priv_p->sys_cmd_ack_rcv_flag = FMB_SYS_CMD_ACK_NONE; + priv_p->sys_cmd_send_flag = FMB_SYS_CMD_SEND_NONE; + priv_p->system_status = FMB_ADD_PRAM_M_MODE_IDLE; + priv_p->encode_mode = FMB_DATA_ENCODE_TOP; + priv_p->notify_mode = FMB_DATA_NOTIFY_NONE; + priv_p->factor_num = 0; + priv_p->factor_irq = FMB_FACTOR_NONE; + priv_p->read_dma_flg = FMB_DATA_DMAFLAG_ON; + priv_p->write_dma_flg = FMB_DATA_DMAFLAG_ON; + priv_p->irqst_clear_flg = FMB_DATA_IRQSTFLAG_ON; + priv_p->vsync_mode = FMB_DATA_VSYNC_ALL; + + + for (i = 0; i < (FMB_SYS_MSG_REG_SIZE / sizeof(unsigned short) ); i++) { + priv_p->check_msg_sys_info_p[i] = 0; + } + + for (i = 0; i < (FMB_VIDEO_MSG_REG_SIZE / sizeof(unsigned short) ); i++) { + priv_p->check_msg_video_info_p[i] = 0; + } + priv_p->check_msg_video_info_p[1] = 0xffff; /* MODE */ + priv_p->check_msg_video_info_p[41] = 0xffff; /* SUBMODE */ + + for (i = 0; i < (FMB_AUDIO_MSG_REG_SIZE / sizeof(unsigned short) ); i++) { + priv_p->check_msg_audio_info_p[i] = 0; + } + + for (i = 0; i < (FMB_VUDATA_INFO_REG_SIZE / sizeof(unsigned short) ); i++) { + priv_p->check_vudata_info_p[i] = 0; + } + + /* Release message buffer */ + Fmb_core_reset_cmd_ack_sys_buf(priv_p, &priv_p->cmd_cack_sys_queue); + Fmb_core_reset_msg_sys_buf(priv_p, &priv_p->msg_sys_queue); + Fmb_core_reset_msg_video_buf(priv_p, &priv_p->msg_video_queue); + Fmb_core_reset_msg_audio_buf(priv_p, &priv_p->msg_audio_queue); + Fmb_core_reset_xerror_info_buf(priv_p, &priv_p->xerror_info_queue); + Fmb_core_reset_vudata_buf(priv_p, &priv_p->vudata_info_queue); + Fmb_core_reset_ederr_info_buf(priv_p, &priv_p->ederr_info_queue); + Fmb_core_reset_dderr_info_buf(priv_p, &priv_p->dderr_info_queue); + Fmb_core_reset_cmd_sys_buf(priv_p, &priv_p->cmd_sys_queue); + Fmb_core_reset_cmd_video_buf(priv_p, &priv_p->cmd_video_queue); + Fmb_core_reset_cmd_audio_buf(priv_p, &priv_p->cmd_audio_queue); + /* Release DMA buffer */ + Fmb_core_reset_dma_queue_rcv( priv_p, NULL ); + Fmb_core_reset_dma_queue_snd( priv_p, NULL ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/********************************************************/ +/* */ +/* LSI core dependence Interrupt process function */ +/* */ +/********************************************************/ +/** +* @brief Received Message difference check + * @param[in] priv_p the pointer to the core private data +* @param[in] type message type +* @param[in] base_addr base address +* @return TURE/FALSE +* @note None +* @attention None +*/ +static int fmb_core_check_rcv_msg_diff( struct fmb_core_private* priv_p, + int type, + unsigned long base_addr) +{ + int i, size; + unsigned short* check_msg_info; + struct fmb_hard_private* hw_priv_p; + int minor; + unsigned short seq_end_prev; + unsigned short seq_end_cur; + unsigned short frm_upd_flg_prev; + unsigned short frm_upd_flg_cur; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + switch (type){ + case FMB_DATA_NOTIFY_SYS: + size = FMB_SYS_MSG_REG_SIZE; + check_msg_info = priv_p->check_msg_sys_info_p; + break; + case FMB_DATA_NOTIFY_VIDEO: + size = FMB_VIDEO_MSG_REG_SIZE; + check_msg_info = priv_p->check_msg_video_info_p; + break; + case FMB_DATA_NOTIFY_AUDIO: + size = FMB_AUDIO_MSG_REG_SIZE; + check_msg_info = priv_p->check_msg_audio_info_p; + break; + case FMB_DATA_NOTIFY_VUDATA: + size = FMB_VUDATA_INFO_REG_SIZE; + check_msg_info = priv_p->check_vudata_info_p; + break; + default: + MSG( DEBUG_LVL, minor, "Invalid type." ); + MSG( INTERNAL_LOG, minor, "END" ); + return -1; + } + + if (priv_p->notify_mode & type) { + if (type == FMB_DATA_NOTIFY_SYS) { + if (check_msg_info[2] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x04) || + /** check MSG_ID & SUB_MSG_ID */ + check_msg_info[3] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x06)) + /** check BODDY_00 */ + { + MSG( INTERNAL_LOG, minor, "END(system message buffer)" ); + return -1; + } + } else if (type == FMB_DATA_NOTIFY_VIDEO) { + if (check_msg_info[1] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x02) || + /** check CMD_INVALID & MODE */ + check_msg_info[41] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x52)) + /** check SUB_MODE */ + { + MSG( INTERNAL_LOG, minor, "END(video message buffer)" ); + return -1; + } + seq_end_prev = check_msg_info[2]; + seq_end_prev = seq_end_prev >> FMB_VIDEO_MSG_A_SEQ_END_SHIFT; + seq_end_prev = seq_end_prev & FMB_VIDEO_MSG_A_SEQ_END_MASK; + + seq_end_cur = Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x04); + seq_end_cur = seq_end_cur >> FMB_VIDEO_MSG_A_SEQ_END_SHIFT; + seq_end_cur = seq_end_cur & FMB_VIDEO_MSG_A_SEQ_END_MASK; + + if ( (seq_end_prev == 0) && (seq_end_cur == 1) ) + { + MSG( INTERNAL_LOG, minor, "END(video message buffer(SEQ_END: 0-->1))" ); + return -1; + } + + frm_upd_flg_prev = check_msg_info[3]; + frm_upd_flg_prev = frm_upd_flg_prev >> FMB_VIDEO_MSG_A_FRAME_UPDATE_FLAG_SHIFT; + frm_upd_flg_prev = frm_upd_flg_prev & FMB_VIDEO_MSG_A_FRAME_UPDATE_FLAG_MASK; + + frm_upd_flg_cur = Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x06); + frm_upd_flg_cur = frm_upd_flg_cur >> FMB_VIDEO_MSG_A_FRAME_UPDATE_FLAG_SHIFT; + frm_upd_flg_cur = frm_upd_flg_cur & FMB_VIDEO_MSG_A_FRAME_UPDATE_FLAG_MASK; + + if ( (frm_upd_flg_prev == 0) && (frm_upd_flg_cur == 1) ) + { + MSG( INTERNAL_LOG, minor, "END(video message buffer(FRAME_UPDATA_FLAG: 0-->1))" ); + return -1; + } + } else if (type == FMB_DATA_NOTIFY_AUDIO) { + if (check_msg_info[2] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x04) || + /** check A_MUTE_ST & A_MUTE */ + (check_msg_info[3] & 0x03) != + ( Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + 0x6) & 0x03) ) + /** check AV_SYNC */ + { + MSG( INTERNAL_LOG, minor, "END(audio message buffer)" ); + return -1; + } + } + else { + for (i = 0; i < (size / sizeof(unsigned short) ); i++) { + if (check_msg_info[i] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + + (i * sizeof(unsigned short)))) + { + MSG( INTERNAL_LOG, minor, "END(VUDATA info buffer)" ); + return -1; + } + } + } + + } + else { + for (i = 0; i < (size / sizeof(unsigned short) ); i++) { + if (check_msg_info[i] != Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + + (i * sizeof(unsigned short)))) + { + MSG( INTERNAL_LOG, minor, "END(i = %d)", i ); + return -1; + } + } + } + + MSG( INTERNAL_LOG, minor, "END(no difference)" ); + return 0; +} + +/** +* @brief VSYNC Interruption receive VUDATA message check +* @param[in] priv_p the pointer to the core private data +* @param[in] ab_sel A/B selector +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_vudata_msg( struct fmb_core_private* priv_p, + unsigned short ab_sel) +{ + int i; + unsigned long flags; + unsigned long base_addr; + unsigned short vudata_length; + struct fmb_vudata_info_buf* vudata_info_buf_p; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + /** check VUDATA Message buffer active */ + spin_lock_irqsave( &priv_p->vudata_info_queue.lock, flags ); + if (!priv_p->vudata_info_queue.isactive) { + MSG( DEBUG_LVL, minor, "received VUDATA info : Buffer isn't active." ); + spin_unlock_irqrestore( &priv_p->vudata_info_queue.lock, flags ); + return; + } + spin_unlock_irqrestore( &priv_p->vudata_info_queue.lock, flags ); + + if (ab_sel) { + /* A-respect Access */ + base_addr = FMB_VUDATA_INFO_A_BASE; + vudata_length = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_A_VUDATA_LENGTH ); + } + else { + /* B-respect Access */ + base_addr = FMB_VUDATA_INFO_B_BASE; + vudata_length = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_B_VUDATA_LENGTH ); + } + + if (vudata_length != 0) { + if (fmb_core_check_rcv_msg_diff( priv_p, FMB_DATA_NOTIFY_VUDATA, base_addr ) == 0) { + MSG( DEBUG_LVL, minor, "received VUDATA info : no difference" ); + return; + } + + /* Save Received VUDATA Message */ + vudata_info_buf_p = Fmb_core_get_free_vudata_buf( priv_p, &priv_p->vudata_info_queue ); + if (vudata_info_buf_p != NULL) { + for (i = 0; i < (FMB_VUDATA_INFO_REG_SIZE / sizeof(unsigned short) ); i++) { + vudata_info_buf_p->msg.data[i] = Fmb_hw_reg_read_lsi( hw_priv_p, base_addr + + (i * sizeof(unsigned short)) ); + priv_p->check_vudata_info_p[i] = vudata_info_buf_p->msg.data[i]; + } + Fmb_core_add_busy_vudata_buf( + priv_p, &priv_p->vudata_info_queue , vudata_info_buf_p ); + } + } + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief Received Message error check +* @param[in] priv_p the pointer to the core private data +* @param[in] ab_sel A/B selector +* @return none +* @note None +* @attention None +*/ +static void fmb_core_check_rcv_msg_err( struct fmb_core_private* priv_p, + unsigned short ab_sel) +{ + unsigned short v_cmd_invalid; + unsigned short v_mode; + unsigned short v_error_level_h; + unsigned short v_error_level_l; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + if (ab_sel) { /* A-respect Access */ + v_cmd_invalid = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_A_CMD_INVALID ); + v_mode = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_A_MODE ); + v_error_level_h = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_A_ERROR_LEVEL_H ); + v_error_level_l = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_A_ERROR_LEVEL_L ); + } + else { /* B-respect Access */ + v_cmd_invalid = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_B_CMD_INVALID ); + v_mode = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_B_MODE ); + v_error_level_h = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_B_ERROR_LEVEL_H ); + v_error_level_l = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_B_ERROR_LEVEL_L ); + } + + /** check CMD INVALID */ + if (v_cmd_invalid != 0) { + MSG( LSI_ERR_LVL, minor, "Error : Video Message = CMD_INVALID" ); + + } + /** check MODE ERROR */ + if (v_mode == 0xF0) { + MSG( LSI_ERR_LVL, minor, "Error : Video Message = MODE ERROR" ); + } + /** check DECODE ERROR */ + if ((v_error_level_h != 0) || (v_error_level_l != 0)) { + MSG( LSI_ERR_LVL, minor, "Error : Video Message = DECODE ERROR" ); + MSG( LSI_ERR_LVL, minor, "ERROR : %04x%04x",v_error_level_h,v_error_level_l ); + } + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief VSYNC Interruption receive Video message check +* @param[in] priv_p the pointer to the core private data +* @param[in] ab_sel A/B selector +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_video_msg( struct fmb_core_private* priv_p, + unsigned short ab_sel) +{ + int i; + unsigned short v_valid; + unsigned long v_base_addr; + struct fmb_video_msg_buf* video_msg_buf_p; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + if (ab_sel) { + /* A-respect Access */ + v_base_addr = FMB_VIDEO_MSG_A_BASE; + v_valid = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_A_VALID ); + } + else { + /* B-respect Access */ + v_base_addr = FMB_VIDEO_MSG_B_BASE; + v_valid = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_VIDEO_MSG_B_VALID ); + } + + if (v_valid) { + if (fmb_core_check_rcv_msg_diff( priv_p, FMB_DATA_NOTIFY_VIDEO, v_base_addr ) + == 0) + { + MSG( DEBUG_LVL, minor, "received Video Message : no difference" ); + return; + } + + /** Received Message error Check */ + fmb_core_check_rcv_msg_err( priv_p, ab_sel ); + + /* Save Received Video Message */ + video_msg_buf_p = + Fmb_core_get_free_msg_video_buf( priv_p, &priv_p->msg_video_queue ); + + if (video_msg_buf_p != NULL) { + for (i = 0; i < (FMB_VIDEO_MSG_REG_SIZE / sizeof(unsigned short) ); i++) { + video_msg_buf_p->msg.msg[i] = + Fmb_hw_reg_read_lsi( hw_priv_p, + v_base_addr + (i * sizeof(unsigned short)) ); + priv_p->check_msg_video_info_p[i] = video_msg_buf_p->msg.msg[i]; + } + Fmb_core_add_busy_msg_video_buf( + priv_p, &priv_p->msg_video_queue , video_msg_buf_p ); + } + } + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief VSYNC Interruption receive Audio message check +* @param[in] priv_p the pointer to the core private data +* @param[in] ab_sel A/B selector +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_audio_msg( struct fmb_core_private* priv_p, + unsigned short ab_sel) +{ + int i; + unsigned short a_valid; + unsigned long a_base_addr; + struct fmb_audio_msg_buf* audio_msg_buf_p; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + if (ab_sel) { + /* A-respect Access */ + a_base_addr = FMB_AUDIO_MSG_A_BASE; + a_valid = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_AUDIO_MSG_A_VALID ); + } + else { + /* B-respect Access */ + a_base_addr = FMB_AUDIO_MSG_B_BASE; + a_valid = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_AUDIO_MSG_B_VALID ); + } + + if (a_valid) { + if (fmb_core_check_rcv_msg_diff( priv_p, FMB_DATA_NOTIFY_AUDIO, a_base_addr) + == 0) + { + MSG( DEBUG_LVL, minor, "received Audio Message : no difference" ); + return; + } + + /* Save Received Video Message */ + audio_msg_buf_p = Fmb_core_get_free_msg_audio_buf( priv_p, &priv_p->msg_audio_queue ); + + if (audio_msg_buf_p != NULL) { + for (i = 0; i < (FMB_AUDIO_MSG_REG_SIZE / sizeof(unsigned short) ); i++) { + audio_msg_buf_p->msg.msg[i] = + Fmb_hw_reg_read_lsi( hw_priv_p, + a_base_addr + (i * sizeof(unsigned short)) ); + priv_p->check_msg_audio_info_p[i] = audio_msg_buf_p->msg.msg[i]; + } + Fmb_core_add_busy_msg_audio_buf( + priv_p, &priv_p->msg_audio_queue, audio_msg_buf_p ); + } + } + MSG( INTERNAL_LOG, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief VSYNC Interruption receive message check +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_vsync_msg( struct fmb_core_private* priv_p ) +{ + unsigned short ab_sel; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_LOG, minor, "START" ); + + ab_sel = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_ADD_PRAM_V_AB_SEL ); + + /* check VUDATA message */ + fmb_core_check_vudata_msg( priv_p, ab_sel ); + + /* check video message */ + MSG(VIDEOMSG_LVL, minor, "Received Video Message"); + fmb_core_check_video_msg( priv_p, ab_sel ); + + /* check audio message */ + MSG(AUDIOMSG_LVL, minor, "Received Audio Message"); + fmb_core_check_audio_msg( priv_p, ab_sel ); + + MSG( INTERNAL_LOG, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief Next VSYNC opposite side command set +* @param[in] priv_p the pointer to the core private data +* @param[in] type command type +* @param[in] base_addr base address +* @return None +* @note None +* @attention None +*/ +static void fmb_core_opposite_cmd_set( struct fmb_core_private* priv_p, + int type, + unsigned long base_addr) +{ + int i, size; + unsigned short* check_cmd_info; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_LOG, minor, "START" ); + + if (type == FMB_CMD_TYPE_VIDEO) { + size = FMB_CMD_VIDEO_INFO_SIZE / sizeof(unsigned short); + check_cmd_info = priv_p->sync_cmd_video_info_p; + } + else { + size = FMB_CMD_AUDIO_INFO_SIZE / sizeof(unsigned short); + check_cmd_info = priv_p->sync_cmd_audio_info_p; + } + + if (check_cmd_info[0] == FMB_CMD_VIDEO_VAILID_ON) { + /** clear sync command info valid */ + check_cmd_info[0] = FMB_CMD_VIDEO_VAILID_OFF; + for (i = 0; i < size ; i++) { + Fmb_hw_reg_write_lsi( hw_priv_p, base_addr + (i * 2), check_cmd_info[i] ); + check_cmd_info[i] = 0; + } + } + + MSG( INTERNAL_LOG, minor, "END" ); +} + +/** +* @brief VSYNC Interruption send Video command check +* @param[in] priv_p the pointer to the core private data +* @param[in] base_addr base address +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_video_cmd( struct fmb_core_private* priv_p, + unsigned long base_addr) +{ + unsigned short i; + unsigned long flags; + unsigned short field; + struct fmb_video_cmd_buf* video_cmd_buf_p; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_LOG, minor, "START" ); + + /** check video command buffer active */ + spin_lock_irqsave( &priv_p->cmd_video_queue.lock, flags ); + if (!priv_p->cmd_video_queue.isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + spin_unlock_irqrestore( &priv_p->cmd_video_queue.lock, flags ); + return; + } + spin_unlock_irqrestore( &priv_p->cmd_video_queue.lock, flags ); + + + /** Encode field mode check */ + if (priv_p->system_status == FMB_ADD_PRAM_M_MODE_ENCODE) { + video_cmd_buf_p = Fmb_core_ref_busy_cmd_video_buf( priv_p, + &priv_p->cmd_video_queue ); + + if (video_cmd_buf_p != NULL) { + if ( ((video_cmd_buf_p->cmd.reg[1] & FMB_VIDEO_MSG_A_MODE_MASK) + == FMB_CMD_VIDEO_ENCODE_START ) + || ((video_cmd_buf_p->cmd.reg[1] & FMB_VIDEO_MSG_A_MODE_MASK) + == FMB_CMD_VIDEO_ENCODE_NULL ) ) + { + //read register + field = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_ADD_PRAM_V_FIELD ); + if (priv_p->vsync_mode == FMB_DATA_VSYNC_ALL) { + if (priv_p->encode_mode != field) { + MSG( DEBUG_LVL, minor, + "Video Command Send : Command will be sent at next VSYNC" ); + return; + } + } + } + } + } + + /** get video command buffer */ + video_cmd_buf_p = Fmb_core_get_busy_cmd_video_buf( priv_p, + &priv_p->cmd_video_queue ); + + if (video_cmd_buf_p == NULL) { + /** Setting on opposite side */ + fmb_core_opposite_cmd_set( priv_p, FMB_CMD_TYPE_VIDEO, base_addr ); + + MSG( INTERNAL_LOG, minor, "END" ); + return; + } + + for (i = 0; i < FMB_CMD_VIDEO_INFO_SIZE / sizeof(unsigned short) ; i++) { + Fmb_hw_reg_write_lsi( hw_priv_p, + base_addr + (i * 2), video_cmd_buf_p->cmd.reg[i] ); + + /** save request Video Command info*/ + priv_p->sync_cmd_video_info_p[i] = video_cmd_buf_p->cmd.reg[i]; + } + /** set valid flag */ + Fmb_hw_reg_write_lsi( hw_priv_p, base_addr, FMB_CMD_VIDEO_VAILID_ON ); + /** set sync command info valid*/ + priv_p->sync_cmd_video_info_p[0] = FMB_CMD_VIDEO_VAILID_ON; + + Fmb_core_add_free_cmd_video_buf( + priv_p, &priv_p->cmd_video_queue, video_cmd_buf_p ); + MSG(VIDEOMSG_LVL, minor, "Video Command Send"); + MSG( INTERNAL_LOG, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief VSYNC Interruption send Audio command check +* @param[in] priv_p the pointer to the core private data +* @param[in] base_addr bese address +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_audio_cmd( struct fmb_core_private* priv_p, + unsigned long base_addr) +{ + unsigned short i; + unsigned long flags; + struct fmb_audio_cmd_buf* audio_cmd_buf_p; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_LOG, minor, "START" ); + + /** check audio command buffer active */ + spin_lock_irqsave( &priv_p->cmd_audio_queue.lock, flags ); + if (!priv_p->cmd_audio_queue.isactive) { + MSG( DEBUG_LVL, minor, "Buffer isn't active." ); + spin_unlock_irqrestore( &priv_p->cmd_audio_queue.lock, flags ); + return; + } + spin_unlock_irqrestore( &priv_p->cmd_audio_queue.lock, flags ); + + /** get audio command buffer */ + audio_cmd_buf_p = Fmb_core_get_busy_cmd_audio_buf( priv_p, + &priv_p->cmd_audio_queue ); + if(audio_cmd_buf_p == NULL) { + /** Setting on opposite side */ + fmb_core_opposite_cmd_set( priv_p, FMB_CMD_TYPE_AUDIO, base_addr ); + MSG( INTERNAL_LOG, minor, "END" ); + return; + } + + for (i = 0; i < FMB_CMD_AUDIO_INFO_SIZE / sizeof(unsigned short); i++) { + Fmb_hw_reg_write_lsi( hw_priv_p, + base_addr + (i * 2), audio_cmd_buf_p->cmd.reg[i] ); + + /** save request Audio Command info*/ + priv_p->sync_cmd_audio_info_p[i] = audio_cmd_buf_p->cmd.reg[i]; + } + /** set valid flag */ + Fmb_hw_reg_write_lsi( hw_priv_p, base_addr, FMB_CMD_AUDIO_VAILID_ON ); + /** set sync command info valid*/ + priv_p->sync_cmd_audio_info_p[0] = FMB_CMD_AUDIO_VAILID_ON; + + Fmb_core_add_free_cmd_audio_buf( + priv_p, &priv_p->cmd_audio_queue, audio_cmd_buf_p ); + MSG(AUDIOMSG_LVL, minor, "Audio Command Send"); + MSG( INTERNAL_LOG, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief VSYNC Interruption send command check +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_check_vsync_cmd( struct fmb_core_private* priv_p ) +{ + unsigned short ab_sel; + unsigned long v_base_addr; + unsigned long a_base_addr; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_LOG, minor, "START" ); + + ab_sel = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_ADD_PRAM_V_AB_SEL ); + + if (ab_sel == FMB_ADD_PRAM_V_AB_SEL_A) { + /* A-respect Access */ + v_base_addr = FMB_VIDEO_CMD_A_BASE; + a_base_addr = FMB_AUDIO_CMD_A_BASE; + } + else { + /* B-respect Access */ + v_base_addr = FMB_VIDEO_CMD_B_BASE; + a_base_addr = FMB_AUDIO_CMD_B_BASE; + } + + /* check Video Command */ + fmb_core_check_video_cmd( priv_p, v_base_addr ); + + /* check Audio Command */ + fmb_core_check_audio_cmd( priv_p, a_base_addr ); + + MSG( INTERNAL_LOG, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief MB86 Codec XERROR tasklet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_xerror_tasklet( unsigned long data ) +{ + int i; + struct fmb_xerror_info_buf* xerror_info_p; + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_INT ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_XERROR ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_EDERR ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_DDERR ); + + MSG( LSI_ERR_LVL, minor, "Error : MB86 LSI XERROR" ); + MSG( LSI_ERR_LVL, minor, "800050 :%04x%04x %04x%04x %04x%04x %04x%04x", + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_M_H), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_M_L), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_V_H), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_V_L), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_A_H), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_A_L), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_RESERVED0), + Fmb_hw_reg_read_lsi( hw_priv_p, FMB_ERROR_INFO_RESERVED1) ); + + xerror_info_p = Fmb_core_get_free_xerror_info_buf( + priv_p, &priv_p->xerror_info_queue ); + if (xerror_info_p != NULL) { + for (i = 0; i < (FMB_XERROR_INFO_REG_SIZE / sizeof(unsigned short) ); i++) { + xerror_info_p->msg.data[i] = + Fmb_hw_reg_read_lsi( + hw_priv_p, FMB_ERROR_INFO_BASE + (i * sizeof(unsigned short)) ); + } + Fmb_core_add_busy_xerror_info_buf( + priv_p, &priv_p->xerror_info_queue , xerror_info_p ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief MB86 Codec EDERR tasklet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_ederr_tasklet( unsigned long data ) +{ + struct fmb_ederr_info_buf* ederr_info_p; + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_INT ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_XERROR ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_EDERR ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_DDERR ); + + MSG( LSI_ERR_LVL, minor, "Error : MB86 LSI EDERR" ); + + ederr_info_p = Fmb_core_get_free_ederr_info_buf( + priv_p, &priv_p->ederr_info_queue ); + if (ederr_info_p != NULL) { + Fmb_core_add_busy_ederr_info_buf( + priv_p, &priv_p->ederr_info_queue , ederr_info_p ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief MB86 Codec EDERR tasklet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_dderr_tasklet( unsigned long data ) +{ + struct fmb_dderr_info_buf* dderr_info_p; + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_INT ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_XERROR ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_EDERR ); + Fmb_hw_disable_irq( hw_priv_p, IRQ_FMB_DDERR ); + + MSG( LSI_ERR_LVL, minor, "Error : MB86 LSI DDERR" ); + + dderr_info_p = Fmb_core_get_free_dderr_info_buf( + priv_p, &priv_p->dderr_info_queue ); + if (dderr_info_p != NULL) { + Fmb_core_add_busy_dderr_info_buf( + priv_p, &priv_p->dderr_info_queue , dderr_info_p ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief MB86 Codec TCPU interrupt tasklet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_tcpu_tasklet( unsigned long data ) +{ + int i; + unsigned short tmp; + struct fmb_sys_msg_buf* sys_msg_buf_p; + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + if (fmb_core_check_rcv_msg_diff( priv_p, + FMB_DATA_NOTIFY_SYS, FMB_SYS_MSG_BASE) == 0) { + MSG(DEBUG_LVL, minor, "received System Message : no difference"); + } + else { + /* Save Received system Message */ + sys_msg_buf_p = + fmb_core_get_free_msg_sys_buf( priv_p, &priv_p->msg_sys_queue ); + + if (sys_msg_buf_p != NULL) { + /* message ID */ + sys_msg_buf_p->msg.id = + FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_MSG_MSG_ID ); + + /* sub message ID */ + sys_msg_buf_p->msg.sub_id = + FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_MSG_SUB_MSG_ID ); + + /* body_00 info */ + sys_msg_buf_p->msg.body = + FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_MSG_BODY_00 ); + + Fmb_core_add_busy_msg_sys_buf( + priv_p, &priv_p->msg_sys_queue , sys_msg_buf_p ); + + for (i = 0; i < (FMB_SYS_MSG_REG_SIZE / sizeof(unsigned short) ); i++) { + priv_p->check_msg_sys_info_p[i] = + Fmb_hw_reg_read_lsi( + hw_priv_p, FMB_SYS_MSG_BASE + (i * sizeof(unsigned short)) ); + } + } + } + + /* send system message ACK */ + FMB_LSI_REG_FIELD_WRITE( hw_priv_p, FMB_SYS_MSG_ACK_DESTINATION_ID, + FMB_SYS_MSG_ACK_DESTINATION_ID_SET ); + + tmp = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_MSG_CONTINUITY_COUNTER ); + FMB_LSI_REG_FIELD_WRITE( hw_priv_p, FMB_SYS_MSG_ACK_CONTINUITY_COUNTER, tmp ); + + tmp = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_MSG_MSG_ID ); + FMB_LSI_REG_FIELD_WRITE( hw_priv_p, FMB_SYS_MSG_ACK_MACK_ID, tmp ); + + FMB_LSI_REG_FIELD_WRITE( + hw_priv_p, FMB_API_SETIRQ_TACK, FMB_API_SETIRQ_TACK_SET ); + MSG(SYSMSG_LVL, minor, "send system message ACK"); + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + + +/** +* @brief MB86 Codec TACK interrupt TaskLet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_tack_tasklet( unsigned long data ) +{ + unsigned short cack_id, sub_cack_id; + struct fmb_cmd_ack_sys_buf* cmd_ack_sys_buf_p; + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + cack_id = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_CMD_ACK_CACK_ID ); + sub_cack_id = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_SYS_CMD_ACK_SUB_CACK_ID ); + + /** set sysytem status */ + priv_p->system_status = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_ADD_PRAM_M_MODE ); + + if (priv_p->sys_cmd_send_flag == FMB_SYS_CMD_SEND_ASYNC) { + cmd_ack_sys_buf_p = Fmb_core_get_free_cmd_ack_sys_buf( + priv_p, &priv_p->cmd_cack_sys_queue ); + + if (cmd_ack_sys_buf_p != NULL) { + /* command ack info */ + cmd_ack_sys_buf_p->cack.id = cack_id; + cmd_ack_sys_buf_p->cack.sub_id = sub_cack_id; + cmd_ack_sys_buf_p->cack.distinct = priv_p->sys_cmd_distinct_p; + Fmb_core_add_busy_cmd_ack_sys_buf( + priv_p, &priv_p->cmd_cack_sys_queue ,cmd_ack_sys_buf_p ); + } + } + else { + priv_p->sys_cmd_ack_info.id = cack_id; + priv_p->sys_cmd_ack_info.sub_id = sub_cack_id; + priv_p->sys_cmd_ack_info.distinct = priv_p->sys_cmd_distinct_p; + priv_p->sys_cmd_ack_rcv_flag = FMB_SYS_CMD_ACK_RECEIVE; + + wake_up_interruptible( &priv_p->sys_cmd_ack_wait_sync ); + } + + priv_p->sys_cmd_send_flag = FMB_SYS_CMD_SEND_NONE; + + tasklet_schedule( &priv_p->cmd_sys_tasklet ); + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + + +/** +* @brief MB86 Codec VSYNC interrupt tasklet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_vsync_tasklet( unsigned long data ) +{ + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + unsigned short field; + + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + /* check receive message */ + fmb_core_check_vsync_msg( priv_p ); + + if(priv_p->vsync_mode == FMB_DATA_VSYNC_TOP) { + field = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_ADD_PRAM_V_FIELD ); + if(field != FMB_DATA_ENCODE_TOP){ + return; + } + } + else if(priv_p->vsync_mode == FMB_DATA_VSYNC_BOTTOM) { + field = FMB_LSI_REG_FIELD_READ( hw_priv_p, FMB_ADD_PRAM_V_FIELD ); + if(field != FMB_DATA_ENCODE_BOTTOM){ + return; + } + } + + /* check send command */ + fmb_core_check_vsync_cmd( priv_p ); + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + + +/** +* @brief MB86 Codec system command send tasklet +* @param[in] data the pointer to the HW private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_cmd_sys_tasklet( unsigned long data ) +{ + int i; + unsigned long flags; + struct fmb_sys_cmd_buf* sys_cmd_buf_p; + struct fmb_hard_private* hw_priv_p; + struct fmb_core_private* priv_p; + int minor; + + sys_cmd_buf_p = NULL; + hw_priv_p = (struct fmb_hard_private *)data; + priv_p = hw_priv_p->core_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + /** check comannd ACK received*/ + spin_lock_irqsave( &priv_p->lock_core_priv, flags ); + + if (priv_p->sys_cmd_send_flag != FMB_SYS_CMD_SEND_NONE) { + spin_unlock_irqrestore( &priv_p->lock_core_priv, flags ); + + MSG( DEBUG_LVL, minor, "Previous system comannd ACK is not received" ); + return; + } + + spin_unlock_irqrestore( &priv_p->lock_core_priv, flags ); + + /** check buffer active */ + spin_lock_irqsave( &priv_p->cmd_sys_queue.lock, flags ); + if (!priv_p->cmd_sys_queue.isactive) { + spin_unlock_irqrestore( &priv_p->cmd_sys_queue.lock, flags ); + return ; + } + spin_unlock_irqrestore( &priv_p->cmd_sys_queue.lock, flags ); + + /** get system command buffer */ + sys_cmd_buf_p = Fmb_core_get_busy_cmd_sys_buf( priv_p, &priv_p->cmd_sys_queue ); + if(sys_cmd_buf_p == NULL) { + return; + } + + sys_cmd_buf_p->cmd.reg[1] = + (priv_p->sys_cmd_continuity_counter & FMB_SYS_CMD_CONTINUITY_COUNTER_MASK) + << FMB_SYS_CMD_CONTINUITY_COUNTER_SHIFT; + + for (i = 0; i < FMB_CMD_SYS_INFO_SIZE; i++) { + Fmb_hw_reg_write_lsi( + hw_priv_p, FMB_SYS_CMD_BASE + (i * 2), sys_cmd_buf_p->cmd.reg[i] ); + } + + priv_p->sys_cmd_continuity_counter++; + priv_p->sys_cmd_continuity_counter &= FMB_SYS_CMD_CONTINUITY_COUNTER_MASK; + + spin_lock_irqsave( &priv_p->lock_core_priv, flags ); + + if (sys_cmd_buf_p->cmd.sync == FMB_MODE_ASYNC) { + priv_p->sys_cmd_send_flag = FMB_SYS_CMD_SEND_ASYNC; + } + else { + priv_p->sys_cmd_send_flag = FMB_SYS_CMD_SEND_SYNC; + } + priv_p->sys_cmd_distinct_p = sys_cmd_buf_p->cmd.distinct; + + spin_unlock_irqrestore( &priv_p->lock_core_priv, flags ); + + Fmb_core_add_free_cmd_sys_buf( priv_p, &priv_p->cmd_sys_queue, sys_cmd_buf_p ); + + FMB_LSI_REG_FIELD_WRITE( + hw_priv_p, FMB_API_SETIRQ_TCPU, FMB_API_SETIRQ_TCPU_SET ); + MSG(CMDMSG_LVL, minor, "send system command"); + + + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + + +/** +* @brief initialize tasklet to MB86 Codec +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +static void fmb_core_tasklet_init( struct fmb_core_private* priv_p ) +{ + int minor; + struct fmb_hard_private* hw_priv_p; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + hw_priv_p = priv_p->hw_priv_p; + tasklet_init( &priv_p->xerror_tasklet, fmb_core_xerror_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->tcpu_tasklet, fmb_core_tcpu_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->tack_tasklet, fmb_core_tack_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->vsync_tasklet, fmb_core_vsync_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->cmd_sys_tasklet, fmb_core_cmd_sys_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->dma_comp_snd_tasklet, fmb_core_dma_snd_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->dma_comp_rcv_tasklet, fmb_core_dma_rcv_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->ederr_tasklet, fmb_core_ederr_tasklet, (unsigned long)hw_priv_p ); + tasklet_init( &priv_p->dderr_tasklet, fmb_core_dderr_tasklet, (unsigned long)hw_priv_p ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** +* @brief kill tasklet to MB86 Codec +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +static void fmb_corel_tasklet_kill( struct fmb_core_private* priv_p ) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + tasklet_kill( &priv_p->xerror_tasklet ); + tasklet_kill( &priv_p->tcpu_tasklet ); + tasklet_kill( &priv_p->tack_tasklet ); + tasklet_kill( &priv_p->vsync_tasklet ); + tasklet_kill( &priv_p->cmd_sys_tasklet ); + tasklet_kill( &priv_p->dma_comp_snd_tasklet ); + tasklet_kill( &priv_p->dma_comp_rcv_tasklet ); + tasklet_kill( &priv_p->ederr_tasklet ); + tasklet_kill( &priv_p->dderr_tasklet ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** +* @brief XERROR interrupt to MB86 Codec +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +void Fmb_core_xerror_irq( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + tasklet_schedule( &priv_p->xerror_tasklet ); + + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** +* @brief INT interrupt to MB86 Codec +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +void Fmb_core_int_irq( struct fmb_core_private* priv_p ) +{ + unsigned short fmb_api_irqst; + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( CODEC_FUNC, minor, "START" ); + MSG( INTERNAL_FUNC, minor, "START" ); + + /* clear interrupt status */ + fmb_api_irqst = Fmb_hw_reg_read_lsi( hw_priv_p, FMB_API_IRQST_ALL ); + if (priv_p->irqst_clear_flg == FMB_DATA_IRQSTFLAG_ON) { + Fmb_hw_reg_write_lsi( hw_priv_p, FMB_API_IRQST_ALL, fmb_api_irqst ); + } + if ((fmb_api_irqst & (FMB_API_IRQST_TCPU_MASK << FMB_API_IRQST_TCPU_SHIFT)) != 0) { + MSG(SYSMSG_LVL, minor, "irq system message"); + tasklet_schedule( &priv_p->tcpu_tasklet ); + } + + if ((fmb_api_irqst & (FMB_API_IRQST_TACK_MASK << FMB_API_IRQST_TACK_SHIFT)) != 0) { + MSG(CMDMSG_LVL, minor, "irq system command"); + tasklet_schedule( &priv_p->tack_tasklet ); + } + + if ((fmb_api_irqst & (FMB_API_IRQST_VSYNC_MASK << FMB_API_IRQST_VSYNC_SHIFT)) != 0) { + tasklet_schedule( &priv_p->vsync_tasklet ); + } + MSG( INTERNAL_FUNC, minor, "END" ); + MSG( CODEC_FUNC, minor, "END" ); +} + +/** +* @brief EDERR interrupt to MB86 Codec +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +void Fmb_core_ederr_irq( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + tasklet_schedule( &priv_p->ederr_tasklet ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + +/** +* @brief DDERR interrupt to MB86 Codec +* @param[in] priv_p the pointer to the core private data +* @return None +* @note None +* @attention None +*/ +void Fmb_core_dderr_irq( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + tasklet_schedule( &priv_p->dderr_tasklet ); + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/********************************************************/ +/* */ +/* LSI core dependence initialization function */ +/* */ +/********************************************************/ +/** + * @brief Initializes the core private data. + * @param[in] hw_priv_p the pointer to the HW private data + * @param[in] priv_p the pointer to the core private data + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +static int fmb_core_private_data_init( struct fmb_hard_private* hw_priv_p, + struct fmb_core_private* priv_p ) +{ + int ret; + int minor; + + ret = 0; + minor = hw_priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + priv_p->lock_core_priv = SPIN_LOCK_UNLOCKED; + priv_p->lock_factor_num = SPIN_LOCK_UNLOCKED; + priv_p->firm_write_redy = 0; + priv_p->firm_write_size = 0; + priv_p->system_status = FMB_ADD_PRAM_M_MODE_IDLE; + priv_p->encode_mode = FMB_DATA_ENCODE_TOP; + priv_p->notify_mode = FMB_DATA_NOTIFY_NONE; + priv_p->sys_cmd_ack_rcv_flag = FMB_SYS_CMD_ACK_NONE; + priv_p->sys_cmd_send_flag = FMB_SYS_CMD_SEND_NONE; + priv_p->factor_num = 0; + priv_p->factor_irq = FMB_FACTOR_NONE; + init_waitqueue_head( &priv_p->sys_cmd_ack_wait ); + init_waitqueue_head( &priv_p->sys_cmd_ack_wait_sync ); + init_waitqueue_head( &priv_p->sys_msg_wait ); + init_waitqueue_head( &priv_p->video_msg_wait ); + init_waitqueue_head( &priv_p->audio_msg_wait ); + init_waitqueue_head( &priv_p->xerror_info_wait ); + init_waitqueue_head( &priv_p->vudata_info_wait ); + init_MUTEX( &priv_p->sys_cmd_sync_send_mutex ); + priv_p->read_dma_flg = FMB_DATA_DMAFLAG_ON; + priv_p->read_dma_count = g_Dmacount_read; + priv_p->write_dma_flg = FMB_DATA_DMAFLAG_ON; + priv_p->write_dma_count = g_Dmacount_write; + priv_p->irqst_clear_flg = FMB_DATA_IRQSTFLAG_ON; + priv_p->vsync_mode = FMB_DATA_VSYNC_ALL; + priv_p->minor = minor; + priv_p->hw_priv_p = hw_priv_p; + + priv_p->check_msg_sys_info_p = kmalloc( FMB_SYS_MSG_REG_SIZE, GFP_KERNEL ); + if (priv_p->check_msg_sys_info_p == NULL) { + MSG( KERN_ERR_LVL, minor, "kmalloc failed(priv_p->check_msg_sys_info_p)" ); + goto err_out; + } + + priv_p->check_msg_video_info_p = kmalloc( FMB_VIDEO_MSG_REG_SIZE, GFP_KERNEL ); + if (priv_p->check_msg_video_info_p == NULL) { + MSG( KERN_ERR_LVL, minor, "kmalloc failed(priv_p->check_msg_video_info_p)" ); + goto err_out; + } + + priv_p->check_msg_audio_info_p = kmalloc( FMB_AUDIO_MSG_REG_SIZE, GFP_KERNEL ); + if (priv_p->check_msg_audio_info_p == NULL) { + MSG( KERN_ERR_LVL, minor, "kmalloc failed(priv_p->check_msg_audio_info_p)" ); + goto err_out; + } + + priv_p->check_vudata_info_p = kmalloc( FMB_VUDATA_INFO_REG_SIZE, GFP_KERNEL ); + if (priv_p->check_vudata_info_p == NULL) { + MSG( KERN_ERR_LVL, minor, "kmalloc failed(priv_p->check_vudata_info_p)" ); + goto err_out; + } + + priv_p->sync_cmd_video_info_p = kmalloc( FMB_CMD_VIDEO_INFO_SIZE, GFP_KERNEL ); + if (priv_p->sync_cmd_video_info_p == NULL) { + MSG( KERN_ERR_LVL, minor, "kmalloc failed(priv_p->sync_cmd_video_info_p)" ); + goto err_out; + } + + priv_p->sync_cmd_audio_info_p = kmalloc( FMB_CMD_AUDIO_INFO_SIZE, GFP_KERNEL ); + if (priv_p->sync_cmd_audio_info_p == NULL) { + MSG( KERN_ERR_LVL, minor, "kmalloc failed(priv_p->sync_cmd_audio_info_p)" ); + goto err_out; + } + + /* message buffer initialize */ + Fmb_core_init_msg_sys_buf( priv_p, &priv_p->msg_sys_queue ); + priv_p->msg_sys_queue.isactive = 1; + + ret = Fmb_core_init_msg_video_buf( priv_p, &priv_p->msg_video_queue ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "Fmb_core_init_msg_video_buf failed" ); + goto err_out; + } + priv_p->msg_video_queue.isactive = 1; + + ret = Fmb_core_init_msg_audio_buf( priv_p, &priv_p->msg_audio_queue ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "Fmb_core_init_msg_audio_buf failed" ); + goto err_out; + } + priv_p->msg_audio_queue.isactive = 1; + + Fmb_core_init_cmd_ack_sys_buf( priv_p, &priv_p->cmd_cack_sys_queue ); + priv_p->cmd_cack_sys_queue.isactive = 1; + + ret = Fmb_core_init_xerror_info_buf( priv_p, &priv_p->xerror_info_queue ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "Fmb_core_init_xerror_info_buf failed" ); + goto err_out; + } + priv_p->xerror_info_queue.isactive = 1; + + ret = Fmb_core_init_vudata_buf( priv_p, &priv_p->vudata_info_queue ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "Fmb_core_init_vudata_buf failed" ); + goto err_out; + } + priv_p->vudata_info_queue.isactive = 1; + + ret = Fmb_core_init_ederr_info_buf( priv_p, &priv_p->ederr_info_queue ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "Fmb_core_init_ederr_buf failed" ); + goto err_out; + } + priv_p->ederr_info_queue.isactive = 1; + + ret = Fmb_core_init_dderr_info_buf( priv_p, &priv_p->dderr_info_queue ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "Fmb_core_init_dderr_buf failed" ); + goto err_out; + } + priv_p->dderr_info_queue.isactive = 1; + + /* command buffer initialize */ + Fmb_core_init_cmd_sys_buf( priv_p, &priv_p->cmd_sys_queue ); + priv_p->cmd_sys_queue.isactive = 1; + Fmb_core_init_cmd_video_buf( priv_p, &priv_p->cmd_video_queue ); + priv_p->cmd_video_queue.isactive = 1; + Fmb_core_init_cmd_audio_buf( priv_p, &priv_p->cmd_audio_queue ); + priv_p->cmd_audio_queue.isactive = 1; + + /* DMA buffer initialize */ + ret = fmb_core_init_dma_queue_snd( priv_p ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "fmb_core_init_dma_queue_snd failed" ); + goto err_out; + } + priv_p->dma_snd_queue.isactive = 1; + + ret = fmb_core_init_dma_queue_rcv( priv_p ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "fmb_core_init_dma_queue_rcv failed" ); + goto err_out; + } + priv_p->dma_rcv_queue.isactive = 1; + + MSG( INTERNAL_FUNC, minor, "END" ); + return 0; + +err_out: + fmb_core_private_data_release( priv_p ); + memset( priv_p, 0, sizeof(struct fmb_core_private) ); + + return -1; +} + +/** + * @brief Releases the core private data. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +static void fmb_core_private_data_release( struct fmb_core_private* priv_p ) +{ + int minor; + + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + /* Release Memorry */ + if (priv_p->check_msg_sys_info_p != NULL) { + MSG( INTERNAL_FUNC, minor, "Release memory(check_msg_sys_info_p)" ); + kfree( priv_p->check_msg_sys_info_p ); + } + if (priv_p->check_msg_video_info_p != NULL) { + MSG( INTERNAL_FUNC, minor, "Release memory(check_msg_video_info_p)" ); + kfree( priv_p->check_msg_video_info_p ); + } + if (priv_p->check_msg_audio_info_p != NULL) { + MSG( INTERNAL_FUNC, minor, "Release memory(check_msg_audio_info_p)" ); + kfree( priv_p->check_msg_audio_info_p ); + } + if (priv_p->check_vudata_info_p != NULL) { + MSG( INTERNAL_FUNC, minor, "Release memory(check_msg_vudata_info_p)" ); + kfree( priv_p->check_vudata_info_p ); + } + if (priv_p->sync_cmd_video_info_p != NULL) { + MSG( INTERNAL_FUNC, minor, "Release memory(sync_cmd_video_info_p)" ); + kfree( priv_p->sync_cmd_video_info_p ); + } + if (priv_p->sync_cmd_audio_info_p != NULL) { + MSG( INTERNAL_FUNC, minor, "Release memory(sync_cmd_audio_info_p)" ); + kfree( priv_p->sync_cmd_audio_info_p ); + } + + /* Release message buffer */ + if (priv_p->msg_video_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release message buffer(msg_video_queue)" ); + Fmb_core_release_msg_video_buf( priv_p, &priv_p->msg_video_queue ); + } + if (priv_p->msg_audio_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release message buffer(msg_audio_queue)" ); + Fmb_core_release_msg_audio_buf( priv_p, &priv_p->msg_audio_queue ); + } + if (priv_p->xerror_info_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release message buffer(xerror_info_queue)" ); + Fmb_core_release_xerror_info_buf( priv_p, &priv_p->xerror_info_queue ); + } + if (priv_p->vudata_info_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release message buffer(vudata_info_queue)" ); + Fmb_core_release_vudata_buf( priv_p, &priv_p->vudata_info_queue ); + } + + if (priv_p->ederr_info_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release message buffer(ederr_info_queue)" ); + Fmb_core_release_ederr_info_buf( priv_p, &priv_p->ederr_info_queue ); + } + + if (priv_p->dderr_info_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release message buffer(dderr_info_queue)" ); + Fmb_core_release_dderr_info_buf( priv_p, &priv_p->dderr_info_queue ); + } + + /* Release DMA buffer */ + if (priv_p->dma_snd_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release DMA buffer(HOST->LSI)" ); + fmb_core_release_dma_queue_snd( priv_p ); + } + if (priv_p->dma_rcv_queue.isactive) { + MSG( INTERNAL_FUNC, minor, "Release DMA buffer(LSI->HOST)" ); + fmb_core_release_dma_queue_rcv( priv_p ); + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief The MB86-LSI part of the probe function. + * @param[in] hw_priv_p the pointer to the HW private data + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_probe( struct fmb_hard_private* hw_priv_p ) +{ + struct fmb_core_private* priv_p; + int ret; + int minor; + + priv_p = NULL; + ret = 0; + minor = hw_priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + priv_p = &s_Fmb_core_private_list[minor]; + + if ( priv_p->minor != -1 ) { + MSG( INTERNAL_ERR_LVL, minor, + "Specified minor has already been used. priv_p->minor = %d", + priv_p->minor ); + return -1; + } + + ret = fmb_core_private_data_init( hw_priv_p, priv_p ); + if (ret != 0) { + MSG( INTERNAL_ERR_LVL, minor, "fmb_core_private_data_init() NG ret = %d", ret ); + return -1; + } + hw_priv_p->core_priv_p = priv_p; + + /* Hi-Level mode only */ + fmb_core_tasklet_init( priv_p ); + + MSG( INTERNAL_FUNC, minor, "END" ); + + return 0; +} + + +/** + * @brief Kills tasklets and releases the core private data. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_remove( struct fmb_core_private* priv_p ) +{ + struct fmb_hard_private* hw_priv_p; + int minor; + + hw_priv_p = priv_p->hw_priv_p; + minor = priv_p->minor; + MSG( INTERNAL_FUNC, minor, "START" ); + + fmb_corel_tasklet_kill( priv_p ); + Fmb_core_clear_dma_all( priv_p ); + fmb_core_private_data_release( priv_p ); + + /* initialize the core private data */ + memset( &s_Fmb_core_private_list[minor], 0, sizeof( struct fmb_core_private ) ); + s_Fmb_core_private_list[minor].minor = -1; + + MSG( INTERNAL_FUNC, minor, "END" ); +} + + +/** + * @brief The MB86-LSI part of the init_module function. + * @param None + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_module( void ) +{ + int cnt = 0; + int minor; + + minor = -1; + + MSG( INTERNAL_FUNC, minor, "START" ); + + memset( s_Fmb_core_private_list, 0x00, sizeof( s_Fmb_core_private_list ) ); + + for ( cnt = 0; cnt < FMB_MAX_CARDS; cnt++ ) { + s_Fmb_core_private_list[cnt].minor = -1; + } + + MSG( INTERNAL_FUNC, minor, "END" ); +} diff --git a/fmb_driver/fmb_core.h b/fmb_driver/fmb_core.h new file mode 100644 index 0000000..82767a2 --- /dev/null +++ b/fmb_driver/fmb_core.h @@ -0,0 +1,2052 @@ +/** + * @brief The header file for the MB86-API Linux driver(LSI core dependent part) + * @since 2009/01/08 + * @note None + * @attention None + * <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> + */ + +/* + * 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. + */ + +/****************************************************************************/ +#ifndef __FMB_CORE_H__ +#define __FMB_CORE_H__ + + +//#include <linux/config.h> +#include <linux/version.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/string.h> +#include <linux/errno.h> +#include <linux/slab.h> +#include <linux/interrupt.h> +#include <linux/timer.h> +#include <linux/pci.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <asm/io.h> +#include <asm/uaccess.h> + +#include "fmb_drv.h" +#include "fmb_hw.h" + +/********************************************************/ +/* Constant definition for ioctl() */ +/********************************************************/ +/** + * Async system command send + */ +#define FMB_SYS_CMD_SEND_NONE 0 +#define FMB_SYS_CMD_SEND_SYNC 1 +#define FMB_SYS_CMD_SEND_ASYNC 2 + +/** + * system command ACK receive (for sync mode) + */ +#define FMB_SYS_CMD_ACK_NONE 0 +#define FMB_SYS_CMD_ACK_RECEIVE 1 + +#define FMB_CMD_TYPE_VIDEO 0x00000000 +#define FMB_CMD_TYPE_AUDIO 0x00000001 + +/********************************************************/ +/* Constant definition for MB86 LSI core */ +/********************************************************/ +/** + * register address + */ +#define FMB_INTERNAL_RAM 0x0 + +/** + * Version Info + */ +#define FMB_VERSION_BASE 0x10 +#define FMB_VERSION_FJ_3 (FMB_VERSION_BASE + 0x00) +#define FMB_VERSION_FJ_2 (FMB_VERSION_BASE + 0x02) +#define FMB_VERSION_FJ_1 (FMB_VERSION_BASE + 0x04) +#define FMB_VERSION_FJ_0 (FMB_VERSION_BASE + 0x06) +#define FMB_VERSION_RESERVED0 (FMB_VERSION_BASE + 0x08) +#define FMB_VERSION_RESERVED1 (FMB_VERSION_BASE + 0x0A) +#define FMB_VERSION_RESERVED2 (FMB_VERSION_BASE + 0x0C) +#define FMB_VERSION_RESERVED3 (FMB_VERSION_BASE + 0x0E) + +/** + * System Command + */ +#define FMB_SYS_CMD_BASE 0x80000 +#define FMB_SYS_CMD_DESTINATION_ID (FMB_SYS_CMD_BASE + 0x0) +#define FMB_SYS_CMD_CONTINUITY_COUNTER (FMB_SYS_CMD_BASE + 0x2) +#define FMB_SYS_CMD_CMD_ID (FMB_SYS_CMD_BASE + 0x4) +#define FMB_SYS_CMD_SUB_CMD_ID (FMB_SYS_CMD_BASE + 0x4) +#define FMB_SYS_CMD_BODY_00 (FMB_SYS_CMD_BASE + 0x6) + +/** + * System Command ACK + */ +#define FMB_SYS_CMD_ACK_BASE 0x80020 +#define FMB_SYS_CMD_ACK_CONTINUITY_COUNTER (FMB_SYS_CMD_ACK_BASE + 0x2) +#define FMB_SYS_CMD_ACK_CACK_ID (FMB_SYS_CMD_ACK_BASE + 0x4) +#define FMB_SYS_CMD_ACK_SUB_CACK_ID (FMB_SYS_CMD_ACK_BASE + 0x4) + +/** + * System Message + */ +#define FMB_SYS_MSG_BASE 0x80040 +#define FMB_SYS_MSG_CONTINUITY_COUNTER (FMB_SYS_MSG_BASE + 0x2) +#define FMB_SYS_MSG_MSG_ID (FMB_SYS_MSG_BASE + 0x4) +#define FMB_SYS_MSG_SUB_MSG_ID (FMB_SYS_MSG_BASE + 0x4) +#define FMB_SYS_MSG_BODY_00 (FMB_SYS_MSG_BASE + 0x6) + +/** + * System Message ACK + */ +#define FMB_SYS_MSG_ACK_BASE 0x80060 +#define FMB_SYS_MSG_ACK_DESTINATION_ID (FMB_SYS_MSG_ACK_BASE + 0x0) +#define FMB_SYS_MSG_ACK_CONTINUITY_COUNTER (FMB_SYS_MSG_ACK_BASE + 0x2) +#define FMB_SYS_MSG_ACK_MACK_ID (FMB_SYS_MSG_ACK_BASE + 0x4) + +/** + * Add Parammeter Multiple + */ +#define FMB_ADD_PRAM_M_BASE 0x800C0 +#define FMB_ADD_PRAM_M_MODE (FMB_ADD_PRAM_M_BASE + 0x0) +#define FMB_ADD_PRAM_M_RELOAD (FMB_ADD_PRAM_M_BASE + 0x0) + +/** + * Add Parammeter Video + */ +#define FMB_ADD_PRAM_V_BASE 0x801E0 +#define FMB_ADD_PRAM_V_AB_SEL (FMB_ADD_PRAM_V_BASE + 0x0) +#define FMB_ADD_PRAM_V_FIELD (FMB_ADD_PRAM_V_BASE + 0x0) + +/** + * Video Command(A) + */ +#define FMB_VIDEO_CMD_A_BASE 0x81000 + +/** + * Video Command(B) + */ +#define FMB_VIDEO_CMD_B_BASE 0x82000 + +/** + * Video Message(A) + */ +#define FMB_VIDEO_MSG_A_BASE 0x81040 +#define FMB_VIDEO_MSG_A_VALID (FMB_VIDEO_MSG_A_BASE + 0x0) +#define FMB_VIDEO_MSG_A_CMD_INVALID (FMB_VIDEO_MSG_A_BASE + 0x2) +#define FMB_VIDEO_MSG_A_MODE (FMB_VIDEO_MSG_A_BASE + 0x2) +#define FMB_VIDEO_MSG_A_ERROR_LEVEL_H (FMB_VIDEO_MSG_A_BASE + 0x8) +#define FMB_VIDEO_MSG_A_ERROR_LEVEL_L (FMB_VIDEO_MSG_A_BASE + 0xA) +#define FMB_VIDEO_MSG_A_SUBMODE (FMB_VIDEO_MSG_A_BASE + 0x52) +#define FMB_VIDEO_MSG_A_VUDATA_LENGTH (FMB_VIDEO_MSG_A_BASE + 0x54) + +/** + * Video Message(B) + */ +#define FMB_VIDEO_MSG_B_BASE 0x82040 +#define FMB_VIDEO_MSG_B_VALID (FMB_VIDEO_MSG_B_BASE + 0x0) +#define FMB_VIDEO_MSG_B_CMD_INVALID (FMB_VIDEO_MSG_B_BASE + 0x2) +#define FMB_VIDEO_MSG_B_MODE (FMB_VIDEO_MSG_B_BASE + 0x2) +#define FMB_VIDEO_MSG_B_ERROR_LEVEL_H (FMB_VIDEO_MSG_B_BASE + 0x8) +#define FMB_VIDEO_MSG_B_ERROR_LEVEL_L (FMB_VIDEO_MSG_B_BASE + 0xA) +#define FMB_VIDEO_MSG_B_SUBMODE (FMB_VIDEO_MSG_B_BASE + 0x52) +#define FMB_VIDEO_MSG_B_VUDATA_LENGTH (FMB_VIDEO_MSG_B_BASE + 0x54) + +/** + * Audio Command(A) + */ +#define FMB_AUDIO_CMD_A_BASE 0x83000 + +/** + * Audio Command(B) + */ +#define FMB_AUDIO_CMD_B_BASE 0x83100 + +/** + * Audio Message(A) + */ +#define FMB_AUDIO_MSG_A_BASE 0x83020 +#define FMB_AUDIO_MSG_A_VALID (FMB_AUDIO_MSG_A_BASE + 0x0) + +/** + * Audio Message(B) + */ +#define FMB_AUDIO_MSG_B_BASE 0x83120 +#define FMB_AUDIO_MSG_B_VALID (FMB_AUDIO_MSG_B_BASE + 0x0) + +/** + * VUDATA Info(A) + */ +#define FMB_VUDATA_INFO_A_BASE 0x81100 + +/** + * VUDATA Info(B) + */ +#define FMB_VUDATA_INFO_B_BASE 0x82100 + +/** + * Error Info + */ +#define FMB_ERROR_INFO_BASE 0x80050 +#define FMB_ERROR_INFO_M_H (FMB_ERROR_INFO_BASE + 0x00) +#define FMB_ERROR_INFO_M_L (FMB_ERROR_INFO_BASE + 0x02) +#define FMB_ERROR_INFO_V_H (FMB_ERROR_INFO_BASE + 0x04) +#define FMB_ERROR_INFO_V_L (FMB_ERROR_INFO_BASE + 0x06) +#define FMB_ERROR_INFO_A_H (FMB_ERROR_INFO_BASE + 0x08) +#define FMB_ERROR_INFO_A_L (FMB_ERROR_INFO_BASE + 0x0A) +#define FMB_ERROR_INFO_RESERVED0 (FMB_ERROR_INFO_BASE + 0x0C) +#define FMB_ERROR_INFO_RESERVED1 (FMB_ERROR_INFO_BASE + 0x0E) + + +/** + * Control Register + */ +#define FMB_BANKSEL 0x90000 +#define FMB_API_SETIRQ_TCPU 0x90070 +#define FMB_API_SETIRQ_TACK 0x90070 +#define FMB_API_IRQST_ALL 0x90074 +#define FMB_API_IRQST_TCPU 0x90074 +#define FMB_API_IRQST_TACK 0x90074 +#define FMB_API_IRQST_VSYNC 0x90074 +#define FMB_API_HCPU_IRQEN_TCPU 0x90078 +#define FMB_API_HCPU_IRQEN_TACK 0x90078 +#define FMB_API_HCPU_IRQEN_VSYNC 0x90078 +#define FMB_OUT_DRIVE 0x90108 + +/** + * mask & shift + */ +#define FMB_SYS_CMD_DESTINATION_ID_MASK 0x000F +#define FMB_SYS_CMD_DESTINATION_ID_SHIFT 12 +#define FMB_SYS_CMD_CONTINUITY_COUNTER_MASK 0x003F +#define FMB_SYS_CMD_CONTINUITY_COUNTER_SHIFT 0 +#define FMB_SYS_CMD_CMD_ID_MASK 0x00FF +#define FMB_SYS_CMD_CMD_ID_SHIFT 8 +#define FMB_SYS_CMD_SUB_CMD_ID_MASK 0x00FF +#define FMB_SYS_CMD_SUB_CMD_ID_SHIFT 0 +#define FMB_SYS_CMD_BODY_00_MASK 0xFFFF +#define FMB_SYS_CMD_BODY_00_SHIFT 0 + +#define FMB_SYS_CMD_ACK_CONTINUITY_COUNTER_MASK 0x003F +#define FMB_SYS_CMD_ACK_CONTINUITY_COUNTER_SHIFT 0 +#define FMB_SYS_CMD_ACK_CACK_ID_MASK 0x00FF +#define FMB_SYS_CMD_ACK_CACK_ID_SHIFT 8 +#define FMB_SYS_CMD_ACK_SUB_CACK_ID_MASK 0x00FF +#define FMB_SYS_CMD_ACK_SUB_CACK_ID_SHIFT 0 + +#define FMB_SYS_MSG_CONTINUITY_COUNTER_MASK 0x003F +#define FMB_SYS_MSG_CONTINUITY_COUNTER_SHIFT 0 +#define FMB_SYS_MSG_MSG_ID_MASK 0x00FF +#define FMB_SYS_MSG_MSG_ID_SHIFT 8 +#define FMB_SYS_MSG_SUB_MSG_ID_MASK 0x00FF +#define FMB_SYS_MSG_SUB_MSG_ID_SHIFT 0 +#define FMB_SYS_MSG_BODY_00_MASK 0xFFFF +#define FMB_SYS_MSG_BODY_00_SHIFT 0 + +#define FMB_SYS_MSG_ACK_DESTINATION_ID_MASK 0x000F +#define FMB_SYS_MSG_ACK_DESTINATION_ID_SHIFT 12 +#define FMB_SYS_MSG_ACK_CONTINUITY_COUNTER_MASK 0x003F +#define FMB_SYS_MSG_ACK_CONTINUITY_COUNTER_SHIFT 0 +#define FMB_SYS_MSG_ACK_MACK_ID_MASK 0x00FF +#define FMB_SYS_MSG_ACK_MACK_ID_SHIFT 8 + +#define FMB_ADD_PRAM_M_MODE_MASK 0x00FF +#define FMB_ADD_PRAM_M_MODE_SHIFT 0 +#define FMB_ADD_PRAM_M_RELOAD_MASK 0x00FF +#define FMB_ADD_PRAM_M_RELOAD_SHIFT 8 + +#define FMB_ADD_PRAM_V_AB_SEL_MASK 0x0001 +#define FMB_ADD_PRAM_V_AB_SEL_SHIFT 0 + +#define FMB_VIDEO_MSG_A_VALID_MASK 0x0001 +#define FMB_VIDEO_MSG_A_VALID_SHIFT 15 +#define FMB_VIDEO_MSG_B_VALID_MASK 0x0001 +#define FMB_VIDEO_MSG_B_VALID_SHIFT 15 +#define FMB_VIDEO_MSG_A_CMD_INVALID_MASK 0x0001 +#define FMB_VIDEO_MSG_A_CMD_INVALID_SHIFT 14 +#define FMB_VIDEO_MSG_B_CMD_INVALID_MASK 0x0001 +#define FMB_VIDEO_MSG_B_CMD_INVALID_SHIFT 14 +#define FMB_VIDEO_MSG_A_MODE_MASK 0x00FF +#define FMB_VIDEO_MSG_A_MODE_SHIFT 0 +#define FMB_VIDEO_MSG_B_MODE_MASK 0x00FF +#define FMB_VIDEO_MSG_B_MODE_SHIFT 0 +#define FMB_VIDEO_MSG_A_SEQ_END_MASK 0x0001 +#define FMB_VIDEO_MSG_A_SEQ_END_SHIFT 2 +#define FMB_VIDEO_MSG_B_SEQ_END_MASK 0x0001 +#define FMB_VIDEO_MSG_B_SEQ_END_SHIFT 2 +#define FMB_VIDEO_MSG_A_FRAME_UPDATE_FLAG_MASK 0x0001 +#define FMB_VIDEO_MSG_A_FRAME_UPDATE_FLAG_SHIFT 0 +#define FMB_VIDEO_MSG_B_FRAME_UPDATE_FLAG_MASK 0x0001 +#define FMB_VIDEO_MSG_B_FRAME_UPDATE_FLAG_SHIFT 0 +#define FMB_VIDEO_MSG_A_ERROR_LEVEL_H_MASK 0xFFFF +#define FMB_VIDEO_MSG_A_ERROR_LEVEL_H_SHIFT 0 +#define FMB_VIDEO_MSG_A_ERROR_LEVEL_L_MASK 0xFFFF +#define FMB_VIDEO_MSG_A_ERROR_LEVEL_L_SHIFT 0 +#define FMB_VIDEO_MSG_B_ERROR_LEVEL_H_MASK 0xFFFF +#define FMB_VIDEO_MSG_B_ERROR_LEVEL_H_SHIFT 0 +#define FMB_VIDEO_MSG_B_ERROR_LEVEL_L_MASK 0xFFFF +#define FMB_VIDEO_MSG_B_ERROR_LEVEL_L_SHIFT 0 +#define FMB_VIDEO_MSG_A_SUBMODE_MASK 0x0003 +#define FMB_VIDEO_MSG_A_SUBMODE_SHIFT 0 +#define FMB_VIDEO_MSG_B_SUBMODE_MASK 0x0003 +#define FMB_VIDEO_MSG_B_SUBMODE_SHIFT 0 +#define FMB_VIDEO_MSG_A_VUDATA_LENGTH_MASK 0x00FF +#define FMB_VIDEO_MSG_A_VUDATA_LENGTH_SHIFT 0 +#define FMB_VIDEO_MSG_B_VUDATA_LENGTH_MASK 0x00FF +#define FMB_VIDEO_MSG_B_VUDATA_LENGTH_SHIFT 0 + +#define FMB_AUDIO_MSG_A_VALID_MASK 0x0001 +#define FMB_AUDIO_MSG_A_VALID_SHIFT 15 +#define FMB_AUDIO_MSG_B_VALID_MASK 0x0001 +#define FMB_AUDIO_MSG_B_VALID_SHIFT 15 + +#define FMB_API_SETIRQ_TCPU_MASK 0x0001 +#define FMB_API_SETIRQ_TCPU_SHIFT 2 +#define FMB_API_SETIRQ_TACK_MASK 0x0001 +#define FMB_API_SETIRQ_TACK_SHIFT 3 + +#define FMB_API_IRQST_TCPU_MASK 0x0001 +#define FMB_API_IRQST_TCPU_SHIFT 2 +#define FMB_API_IRQST_TACK_MASK 0x0001 +#define FMB_API_IRQST_TACK_SHIFT 3 +#define FMB_API_IRQST_VSYNC_MASK 0x0001 +#define FMB_API_IRQST_VSYNC_SHIFT 4 + +#define FMB_API_HCPU_IRQEN_TCPU_MASK 0x0001 +#define FMB_API_HCPU_IRQEN_TCPU_SHIFT 2 +#define FMB_API_HCPU_IRQEN_TACK_MASK 0x0001 +#define FMB_API_HCPU_IRQEN_TACK_SHIFT 3 +#define FMB_API_HCPU_IRQEN_VSYNC_MASK 0x0001 +#define FMB_API_HCPU_IRQEN_VSYNC_SHIFT 4 + +#define FMB_ADD_PRAM_V_FIELD_MASK 0x0001 +#define FMB_ADD_PRAM_V_FIELD_SHIFT 15 + + +/** + * Register value + */ +#define FMB_API_IRQST_TCPU_IRQ 1 +#define FMB_API_IRQST_TACK_IRQ 1 +#define FMB_API_IRQST_VSYNC_IRQ 1 + +#define FMB_API_SETIRQ_TCPU_SET 1 +#define FMB_API_SETIRQ_TACK_SET 1 +#define FMB_API_HCPU_IRQEN_TCPU_ENABLE 1 +#define FMB_API_HCPU_IRQEN_TCPU_DISABLE 0 +#define FMB_API_HCPU_IRQEN_TACK_ENABLE 1 +#define FMB_API_HCPU_IRQEN_TACK_DISABLE 0 +#define FMB_API_HCPU_IRQEN_VSYNC_ENABLE 1 +#define FMB_API_HCPU_IRQEN_VSYNC_DISABLE 0 + +#define FMB_SYS_CMD_ACK_ID_CHECK 0x00 +#define FMB_SYS_CMD_ACK_ID_RESET 0x02 +#define FMB_SYS_CMD_ACK_ID_RELOAD 0x04 +#define FMB_SYS_CMD_ACK_ID_STREAM 0x0A +#define FMB_SYS_CMD_ACK_ID_ERROR 0x80 + +#define FMB_SYS_CMD_ACK_SUB_ID_TRUE 0x00 +#define FMB_SYS_CMD_ACK_SUB_ID_FALSE 0x80 + +#define FMB_SYS_CMD_DESTINATION_ID_SET 0x0 +#define FMB_SYS_MSG_ACK_DESTINATION_ID_SET 0x3 + +#define FMB_OUT_DRIVE_VALUE 0x0100 + +#define FMB_CODEC_BANKSEL_FIRM_DOWNLOAD_BASE 0x4200 +#define FMB_CODEC_BANKSEL_AFTER_BOOTUP 0x0000 + +#define FMB_CMD_VIDEO_VAILID_ON 0x8000 +#define FMB_CMD_AUDIO_VAILID_ON 0x8000 +#define FMB_CMD_VIDEO_VAILID_OFF 0x0000 +#define FMB_CMD_AUDIO_VAILID_OFF 0x0000 + +#define FMB_CMD_VIDEO_ENCODE_STOP 0x00 +#define FMB_CMD_VIDEO_ENCODE_START 0x01 +#define FMB_CMD_VIDEO_ENCODE_NULL 0x02 + +#define FMB_ADD_PRAM_M_MODE_IDLE 0x00 +#define FMB_ADD_PRAM_M_MODE_ENCODE 0x01 +#define FMB_ADD_PRAM_M_MODE_DECODE 0x11 + +#define FMB_ADD_PRAM_V_AB_SEL_A 0x1 +#define FMB_ADD_PRAM_V_AB_SEL_B 0x0 +#define FMB_ADD_PRAM_V_FIELD_TOP 0x0 +#define FMB_ADD_PRAM_V_FIELD_BOTTOM 0x1 + + +/** + * size define + */ +#define FMB_CODEC_BANK_SIZE (512 * 1024) + +#define FMB_CMD_SYS_INFO_SIZE 0x10 +#define FMB_CMD_VIDEO_INFO_SIZE 0x200 +#define FMB_CMD_AUDIO_INFO_SIZE 0x1e + +/** + * DMA status + */ +#define FMB_DMA_STOP 0 /* stop */ +#define FMB_DMA_START 1 /* executing */ +#define FMB_DMA_END_WAIT 2 /* waiting for end */ +#define FMB_DMA_END 3 /* end */ + +/** + * DMA buffer + */ +#define FMB_DMA_SND_BUF_CNT 1 +#define FMB_DMA_RCV_BUF_CNT 24 + +#define FMB_DMA_SND_BUF_SIZE (64*1024) +#define FMB_DMA_RCV_BUF_SIZE (128*1024) + +/** + * DMA count + */ +#define FMB_DATA_DMACOUNT_MIN 0x00000000 +#define FMB_DATA_DMACOUNT_READ_DEF 0x00000003 +#define FMB_DATA_DMACOUNT_WRITE_DEF 0x00000003 +#define FMB_DATA_DMACOUNT_MAX 0x00000180 + +/********************************************************/ +/* Macro definition (Register Field R/W) */ +/********************************************************/ +#define SWAPW(x) (((x>>8)&0x00ff) | ((x<<8)&0xff00)) + +#define FMB_LSI_REG_FIELD_READ(hw_priv_p, name) \ + ((Fmb_hw_reg_read_lsi(hw_priv_p, name) >> name##_SHIFT) & name##_MASK) + +#define FMB_LSI_REG_FIELD_WRITE(hw_priv_p, name, value) \ + Fmb_hw_reg_rmw_lsi(hw_priv_p, name, name##_SHIFT, name##_MASK, value) + + + +/********************************************************/ +/* Structure definition */ +/********************************************************/ +/** +* system message buffer +*/ +struct fmb_sys_msg_buf { + struct fmb_msg_sys_info msg; + struct fmb_sys_msg_buf* next_p; +}; + +/** +* video message buffer +*/ +struct fmb_video_msg_buf { + struct fmb_msg_video_info msg; + struct fmb_video_msg_buf* next_p; +}; + +/** +* audio message buffer +*/ +struct fmb_audio_msg_buf { + struct fmb_msg_audio_info msg; + struct fmb_audio_msg_buf* next_p; +}; + +/** +* system command ACK buffer +*/ +struct fmb_cmd_ack_sys_buf { + struct fmb_cmd_ack_sys_info cack; + struct fmb_cmd_ack_sys_buf* next_p; +}; + +/** +* XERROR info buffer +*/ +struct fmb_xerror_info_buf { + struct fmb_async_info msg; + struct fmb_xerror_info_buf* next_p; +}; + +/** +* VUDATA info buffer +*/ +struct fmb_vudata_info_buf { + struct fmb_async_info msg; + struct fmb_vudata_info_buf* next_p; +}; + +/** +* EDERR info buffer +*/ +struct fmb_ederr_info_buf { + struct fmb_async_info msg; + struct fmb_ederr_info_buf* next_p; +}; + +/** +* DDERR info buffer +*/ +struct fmb_dderr_info_buf { + struct fmb_async_info msg; + struct fmb_dderr_info_buf* next_p; +}; + + +/** +* system comand buffer +*/ +struct fmb_sys_cmd_info { + unsigned short reg[FMB_CMD_SYS_INFO_SIZE]; + void* distinct; + unsigned short sync; +}; + +struct fmb_sys_cmd_buf { + struct fmb_sys_cmd_info cmd; + struct fmb_sys_cmd_buf* next_p; +}; + +/** +* video comand buffer +*/ +struct fmb_video_cmd_info { + unsigned short reg[FMB_CMD_VIDEO_INFO_SIZE]; +}; + +struct fmb_video_cmd_buf { + struct fmb_video_cmd_info cmd; + struct fmb_video_cmd_buf* next_p; +}; + +/** +* audio comand buffer +*/ +struct fmb_audio_cmd_info { + unsigned short reg[FMB_CMD_AUDIO_INFO_SIZE]; +}; + +struct fmb_audio_cmd_buf { + struct fmb_audio_cmd_info cmd; + struct fmb_audio_cmd_buf* next_p; +}; + +/** + * DMA buffer + */ +struct fmb_dma_buf +{ + char* addr_l; /**< logical address */ + dma_addr_t addr_p; /**< physical address */ + unsigned long trans_size; /**< size to be transferred */ + unsigned long copy_size; /**< size copied */ + struct fmb_dma_buf* next_p; /**< pointer to the next buffer */ +}; + + + +/** +* system message buffer queue +*/ +struct fmb_msg_sys_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_sys_msg_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_sys_msg_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_sys_msg_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_sys_msg_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_sys_msg_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* video message buffer queue +*/ +struct fmb_msg_video_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_video_msg_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_video_msg_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_video_msg_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_video_msg_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_video_msg_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* audio message buffer queue +*/ +struct fmb_msg_audio_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_audio_msg_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_audio_msg_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_audio_msg_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_audio_msg_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_audio_msg_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* system command ACK buffer queue +*/ +struct fmb_cmd_ack_sys_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_cmd_ack_sys_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_cmd_ack_sys_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_cmd_ack_sys_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_cmd_ack_sys_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_cmd_ack_sys_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* xerror info buffer queue +*/ +struct fmb_xerror_info_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_xerror_info_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_xerror_info_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_xerror_info_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_xerror_info_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_xerror_info_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* vudata buffer queue +*/ +struct fmb_vudata_info_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_vudata_info_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_vudata_info_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_vudata_info_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_vudata_info_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_vudata_info_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* ederr info buffer queue +*/ +struct fmb_ederr_info_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_ederr_info_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_ederr_info_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_ederr_info_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_ederr_info_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_ederr_info_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* ederr info buffer queue +*/ +struct fmb_dderr_info_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_dderr_info_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_dderr_info_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_dderr_info_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_dderr_info_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_dderr_info_buf msg_buf[FMB_MSG_BUF_SIZE]; + /**< message buffer list */ +}; + +/** +* system command buffer queue +*/ +struct fmb_cmd_sys_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_sys_cmd_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_sys_cmd_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_sys_cmd_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_sys_cmd_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_sys_cmd_buf cmd_buf[FMB_CMD_BUF_SIZE]; + /**< command buffer list */ +}; + +/** +* video command buffer queue +*/ +struct fmb_cmd_video_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_video_cmd_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_video_cmd_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_video_cmd_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_video_cmd_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_video_cmd_buf cmd_buf[FMB_CMD_BUF_SIZE]; + /**< command buffer list */ +}; + +/** +* audio command buffer queue +*/ +struct fmb_cmd_audio_queue { + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + wait_queue_head_t waitq; /**< wait queue */ + int b_num; /**< using buffer number */ + int f_num; /**< number of free buffers */ + struct fmb_audio_cmd_buf* b_head_p; /**< head of a busy buffer */ + struct fmb_audio_cmd_buf* b_tail_p; /**< tail of a busy buffer */ + struct fmb_audio_cmd_buf* f_head_p; /**< head of a empty buffer */ + struct fmb_audio_cmd_buf* f_tail_p; /**< tail of a empty buffer */ + struct fmb_audio_cmd_buf cmd_buf[FMB_CMD_BUF_SIZE]; + /**< command buffer list */ +}; + +/** + * DMA buffer queue(common) + */ +struct fmb_dma_queue +{ + int dma_status; /**< DMA status */ + struct fmb_dma_buf* dma_data_p; /**< buffer used for DMA */ + struct fmb_dma_buf* copy_data_p; /**< buffer used for copying data */ + wait_queue_head_t buf_waitq; /**< wait queue for free DMA buffer */ + wait_queue_head_t comp_waitq; /**< wait queue for DMA completion of all data */ + struct fmb_dma_buf* b_head_p; /**< head of busy buffer queue */ + struct fmb_dma_buf* b_tail_p; /**< tail of busy buffer queue */ + struct fmb_dma_buf* f_head_p; /**< head of free buffer queue */ + struct fmb_dma_buf* f_tail_p; /**< tail of busy buffer queue */ + int b_num; /**< number of busy buffers */ + int f_num; /**< number of free buffers */ +}; + +/** + * DMA send buffer queue + */ +struct fmb_dma_snd_queue +{ + struct semaphore mutex_write; /**< mutex for write */ + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + struct fmb_dma_queue dma_queue; /**< DMA queue */ + struct fmb_dma_buf buf[FMB_DMA_SND_BUF_CNT]; /**< DMA buffer array */ +}; + +/** + * DMA receive buffer queue + */ +struct fmb_dma_rcv_queue +{ + struct semaphore mutex_read; /**< mutex for read */ + spinlock_t lock; /**< spin lock */ + int isactive; /**< active flag */ + struct fmb_dma_queue dma_queue; /**< DMA queue */ + struct fmb_dma_buf buf[FMB_DMA_RCV_BUF_CNT]; + /**< DMA buffer array */ + unsigned long dma_comp_size; /**< total size of DMA(byte) */ + wait_queue_head_t comp_waitq; /**< wait queue for DMA completion */ +}; + +/** + * @brief The MB86-LSI-dependent part of private data<br> + * @note None + * @attention None + */ +struct fmb_core_private +{ + spinlock_t lock_core_priv; /**< spin lock for this private data */ + + unsigned char sys_cmd_continuity_counter; /**< continuity counter of system command */ + + int firm_write_redy; /**< whether or not the driver can download firmware */ + unsigned long firm_write_size; /**< total size of downloaded firmware */ + + unsigned int encode_mode; + unsigned int notify_mode; + + unsigned int system_status; + int sys_cmd_ack_rcv_flag; + int sys_cmd_send_flag; + void* sys_cmd_distinct_p; + struct fmb_cmd_ack_sys_info sys_cmd_ack_info; /**< system command ack info */ + + /* check message info */ + unsigned short* check_msg_sys_info_p; /**< check buffer for system message */ + unsigned short* check_msg_video_info_p; /**< check buffer for video message */ + unsigned short* check_msg_audio_info_p; /**< check buffer for audio message */ + unsigned short* check_vudata_info_p; /**< check buffer for VUDATA info */ + + /* sync command info */ + unsigned short* sync_cmd_video_info_p; /**< video commando info */ + unsigned short* sync_cmd_audio_info_p; /**< audio commando info */ + + /* message buffer queue */ + spinlock_t lock_factor_num; /**< spin lock for factor_num */ + int factor_num; + struct fmb_msg_sys_queue msg_sys_queue; /**< buffer queue for system message */ + struct fmb_msg_video_queue msg_video_queue; /**< buffer queue for video message */ + struct fmb_msg_audio_queue msg_audio_queue; /**< buffer queue for audio message */ + struct fmb_cmd_ack_sys_queue cmd_cack_sys_queue; /**< buffer queue for system command ack */ + struct fmb_xerror_info_queue xerror_info_queue; /**< buffer queue for XERROR info */ + struct fmb_vudata_info_queue vudata_info_queue; /**< buffer queue for VUDATA info */ + struct fmb_ederr_info_queue ederr_info_queue; /**< buffer queue for EDERR info */ + struct fmb_dderr_info_queue dderr_info_queue; /**< buffer queue for DDERR info */ + /* command buffer queue */ + struct fmb_cmd_sys_queue cmd_sys_queue; /**< buffer queue for system command */ + struct fmb_cmd_video_queue cmd_video_queue; /**< buffer queue for video command */ + struct fmb_cmd_audio_queue cmd_audio_queue; /**< buffer queue for audio command */ + + /* Low Level mode only */ + int factor_irq; + + /* DMA buffer queue */ + struct fmb_dma_snd_queue dma_snd_queue; /**< buffer queue for DMA send */ + struct fmb_dma_rcv_queue dma_rcv_queue; /**< buffer queue for DMA receive */ + + /* waitqueue */ + wait_queue_head_t sys_cmd_ack_wait; /**< wait queue for system command ACK */ + wait_queue_head_t sys_cmd_ack_wait_sync; /**< wait queue for system command ACK(SYNC mode) */ + wait_queue_head_t sys_msg_wait; /**< wait queue for system message */ + wait_queue_head_t video_msg_wait; /**< wait queue for video message */ + wait_queue_head_t audio_msg_wait; /**< wait queue for audio message */ + wait_queue_head_t xerror_info_wait; /**< wait queue for XERROR */ + wait_queue_head_t vudata_info_wait; /**< wait queue for VUDATA */ + wait_queue_head_t ederr_info_wait; /**< wait queue for EDERR */ + wait_queue_head_t dderr_info_wait; /**< wait queue for DDERR */ + + /* tasklet */ + struct tasklet_struct xerror_tasklet; /**< tasklet for XERROR interrupt */ + struct tasklet_struct tcpu_tasklet; /**< tasklet for TCPU interrupt */ + struct tasklet_struct tack_tasklet; /**< tasklet for TACK interrupt */ + struct tasklet_struct vsync_tasklet; /**< tasklet for VSYNC interrupt */ + struct tasklet_struct cmd_sys_tasklet; /**< tasklet for system command */ + struct tasklet_struct dma_comp_snd_tasklet; /**< tasklet for DMA(send) completion interrupt */ + struct tasklet_struct dma_comp_rcv_tasklet; /**< tasklet for DMA(receive) completion interrupt */ + struct tasklet_struct ederr_tasklet; /**< tasklet for EDERR interrupt */ + struct tasklet_struct dderr_tasklet; /**< tasklet for DDERR interrupt */ + + + /* DMA Timer */ + unsigned int read_dma_flg; /**< whether or not timeout for DMA(receive) is specified */ + unsigned int read_dma_count; /**< timeout count for DMA(receive) */ + unsigned int write_dma_flg; /**< whether or not timeout for DMA(send) is specified */ + unsigned int write_dma_count; /**< timeout count for DMA(send) */ + unsigned int irqst_clear_flg; /**< Flag that clears IRQ register */ + unsigned int vsync_mode ; + + struct semaphore sys_cmd_sync_send_mutex; /**< mutex for system command */ + + int minor; /**< minor number */ + struct fmb_hard_private* hw_priv_p; /**< pointer to the HW private data */ +}; + + +/********************************************************/ +/* External Function */ +/********************************************************/ +/** + * @brief Clears all DMA channels. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_clear_dma_all( struct fmb_core_private* priv_p ); + +/** + * @brief Clears the DMA channel(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_clear_dma_snd( struct fmb_core_private* priv_p ); + +/** + * @brief Clears the DMA channel(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_clear_dma_rcv( struct fmb_core_private* priv_p ); + +/** + * @brief Enables the DMA channel(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_enable_dma_snd( struct fmb_core_private* priv_p ); + +/** + * @brief Enables the DMA channel(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_enable_dma_rcv( struct fmb_core_private* priv_p ); + +/** + * @brief Dequeues a busy DMA buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return the pointer to the busy DMA buffer + * @note None + * @attention None + */ +struct fmb_dma_buf* Fmb_core_get_busy_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p); + +/** + * @brief Dequeues a free DMA buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return the pointer to the free DMA buffer + * @note None + * @attention None + */ +struct fmb_dma_buf* Fmb_core_get_free_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p); + +/** + * @brief Enqueues the free DMA buffer to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] buf_p the pointer to the free DMA buffer + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_buf* buf_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p); + +/** + * @brief Enqueues the busy DMA buffer to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] buf_p the pointer to the busy DMA buffer + * @param[in] queue_p the pointer to the buffer queue + * @param[in] lock_p the pointer to the spinlock for the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_dma_buf( + struct fmb_core_private* priv_p, + struct fmb_dma_buf* buf_p, + struct fmb_dma_queue* queue_p, + spinlock_t* lock_p); + +/** + * @brief Resets the DMA queue(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock for the DMA queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_dma_queue_snd( struct fmb_core_private* priv_p, + spinlock_t* lock_p ); + +/** + * @brief Resets the DMA queue(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock for the DMA queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_dma_queue_rcv( struct fmb_core_private* priv_p, + spinlock_t* lock_p ); + +/** + * @brief Starts the DMA access(HOST -> LSI). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock + * @return None + * @note None + * @attention None + */ +void Fmb_core_start_dma_snd( + struct fmb_core_private* priv_p, + spinlock_t* lock_p +); + +/** + * @brief Starts the DMA access(LSI -> HOST). + * @param[in] priv_p the pointer to the core private data + * @param[in] lock_p the pointer to the spinlock + * @return None + * @note None + * @attention None + */ +void Fmb_core_start_dma_rcv( + struct fmb_core_private* priv_p, + spinlock_t* lock_p +); + +/** + * @brief Called from the interrupt handler when the interrupt source<br> + * is DMA(HOST->LSI) completion.<br> + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_dma_snd_irq( struct fmb_core_private* priv_p ); + +/** + * @brief Called from the interrupt handler when the interrupt source<br> + * is DMA(LSI->HOST) completion.<br> + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_dma_rcv_irq( struct fmb_core_private* priv_p ); + +/** + * @brief Dequeues a busy system message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy system message buffer + * @note None + * @attention None + */ +struct fmb_sys_msg_buf* + Fmb_core_get_busy_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ); + +/** + * @brief Enqueues the busy system message buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p, + struct fmb_sys_msg_buf* buf_p ); + +/** + * @brief Dequeues a free system message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free system message buffer + * @note None + * @attention None + */ +struct fmb_sys_msg_buf* + Fmb_core_get_free_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ); + +/** + * @brief Enqueues the free system message buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p, + struct fmb_sys_msg_buf* buf_p ); + +/** + * @brief Resets the system message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ); + +/** + * @brief Initializes the system message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_msg_sys_buf( struct fmb_core_private* priv_p, + struct fmb_msg_sys_queue* queue_p ); + +/** + * @brief Dequeues a busy video message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy video message buffer + * @note None + * @attention None + */ +struct fmb_video_msg_buf* + Fmb_core_get_busy_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p ); + +/** + * @brief Enqueues the busy video message buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p, + struct fmb_video_msg_buf* buf_p ); + +/** + * @brief Dequeues a free video message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free video message buffer + * @note None + * @attention None + */ +struct fmb_video_msg_buf* + Fmb_core_get_free_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p ); + +/** + * @brief Enqueues the free video message buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue, + struct fmb_video_msg_buf* buf_p ); + +/** + * @brief Resets the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p); + +/** + * @brief Initializes the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p ); + +/** + * @brief Releases the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attension None + */ +void Fmb_core_release_msg_video_buf( struct fmb_core_private* priv_p, + struct fmb_msg_video_queue* queue_p ); + +/** + * @brief Dequeues a busy audio message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy audio message buffer + * @note None + * @attention None + */ +struct fmb_audio_msg_buf* + Fmb_core_get_busy_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p ); + +/** + * @brief Enqueues the busy audio message buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p, + struct fmb_audio_msg_buf* buf_p ); + +/** + * @brief Dequeues a free audio message buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free audio message buffer + * @note None + * @attention None + */ +struct fmb_audio_msg_buf* + Fmb_core_get_free_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p); + +/** + * @brief Enqueues the free audio message buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio message buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p, + struct fmb_audio_msg_buf* buf_p ); + +/** + * @brief Resets the audio message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p ); + +/** + * @brief Initializes the audio message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p ); + +/** + * @brief Releases the video message buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_msg_audio_buf( struct fmb_core_private* priv_p, + struct fmb_msg_audio_queue* queue_p ); + +/** + * @brief Dequeues a busy system command ACK buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy system command ACK buffer + * @note None + * @attention None + */ +struct fmb_cmd_ack_sys_buf* + Fmb_core_get_busy_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p ); + +/** + * @brief Enqueues the busy system command ACK buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command ACK buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p, + struct fmb_cmd_ack_sys_buf* buf_p ); + +/** + * @brief Dequeues a free system command ACK buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free system command ACK buffer + * @note None + * @attention None + */ +struct fmb_cmd_ack_sys_buf* + Fmb_core_get_free_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p ); + +/** + * @brief Enqueues the free system command ACK buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command ACK buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p, + struct fmb_cmd_ack_sys_buf* buf_p); + +/** + * @brief Resets the system command ACK buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p ); + +/** + * @brief Initializes the system command ACK buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_ack_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_ack_sys_queue* queue_p ); + +/** + * @brief Dequeues a busy xerror info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy xerror info buffer + * @note None + * @attention None + */ +struct fmb_xerror_info_buf* + Fmb_core_get_busy_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p ); + +/** + * @brief Enqueues the busy XERROR info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the XERROR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p, + struct fmb_xerror_info_buf* buf_p ); + +/** + * @brief Dequeues a free XERROR info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free XERROR info buffer + * @note None + * @attention None + */ +struct fmb_xerror_info_buf* + Fmb_core_get_free_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p ); + +/** + * @brief Enqueues the free XERROR info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the XERROR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p, + struct fmb_xerror_info_buf* buf_p ); + +/** + * @brief Resets the XERROR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p ); + +/** + * @brief Initializes the XERROR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 sucsess + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p ); + +/** + * @brief Releases the XERROR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_xerror_info_buf( struct fmb_core_private* priv_p, + struct fmb_xerror_info_queue* queue_p ); + +/** + * @brief Dequeues a busy VUDATA info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy VUDATA info buffer + * @note None + * @attention None + */ +struct fmb_vudata_info_buf* + Fmb_core_get_busy_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p ); + +/** + * @brief Enqueues the busy VUDATA info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the VUDATA info buffer + * @return None + * @note None + * @attention None + */ +void fmb_core_add_busy_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p, + struct fmb_vudata_info_buf* buf_p ); + +/** + * @brief Dequeues a free VUDATA info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free VUDATA info buffer + * @note None + * @attention None + */ +struct fmb_vudata_info_buf* + Fmb_core_get_free_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p ); + +/** + * @brief Enqueues the free VUDATA info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the VUDATA info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p, + struct fmb_vudata_info_buf* buf_p ); + +/** + * @brief Resets the VUDATA info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p ); + +/** + * @brief Initializes the VUDATA info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p ); + +/** + * @brief Releases the VUDATA info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_vudata_buf( struct fmb_core_private* priv_p, + struct fmb_vudata_info_queue* queue_p ); + +/** + * @brief Enqueues the busy EDERR info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the EDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p, + struct fmb_ederr_info_buf* buf_p ); + +/** + * @brief Dequeues a free EDERR info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free EDERR info buffer + * @note None + * @attention None + */ +struct fmb_ederr_info_buf* + Fmb_core_get_free_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p ); + +/** + * @brief Enqueues the free EDERR info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the EDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p, + struct fmb_ederr_info_buf* buf_p ); + +/** + * @brief Resets the EDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p ); + +/** + * @brief Initializes the EDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 sucsess + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p ); + +/** + * @brief Releases the EDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_ederr_info_buf( struct fmb_core_private* priv_p, + struct fmb_ederr_info_queue* queue_p ); + +/** + * @brief Enqueues the busy DDERR info buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the DDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p, + struct fmb_dderr_info_buf* buf_p ); + +/** + * @brief Dequeues a free DDERR info buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free DDERR info buffer + * @note None + * @attention None + */ +struct fmb_dderr_info_buf* + Fmb_core_get_free_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p ); + +/** + * @brief Enqueues the free DDERR info buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the DDERR info buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p, + struct fmb_dderr_info_buf* buf_p ); + +/** + * @brief Resets the DDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p ); + +/** + * @brief Initializes the DDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return 0 sucsess + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_init_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p ); + +/** + * @brief Releases the DDERR info buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_release_dderr_info_buf( struct fmb_core_private* priv_p, + struct fmb_dderr_info_queue* queue_p ); + + + +/** + * @brief Dequeues a busy system command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy system command buffer + * @note None + * @attention None + */ +struct fmb_sys_cmd_buf* + Fmb_core_get_busy_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p ); + +/** + * @brief Enqueues the busy system command buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p, + struct fmb_sys_cmd_buf* buf_p ); + +/** + * @brief Dequeues a free system command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free system command buffer + * @note None + * @attention None + */ +struct fmb_sys_cmd_buf* + Fmb_core_get_free_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p ); + +/** + * @brief Enqueues the free system command buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the system command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p, + struct fmb_sys_cmd_buf* buf_p ); + +/** + * @brief Resets thesystem command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p ); + +/** + * @brief Initializes the system command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_sys_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_sys_queue* queue_p ); + +/** + * @brief Returns the queue head of the busy video command buffer. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the head of the busy queue + * @note None + * @attention None + */ +struct fmb_video_cmd_buf* + Fmb_core_ref_busy_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p); + +/** + * @brief Dequeues a busy video command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy video command buffer + * @note None + * @attention None + */ +struct fmb_video_cmd_buf* + fmb_core_get_busy_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p ); + +/** + * @brief Enqueues the busy video command buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p, + struct fmb_video_cmd_buf* buf_p); + +/** + * @brief Dequeues a free video command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free video command buffer + * @note None + * @attention None + */ +struct fmb_video_cmd_buf* + Fmb_core_get_free_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p ); + +/** + * @brief Enqueues the free video command buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the video command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p, + struct fmb_video_cmd_buf* buf_p); + +/** + * @brief Resets the video command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p ); + +/** + * @brief Initializes the video command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_video_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_video_queue* queue_p ); + +/** + * @brief Dequeues a busy audio command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the busy audio command buffer + * @note None + * @attention None + */ +struct fmb_audio_cmd_buf* + Fmb_core_get_busy_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p ); + +/** + * @brief Enqueues the busy audio command buffer<br> + * to the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_busy_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p, + struct fmb_audio_cmd_buf* buf_p); + +/** + * @brief Dequeues a free audio command buffer from the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return the pointer to the free audio command buffer + * @note None + * @attention None + */ +struct fmb_audio_cmd_buf* + Fmb_core_get_free_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p ); + +/** + * @brief Enqueues the free audio command buffer to <br> + * the buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @param[in] buf_p the pointer to the audio command buffer + * @return None + * @note None + * @attention None + */ +void Fmb_core_add_free_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p, + struct fmb_audio_cmd_buf* buf_p ); + +/** + * @brief Resets the audio command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_reset_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p ); + +/** + * @brief Initializes the audio command buffer queue. + * @param[in] priv_p the pointer to the core private data + * @param[in] queue_p the pointer to the buffer queue + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_cmd_audio_buf( struct fmb_core_private* priv_p, + struct fmb_cmd_audio_queue* queue_p ); + +/** + * @brief Returns the notification kind for received ASYNC notification. + * @param[in] priv_p the pointer to the core private data + * @return factor notification kind.<br> + * The lower 6bits each represents presence(1)/<br> + * absence(0) of particular notification:<br> + * - bit0 : system command ack message<br> + * - bit1 : system message<br> + * - bit2 : video message<br> + * - bit3 : audio message<br> + * - bit4 : xerror message<br> + * - bit5 : vudata message<br> + * @note None + * @attention None + */ +int Fmb_core_get_factor_check( struct fmb_core_private* priv_p ); + +/** + * @brief Resets the private data. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_private_data_reset( struct fmb_core_private* priv_p ); + + + +/** +* @brief set factor_num +* +* @param[in] set value +* @return None +* @note None +* @attension None +*/ +void Fmb_core_set_factor_num( struct fmb_core_private* priv_p, int val ); + +/** +* @brief get factor_num +* +* @param None +* @return factor_num +* @note None +* @attension None +*/ +int Fmb_core_get_factor_num( struct fmb_core_private* priv_p ); + + + + +/** + * @brief Interrupt handler for a XERROR interrupt from the MB86 LSI. + * @param[in] the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_xerror_irq( struct fmb_core_private* priv_p ); + + +/** + * @brief Interrupt handler for a INT interrupt from the MB86 LSI. + * @param[in] the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_int_irq( struct fmb_core_private* priv_p ); + +/** + * @brief Interrupt handler for a EDERR interrupt from the MB86 LSI. + * @param[in] the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_ederr_irq( struct fmb_core_private* priv_p ); + +/** + * @brief Interrupt handler for a DDERR interrupt from the MB86 LSI. + * @param[in] the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_dderr_irq( struct fmb_core_private* priv_p ); + + + +/** + * @brief The MB86-LSI part of the probe function. + * @param[in] hw_priv_p the pointer to the HW private data + * @return 0 success + * @return -1 fail + * @note None + * @attention None + */ +int Fmb_core_probe( struct fmb_hard_private* hw_priv_p ); + + +/** + * @brief Kills tasklets and releases the core private data. + * @param[in] priv_p the pointer to the core private data + * @return None + * @note None + * @attention None + */ +void Fmb_core_remove( struct fmb_core_private* priv_p ); + + +/** + * @brief The MB86-LSI part of the init_module function. + * @param None + * @return None + * @note None + * @attention None + */ +void Fmb_core_init_module( void ); + + +#endif /* ifndef __FMB_CORE_H__ */ diff --git a/fmb_driver/fmb_drv.h b/fmb_driver/fmb_drv.h new file mode 100644 index 0000000..659ad11 --- /dev/null +++ b/fmb_driver/fmb_drv.h @@ -0,0 +1,264 @@ +/** +* @brief User API definition header file for MB86 LSI Linux driver. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +/****************************************************************************/ +#ifndef __FMB_DRV_H__ +#define __FMB_DRV_H__ + + +/********************************************************/ +/* ioctl Constant definition */ +/********************************************************/ +/* System command sync mode */ +#define FMB_MODE_SYNC 0 +#define FMB_MODE_ASYNC 1 + +/* Async commnad buffer */ +#define FMB_CMD_INFO_NONE 0x00000000 /* (bit0000_0000) */ +#define FMB_CMD_INFO_SYS 0x00000001 /* (bit0000_0001) */ +#define FMB_CMD_INFO_VIDEO 0x00000002 /* (bit0000_0010) */ +#define FMB_CMD_INFO_AUDIO 0x00000004 /* (bit0000_0100) */ +#define FMB_CMD_INFO_ALL 0x00000007 /* (bit0000_0111) */ + +/* Async notification factor */ +#define FMB_FACTOR_NONE 0x00000000 /* (bit0000_0000) */ +#define FMB_FACTOR_CACK_SYS 0x00000001 /* (bit0000_0001) */ +#define FMB_FACTOR_MSG_SYS 0x00000002 /* (bit0000_0010) */ +#define FMB_FACTOR_MSG_VIDEO 0x00000004 /* (bit0000_0100) */ +#define FMB_FACTOR_MSG_AUDIO 0x00000008 /* (bit0000_1000) */ +#define FMB_FACTOR_XERROR 0x00000010 /* (bit0001_0000) */ +#define FMB_FACTOR_VUDATA 0x00000020 /* (bit0010_0000) */ +#define FMB_FACTOR_EDERR 0x00000040 /* (bit0100_0000) */ +#define FMB_FACTOR_DDERR 0x00000080 /* (bit1000_0000) */ +#define FMB_FACTOR_ASYNC_ALL 0x000000FF /* (bit1111_1111) */ + +/* Low Level mode only */ +/* IRQ notification factor */ +//#define FMB_FACTOR_NONE 0x00000000 /* (bit0000_0000) */ +#define FMB_FACTOR_TCPU 0x00000001 /* (bit0000_0001) */ +#define FMB_FACTOR_TACK 0x00000002 /* (bit0000_0010) */ +#define FMB_FACTOR_VSYNC 0x00000004 /* (bit0000_0100) */ +#define FMB_FACTOR_VBIT 0x00000008 /* (bit0000_1000) */ +#define FMB_FACTOR_XERROR 0x00000010 /* (bit0001_0000) */ +#define FMB_FACTOR_IRQ_ALL 0x0000001F /* (bit0001_1111) */ + +/* Async factor type */ +#define FMB_TYPE_ASYNC_XERROR 0 +#define FMB_TYPE_ASYNC_VUDATA 1 + +/* MB86-API PCI register type */ +#define FMB_TYPE_DMA 0x00000000 +#define FMB_TYPE_LSI 0x00000001 + +/* Driver Internal mode */ + + +#define FMB_DATA_TYPE_ENCODE 0x00000001 +#define FMB_DATA_TYPE_NOTIFY 0x00000002 +#define FMB_DATA_TYPE_RDMAFLAG 0x00000003 +#define FMB_DATA_TYPE_WDMAFLAG 0x00000004 +#define FMB_DATA_TYPE_IRQSTFLAG 0x00000005 +#define FMB_DATA_TYPE_VSYNC 0x00000006 + + +#define FMB_DATA_ENCODE_TOP 0x00000000 +#define FMB_DATA_ENCODE_BOTTOM 0x00000001 + +#define FMB_DATA_NOTIFY_NONE 0x00000000 /* (bit0000_0000) */ +#define FMB_DATA_NOTIFY_SYS 0x00000001 /* (bit0000_0001) */ +#define FMB_DATA_NOTIFY_VIDEO 0x00000002 /* (bit0000_0010) */ +#define FMB_DATA_NOTIFY_AUDIO 0x00000004 /* (bit0000_0100) */ +#define FMB_DATA_NOTIFY_VUDATA 0x00000008 /* (bit0000_1000) */ +#define FMB_DATA_NOTIFY_ALL 0x0000000F /* (bit0000_1111) */ + + +#define FMB_DATA_DMAFLAG_OFF 0x00000000 +#define FMB_DATA_DMAFLAG_ON 0x00000001 + +#define FMB_DATA_IRQSTFLAG_ON 0x00000000 +#define FMB_DATA_IRQSTFLAG_OFF 0x00000001 + +#define FMB_DATA_VSYNC_ALL 0x00000000 +#define FMB_DATA_VSYNC_TOP 0x00000001 +#define FMB_DATA_VSYNC_BOTTOM 0x00000002 + + + +/* Driver Command Message buffers define */ +#define FMB_MSG_BUF_SIZE 64 +#define FMB_CMD_BUF_SIZE 320 + +#define FMB_SYS_MSG_REG_SIZE 0x10 +#define FMB_VIDEO_MSG_REG_SIZE 0xC0 +#define FMB_AUDIO_MSG_REG_SIZE 0x60 +#define FMB_VUDATA_INFO_REG_SIZE 0x100 +#define FMB_XERROR_INFO_REG_SIZE 0x10 +#define FMB_EDERR_INFO_REG_SIZE 0x10 +#define FMB_DDERR_INFO_REG_SIZE 0x10 + +#define FMB_VERSION_REG_SIZE 0x10 +#define FMB_DRIVER_VERSION_LENGTH 0x8 + +/* interrput type */ +#define IRQ_FMB_DMA 0x00000001 +#define IRQ_FMB_INT 0x00000002 +#define IRQ_FMB_XERROR 0x00000003 +#define IRQ_FMB_EDERR 0x00000004 +#define IRQ_FMB_DDERR 0x00000005 + +/********************************************************/ +/* ioctl Structure definition */ +/********************************************************/ + +struct fmb_param_info { + unsigned long prm_num; + unsigned long* prm_id; + unsigned short* prm_data; +}; + +struct fmb_ctl_param_info { + int type; + unsigned short* data; +}; + +struct fmb_cmd_sys_info { + unsigned short id; + unsigned short sub_id; + unsigned short body; + unsigned short sync; + void* distinct; +}; + +struct fmb_cmd_video_info { + unsigned long cprm_num; + unsigned long* cprm_id; + unsigned short* cprm_data; +}; + +struct fmb_cmd_audio_info { + unsigned long cprm_num; + unsigned long* cprm_id; + unsigned short* cprm_data; +}; + +struct fmb_cmd_ack_sys_info { + unsigned short id; + unsigned short sub_id; + long timeout; + void* distinct; +}; + +struct fmb_cmd_info_reset { + unsigned long type; +}; + +struct fmb_msg_sys_info { + unsigned short id; + unsigned short sub_id; + unsigned short body; + long timeout; +}; + +struct fmb_msg_video_info { + unsigned short* msg; + long timeout; +}; + +struct fmb_msg_audio_info { + unsigned short* msg; + long timeout; +}; + +struct fmb_firm_info { + unsigned long firm_size; + unsigned char* firm_data; +}; + +struct fmb_factor_info { + unsigned long factor; + long timeout; +}; + +struct fmb_factor_reset { + unsigned long factor; +}; + +struct fmb_async_info { + unsigned long type; + unsigned short* data; + long timeout; +}; + +struct fmb_reg_info { + unsigned long reg_num; + unsigned long offset; + unsigned short* prm_data; +}; + + +struct fmb_internal_info { + unsigned long type; + unsigned long data; +}; + +struct fmb_pci_reg_info { + unsigned long reg_type; + unsigned long reg_num; + unsigned long offset; + unsigned long* prm_data; +}; + +struct fmb_version_info { + char* driver_ver; + unsigned short* firm_ver; +}; + +struct fmb_bootup_firm_info { + long timeout; +}; + + +/********************************************************/ +/* ioctl Command definition */ +/********************************************************/ + +#define FMB_DEV_TYPE 0xAE + +#define FMB_API_GET_PARAM _IOR (FMB_DEV_TYPE, 1, struct fmb_param_info) +#define FMB_API_SET_PARAM _IOWR(FMB_DEV_TYPE, 2, struct fmb_param_info) +#define FMB_API_SEND_SYS_CMD _IOWR(FMB_DEV_TYPE, 3, struct fmb_cmd_sys_info) +#define FMB_API_SEND_VIDEO_CMD _IOW (FMB_DEV_TYPE, 4, struct fmb_cmd_video_info) +#define FMB_API_SEND_AUDIO_CMD _IOW (FMB_DEV_TYPE, 5, struct fmb_cmd_audio_info) +#define FMB_API_GET_SYS_CMD_ACK _IOR (FMB_DEV_TYPE, 6, struct fmb_cmd_ack_sys_info) +#define FMB_API_RESET_CMD_INFO _IOR (FMB_DEV_TYPE, 7, struct fmb_cmd_info_reset) +#define FMB_API_GET_SYS_MSG _IOR (FMB_DEV_TYPE, 8, struct fmb_msg_sys_info) +#define FMB_API_GET_VIDEO_MSG _IOR (FMB_DEV_TYPE, 9, struct fmb_msg_video_info) +#define FMB_API_GET_AUDIO_MSG _IOR (FMB_DEV_TYPE, 10, struct fmb_msg_audio_info) +#define FMB_API_INIT_PREPARE_FIRM _IO (FMB_DEV_TYPE, 11) +#define FMB_API_WRITE_FIRM _IOW (FMB_DEV_TYPE, 12, struct fmb_firm_info) +#define FMB_API_BOOT_UP_FIRM _IOWR(FMB_DEV_TYPE, 13, struct fmb_bootup_firm_info) +#define FMB_API_GET_FACTOR _IOR (FMB_DEV_TYPE, 14, struct fmb_factor_info) +#define FMB_API_RESET_FACTOR _IOR (FMB_DEV_TYPE, 15, struct fmb_factor_reset) +#define FMB_API_GET_ASYNC_INFO _IOR (FMB_DEV_TYPE, 16, struct fmb_async_info) +#define FMB_API_GET_LSI_REG _IOR (FMB_DEV_TYPE, 17, struct fmb_reg_info) +#define FMB_API_SET_LSI_REG _IOW (FMB_DEV_TYPE, 18, struct fmb_reg_info) +#define FMB_API_GET_INTERNAL_DATA _IOR (FMB_DEV_TYPE, 19, struct fmb_internal_info) +#define FMB_API_SET_INTERNAL_DATA _IOW (FMB_DEV_TYPE, 20, struct fmb_internal_info) +#define FMB_API_GET_PCI_REG _IOR (FMB_DEV_TYPE, 21, struct fmb_pci_reg_info) +#define FMB_API_SET_PCI_REG _IOW (FMB_DEV_TYPE, 22, struct fmb_pci_reg_info) +#define FMB_API_GET_VERSION _IOR (FMB_DEV_TYPE, 23, struct fmb_version_info) + + +#endif /* ifndef __FMB_DRV_H__ */ diff --git a/fmb_driver/fmb_hw.c b/fmb_driver/fmb_hw.c new file mode 100644 index 0000000..4a63b2f --- /dev/null +++ b/fmb_driver/fmb_hw.c @@ -0,0 +1,1508 @@ +/** +* @brief Hardware dependence part class for fmb Linux driver +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +/****************************************************************************/ +#include "fmb.h" +#include "fmb_core.h" +#include "fmb_api.h" + +#ifndef VERSION +#define VERSION "?.?.?.?" +#endif + +/********************************************************/ +/* FUNCTION PROTOTYPE */ +/********************************************************/ + +PREPARE_DEBUG(); + +MODULE_LICENSE( "GPL" ); +MODULE_DESCRIPTION( "MB86_Driver" ); +DECLARE_MUTEX( sm ); + +/********************************************************/ +/* GROBAL VALUES */ +/********************************************************/ +static struct fmb_hard_private s_Fmb_hard_private_list[FMB_MAX_CARDS]; +static int s_Fmb_cards_active = 0; +static int s_Fmb_driver_version_major; +static spinlock_t s_Fmb_hw_lock = SPIN_LOCK_UNLOCKED; +static dev_t s_dev; +/********************************************************/ +/* */ +/* register processing function */ +/* */ +/********************************************************/ +/** +* @brief Register Read to DMA +* @param[in] priv_p private data pointer +* @param[in] addr DMA register address +* @return val register read value +* @note None +* @attention None +*/ + +unsigned long Fmb_hw_reg_read_dma(struct fmb_hard_private* priv_p, unsigned long addr) +{ + int minor; + unsigned long val; + + minor = priv_p->minor; + val = 0; + + MSG(DEBUG_LVL, minor, "START"); + + if (!priv_p->dma_base) { + MSG(INTERNAL_ERR_LVL, minor, "Address is not dma"); + return 0; + } + val = inl(priv_p->dma_base + addr); + + MSG(CODEC_LVL, minor, "read BAR0 offset(0x%.2lx) = 0x%lx", addr, val); + MSG(DEBUG_LVL, minor, "dma offset = 0x%lx", addr); + MSG(DEBUG_LVL, minor, "END"); + return val; +} + + +/** +* @brief Register Write to DMA +* @param[in] priv_p private data pointer +* @param[in] addr DMA register address +* @param[in] data register write value +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_reg_write_dma(struct fmb_hard_private* priv_p, unsigned long addr, unsigned long data) +{ + int minor; + minor = priv_p->minor; + + MSG(INTERNAL_FUNC, minor, "START"); + + if (!priv_p->dma_base) { + MSG(INTERNAL_ERR_LVL, minor, "Address is not dma"); + return; + } + outl(data, (priv_p->dma_base + addr)); + MSG(CODEC_LVL, minor, "write BAR0 offset(0x%.2lx) = 0x%lx", addr, data); + MSG(DEBUG_LVL, minor, "dma offset = 0x%lx", addr); + MSG(INTERNAL_FUNC, minor, "END"); +} + +/** +* @brief Register Read to LSI +* @param[in] priv_p private data pointer +* @param[in] addr LSI register address +* @return val register read value +* @note None +* @attention None +*/ + +unsigned short Fmb_hw_reg_read_lsi(struct fmb_hard_private* priv_p, unsigned long addr) +{ + int minor; + int retry; + unsigned long val; + unsigned long flags; + unsigned long intcsr; + unsigned long fRetryError; + + minor = priv_p->minor; + retry = 5; + val = 0; + fRetryError = 0; + + MSG(INTERNAL_FUNC, minor, "START"); + + spin_lock_irqsave(&priv_p->core_reg_lock, flags); + if (!priv_p->core_base) { + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Address is not core"); + return 0; + } + while (retry) { + val = ioread32( (void*)(priv_p->core_base + (addr*2)) ); + MSG(CODEC_LVL, minor, "read BAR1 offset(0x%.6lx) = 0x%lx", (addr*2), val); + MSG(DEBUG_LVL, minor, "lsi offset = 0x%lx", addr); + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000040) { + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x00000040); + fRetryError = 1; + retry--; + MSG(DEBUG_LVL, minor, "Target 256 Retry Error being checked"); + continue; + } + break; + } + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_FUNC, minor, "END"); + return (unsigned short)val; +} + + + +/** +* @brief Register Write to LSI +* @param[in] priv_p private data pointer +* @param[in] addr LSI register address +* @param[in] data register write value +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_reg_write_lsi(struct fmb_hard_private* priv_p, unsigned long addr, unsigned short data) +{ + int minor; + int retry; + unsigned long val; + unsigned long flags; + unsigned long intcsr; + unsigned long fRetryError; + + minor = priv_p->minor; + retry = 5; + val = 0; + fRetryError = 0; + + MSG(DEBUG_LVL, minor, "START"); + + spin_lock_irqsave(&priv_p->core_reg_lock, flags); + val = (unsigned long)data; + if (!priv_p->core_base) { + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Address is not core"); + return; + } + while (retry) { + iowrite32((u32)data, (void*)(priv_p->core_base + (addr*2)) ); + MSG(CODEC_LVL, minor, "write BAR1 offset(0x%.6lx) = 0x%x", (addr*2), data); + MSG(DEBUG_LVL, minor, "lsi offset = 0x%lx", addr); + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000040) { + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x00000040); + fRetryError = 1; + retry--; + MSG(DEBUG_LVL, minor, "Target 256 Retry Error being checked"); + continue; + } + break; + } + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(DEBUG_LVL, minor, "END"); +} + + +/** +* @brief Register Read to LSI Enhancing master +* @param[in] priv_p private data pointer +* @param[in] addr LSI Enhancing master register address +* @return val register read value +* @note None +* @attention None +*/ + +unsigned long Fmb_hw_reg_read_lsi_master(struct fmb_hard_private* priv_p, unsigned long addr) +{ + int minor; + int retry; + unsigned long val; + unsigned long flags; + unsigned long intcsr; + unsigned long fRetryError; + + minor = priv_p->minor; + retry = 5; + val = 0; + fRetryError = 0; + + MSG(INTERNAL_LOG, minor, "START"); + + spin_lock_irqsave(&priv_p->core_reg_lock, flags); + if (!priv_p->core_base) { + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Address is not core"); + return 0; + } + while (retry) { + val = ioread32( (void*)(priv_p->core_base + addr) ); + MSG(CODEC_LVL, minor, "read BAR1 offset(0x%.6lx) = 0x%lx", addr, val); + MSG(DEBUG_LVL, minor, "lsi offset = 0x%lx", addr); + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000040) { + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x00000040); + fRetryError = 1; + retry--; + MSG(DEBUG_LVL, minor, "Target 256 Retry Error being checked"); + continue; + } + break; + } + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_LOG, minor, "END"); + return val; +} + + +/** +* @brief Register Write to LSI Enhancing master +* @param[in] priv_p private data pointer +* @param[in] addr LSI Enhancing master register address +* @param[in] data register write value +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_reg_write_lsi_master(struct fmb_hard_private* priv_p, unsigned long addr, unsigned long data) +{ + int minor; + int retry; + unsigned long flags; + unsigned long intcsr; + unsigned long fRetryError; + + minor = priv_p->minor; + retry = 5; + fRetryError = 0; + + MSG(INTERNAL_LOG, minor, "START"); + + spin_lock_irqsave(&priv_p->core_reg_lock, flags); + if (!priv_p->core_base) { + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Address is not core"); + return; + } + while (retry) { + iowrite32((u32)data, (void*)(priv_p->core_base + addr) ); + MSG(CODEC_LVL, minor, "write BAR1 offset(0x%.6lx) = 0x%lx", addr, data); + MSG(DEBUG_LVL, minor, "lsi offset = 0x%lx", addr); + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000040) { + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x00000040); + fRetryError = 1; + retry--; + MSG(DEBUG_LVL, minor, "Target 256 Retry Error being checked"); + continue; + } + break; + } + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_LOG, minor, "END"); +} + +/** +* @brief Register Read Modfi Write to LSI +* @param[in] priv_p private data pointer +* @param[in] addr LSI register address +* @param[in] shift shift value at the time of writing +* @param[in] mask mask value at the time of writing +* @param[in] data register write value +* @return val register read value +* @note None +* @attention None +*/ + +unsigned short Fmb_hw_reg_rmw_lsi(struct fmb_hard_private* priv_p, unsigned long addr, unsigned short shift, + unsigned short mask, unsigned short data) +{ + int minor; + int retry; + unsigned long val; + unsigned long intcsr; + unsigned long flags; + unsigned long shift_tmp; + unsigned long mask_tmp; + unsigned long data_tmp; + unsigned long fRetryError; + + minor = priv_p->minor; + retry = 5; + shift_tmp = 0; + mask_tmp = 0; + data_tmp = 0; + fRetryError = 0; + + MSG(INTERNAL_FUNC, minor, "START"); + + spin_lock_irqsave(&priv_p->core_reg_lock, flags); + shift_tmp = (unsigned long)shift; + mask_tmp = (unsigned long)mask; + data_tmp = (unsigned long)data; + + if (!priv_p->core_base) { + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_ERR_LVL, minor, "Address is not core"); + return 0; + } + while (retry) { + val = ioread32( (void*)(priv_p->core_base + (addr*2)) ); + MSG(CODEC_LVL, minor, "read BAR1 offset(0x%.6lx) = 0x%lx", (addr*2), val); + val &= ~(mask_tmp << shift_tmp); /* clear pertinent bit */ + val |= ((data_tmp & mask_tmp) << shift_tmp); /* set pertinent bit */ + iowrite32((u32)val, (void*)(priv_p->core_base + (addr*2)) ); + MSG(CODEC_LVL, minor, "write BAR1 offset(0x%.6lx) = 0x%lx", (addr*2), val); + MSG(DEBUG_LVL, minor, "lsi offset = 0x%lx", addr); + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000040) { + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x00000040); + fRetryError = 1; + retry--; + MSG(DEBUG_LVL, minor, "Target 256 Retry Error being checked"); + continue; + } + break; + } + spin_unlock_irqrestore(&priv_p->core_reg_lock, flags); + MSG(INTERNAL_FUNC, minor, "END"); + return (unsigned short)val; +} + +/** +* @brief Check access area for lsi +* @param[in] priv_p private data pointer +* @param[in] offset_addr offset address to specified PCI +* @param[in] access_size Size of access area +* @return 0 Normal end +* @return -EINVAL The content of the parameter is illegal. +* @note None +* @attention None +*/ + +int Fmb_hw_check_addr_lsi(struct fmb_hard_private* priv_p, unsigned long offset_addr, unsigned long access_size) +{ + int minor; + unsigned long tail_addr; + + minor = priv_p->minor; + + MSG(INTERNAL_FUNC, minor, "START"); + + tail_addr = (offset_addr + access_size)*2; + if ((offset_addr*2) > FMB_CORE_LSI_SIZE) { + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + if (tail_addr > FMB_CORE_LSI_SIZE) { + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + MSG(INTERNAL_FUNC, minor, "END"); + return 0; +} + + +/** +* @brief Check access area for PCI +* @param[in] priv_p private data pointer +* @param[in] pci_type Type of specified PCI (Not used) +* @param[in] offset_addr offset address to specified PCI +* @param[in] access_size Size of access area +* @return 0 Normal end +* @return -EINVAL The content of the parameter is illegal. +* @note None +* @attention None +*/ + +int Fmb_hw_check_addr_pci(struct fmb_hard_private* priv_p, unsigned long pci_type, unsigned long offset_addr, + unsigned long access_size) +{ + int minor; + unsigned long tail_addr; + + minor = priv_p->minor; + + MSG(INTERNAL_LOG, minor, "START"); + + tail_addr = offset_addr + access_size; + switch (pci_type){ + case FMB_TYPE_DMA: + if (offset_addr >= FMB_DMA_SIZE) { + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + if (tail_addr >= FMB_DMA_SIZE) { + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + break; + case FMB_TYPE_LSI: + if (offset_addr < 0x1E0000){ + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + if (offset_addr >= FMB_CORE_SIZE) { + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + if (tail_addr >= FMB_CORE_SIZE) { + MSG(INTERNAL_ERR_LVL, minor, "Specified address is abnormal."); + return -EINVAL; + } + break; + default: + MSG(INTERNAL_ERR_LVL, minor, "invalid type"); + return -EINVAL; + } + MSG(INTERNAL_LOG, minor, "END"); + return 0; +} + +/********************************************************/ +/* */ +/* PCI(Interrupt) processing function */ +/* */ +/********************************************************/ +/** +* @brief DMA/LSI Clear Interrupt +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_clear_irq(struct fmb_hard_private* priv_p ) +{ + int minor; + unsigned long imask; + unsigned long intcsr; + unsigned long dmacsr; + unsigned long fpciintst; + unsigned short irqst; + + minor = priv_p->minor; + + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_FUNC, minor, "START"); + + local_irq_save(imask); + local_irq_disable(); + + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000010) { + /* DMA ch0 */ + dmacsr = Fmb_hw_reg_read_dma(priv_p, DMA0CMDSTS); + dmacsr |= 0x8; + Fmb_hw_reg_write_dma(priv_p, DMA0CMDSTS, dmacsr); + MSG(DEBUG_LVL, minor, "DMA ch0 clear"); + } + + if (intcsr & 0x00000020) { + /* DMA ch1 */ + dmacsr = Fmb_hw_reg_read_dma(priv_p, DMA1CMDSTS); + dmacsr |= 0x8; + Fmb_hw_reg_write_dma(priv_p, DMA1CMDSTS, dmacsr); + MSG(DEBUG_LVL, minor, "DMA ch1 clear"); + } + + if (intcsr & 0x00000001) { + /* LXINT */ + fpciintst = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTST); + + if (fpciintst & FPCI_INTMASK_INT) { + irqst = Fmb_hw_reg_read_lsi(priv_p, FMB_API_IRQST_ALL); + + irqst &= (API_IRQST_TCPU_CMD | API_IRQST_TACK_CMD | API_IRQST_VSYNC_CMD); + Fmb_hw_reg_write_lsi(priv_p, FMB_API_IRQST_ALL, irqst); + MSG(DEBUG_LVL, minor, "INT clear"); + } + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTST, fpciintst); + MSG(DEBUG_LVL, minor, "LXINT clear"); + } + local_irq_restore(imask); + local_irq_enable(); + MSG(INTERNAL_FUNC, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); +} + + +/** +* @brief DMA/LSI Enable Interrupt +* @param[in] priv_p private data pointer +* @param[in] irq_type irq type +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_enable_irq(struct fmb_hard_private* priv_p, int irq_type ) +{ + int minor; + unsigned long val; + unsigned long flags; + + minor = priv_p->minor; + val = 0; + + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_FUNC, minor, "START"); + + switch (irq_type) { + /* DMA */ + case IRQ_FMB_DMA: + spin_lock_irqsave(&priv_p->dma_reg_lock, flags); + val = Fmb_hw_reg_read_dma(priv_p, INTENABLE); + val |= 0x00000031; + Fmb_hw_reg_write_dma(priv_p, INTENABLE, val); + spin_unlock_irqrestore(&priv_p->dma_reg_lock, flags); + MSG(DEBUG_LVL, minor, "DMA enable"); + break; + + /* LSI */ + /* INT */ + case IRQ_FMB_INT: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val |= FPCI_INTMASK_INT; + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + Fmb_hw_reg_write_lsi(priv_p, FMB_API_HCPU_IRQEN_TCPU, API_IRQST_TCPU_CMD | API_IRQST_TACK_CMD | API_IRQST_VSYNC_CMD); + MSG(DEBUG_LVL, minor, "INT enable"); + break; + + /* XERROR */ + case IRQ_FMB_XERROR: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val |= 0x80000000; + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + MSG(DEBUG_LVL, minor, "XERROR enable"); + break; + + /* EDERR */ + case IRQ_FMB_EDERR: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val |= 0x00400000; + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + MSG(DEBUG_LVL, minor, "EDERR enable"); + break; + + /* DDERR */ + case IRQ_FMB_DDERR: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val |= 0x00040000; + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + MSG(DEBUG_LVL, minor, "DDERR enable"); + break; + + default: + break; + } + MSG(INTERNAL_FUNC, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); +} + +/** +* @brief DMA/LSI Disable Interrupt Vector +* @param[in] priv_p private data pointer +* @param[in] irq_type irq type +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_disable_irq(struct fmb_hard_private* priv_p, int irq_type) +{ + int minor; + unsigned long val; + unsigned long flags; + + minor = priv_p->minor; + val = 0; + + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_FUNC, minor, "START"); + + switch (irq_type) { + /* DMA */ + case IRQ_FMB_DMA: + spin_lock_irqsave(&priv_p->dma_reg_lock, flags); + val = Fmb_hw_reg_read_dma(priv_p, INTENABLE); + val &= ~(0x00000030); + Fmb_hw_reg_write_dma(priv_p, INTENABLE, val); + spin_unlock_irqrestore(&priv_p->dma_reg_lock, flags); + MSG(DEBUG_LVL, minor, "DMA disable"); + break; + + /* LSI */ + /* INT */ + case IRQ_FMB_INT: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val &= ~(FPCI_INTMASK_INT); + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + Fmb_hw_reg_write_lsi(priv_p, FMB_API_HCPU_IRQEN_TCPU, 0x0000); + MSG(DEBUG_LVL, minor, "INT disable"); + break; + + /* XERROR */ + case IRQ_FMB_XERROR: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val &= ~(0x80000000); + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + MSG(DEBUG_LVL, minor, "XERROR disable"); + break; + + /* EDERR */ + case IRQ_FMB_EDERR: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val &= ~(0x00400000); + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + MSG(DEBUG_LVL, minor, "EDERR disable"); + break; + + /* DDERR */ + case IRQ_FMB_DDERR: + val = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTEN); + val &= ~(0x00040000); + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTEN, val); + MSG(DEBUG_LVL, minor, "DDERR disable"); + break; + + default: + break; + } + MSG(INTERNAL_FUNC, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); +} + +/** +* @brief FMB Hardware interrupt initialize +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +static void fmb_hw_irq_init(struct fmb_hard_private* priv_p) +{ + int minor; + + minor = priv_p->minor; + + MSG(INTERNAL_LOG, minor, "START"); + + Fmb_hw_disable_irq(priv_p, IRQ_FMB_DMA); + Fmb_hw_disable_irq(priv_p, IRQ_FMB_INT); + Fmb_hw_disable_irq(priv_p, IRQ_FMB_XERROR); + Fmb_hw_disable_irq(priv_p, IRQ_FMB_EDERR); + Fmb_hw_disable_irq(priv_p, IRQ_FMB_DDERR); + + MSG(INTERNAL_LOG, minor, "END"); +} + +/********************************************************/ +/* */ +/* Hardware dependence initialization function */ +/* */ +/********************************************************/ + +/** +* @brief FMB Hardware PCI Memory mapping +* @param[in] priv_p private data pointer +* @return 0 normal end +* @note None +* @attention None +*/ + +static int fmb_hw_memmap(struct fmb_hard_private* priv_p) +{ + int minor; + unsigned long phyaddr; + + minor = priv_p->minor; + + MSG(INTERNAL_LOG, minor, "START"); + + /* BAR0 */ + if (!request_region(pci_resource_start(priv_p->pci_dev_p, 0), + pci_resource_len(priv_p->pci_dev_p, 0), FMB_DRIVER_NAME)) + { + MSG(KERN_ERR_LVL, minor, "Cannot reserve I/O ports(BAR0)"); + goto err_out_disable; + } + priv_p->dma_base = pci_resource_start(priv_p->pci_dev_p, 0); + MSG(DEBUG_LVL, minor, "Reservation success I/O ports(BAR0)"); + + /* BAR1 */ + if (!request_mem_region(pci_resource_start(priv_p->pci_dev_p, 1), + pci_resource_len(priv_p->pci_dev_p, 1), FMB_DRIVER_NAME)) + { + MSG(KERN_ERR_LVL, minor, "Cannot reserve MMIO region(BAR1)"); + goto err_out_free_pio_region; + } + phyaddr = pci_resource_start(priv_p->pci_dev_p, 1); + priv_p->core_base = (unsigned long)ioremap(phyaddr,FMB_CORE_SIZE); + MSG(DEBUG_LVL, minor, "Reservation success MMIO region(BAR1)"); + + MSG(RESOURCE_LVL, minor, "# address map"); + MSG(RESOURCE_LVL, minor, "# FMB DMA : L:0x%lx", + priv_p->dma_base); + + MSG(RESOURCE_LVL, minor, "# FMB LSI : L:0x%lx S:0x%08x", + priv_p->core_base, + FMB_CORE_SIZE); + + MSG(INTERNAL_LOG, minor, "END"); + return 0; + +err_out_disable: + pci_disable_device(priv_p->pci_dev_p); + return -1; +err_out_free_pio_region: + release_region(pci_resource_start(priv_p->pci_dev_p, 0), pci_resource_len(priv_p->pci_dev_p, 0)); + return -1; +} + +/** +* @brief FMB Hardware PCI UnMemory mapping +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +static void fmb_hw_unmemmap(struct fmb_hard_private* priv_p) +{ + int minor; + + minor = priv_p->minor; + + MSG(INTERNAL_LOG, minor, "START"); + + /* BAR1 */ + iounmap((void*)priv_p->core_base); + release_mem_region(pci_resource_start(priv_p->pci_dev_p, 1), pci_resource_len(priv_p->pci_dev_p, 1)); + /* BAR0 */ + release_region(pci_resource_start(priv_p->pci_dev_p, 0), pci_resource_len(priv_p->pci_dev_p, 0)); + + MSG(INTERNAL_LOG, minor, "END"); +} + +/** +* @brief FMB Codec Lsi Initialize +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_codec_lsi_init(struct fmb_hard_private* priv_p) +{ + int minor; + + minor = priv_p->minor; + + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_FUNC, minor, "START"); + + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CNT, 0x00000003); + + mdelay(FMB_CARD_RESET_DELAY_TIME1); /* wait 1ms */ + + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CNT, 0x00000002); + + mdelay(FMB_CARD_RESET_DELAY_TIME1); /* wait 1ms */ + + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CODEC_CNT, 0x00000000); + + mdelay(FMB_CARD_RESET_DELAY_TIME1); /* wait 1ms */ + + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CODEC_CNT, 0x00000002); + + mdelay(FMB_CARD_RESET_DELAY_TIME1); /* wait 1ms */ + + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CODEC_CNT, 0x00000003); + + mdelay(FMB_CARD_RESET_DELAY_TIME2); /* wait 500ms */ + + + MSG(INTERNAL_FUNC, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); +} + +/** +* @brief PCI Card Reset +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +static void fmb_card_reset(struct fmb_hard_private* priv_p) +{ + int minor; + + minor = priv_p->minor; + + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_LOG, minor, "START"); + + Fmb_hw_reg_write_dma(priv_p, INTENABLE, 0x00000000); + Fmb_hw_reg_write_dma(priv_p, TCSTATUS, 0x80000000); + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x000000C0); + Fmb_hw_reg_write_dma(priv_p, TCSTATUS, 0x80000000); + Fmb_hw_reg_write_dma(priv_p, INTSOURCE, 0x000000C0); + + Fmb_hw_reg_write_dma(priv_p, DMA0CMDSTS, 0x00000704); + Fmb_hw_reg_write_dma(priv_p, DMA0CMDSTS, 0x00000708); + Fmb_hw_reg_write_dma(priv_p, DMA0CMDSTS, 0x00000700); + Fmb_hw_reg_write_dma(priv_p, DMA1CMDSTS, 0x00000604); + Fmb_hw_reg_write_dma(priv_p, DMA1CMDSTS, 0x00000608); + Fmb_hw_reg_write_dma(priv_p, DMA1CMDSTS, 0x00000600); + + MSG(INTERNAL_LOG, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); +} + + +/** +* @brief PCI Card Powerdown +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +static void fmb_card_powerdown( struct fmb_hard_private* priv_p) +{ + int minor; + + minor = priv_p->minor; + + MSG(CODEC_FUNC, minor, "START"); + MSG(INTERNAL_LOG, minor, "START"); + + Fmb_hw_reg_write_dma(priv_p, INTENABLE, 0x00000000); + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CODEC_CNT, 0x00000000); + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_CNT,0x00000000); + + MSG(INTERNAL_LOG, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); +} + + +/** +* @brief FMB Hardware Private Data initialize +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +static void fmb_hw_private_data_init(struct fmb_hard_private* priv_p) +{ + int minor; + unsigned char pci_latency; + + minor = priv_p->minor; + + MSG(INTERNAL_LOG, minor, "START"); + + priv_p->lock_hw_priv = SPIN_LOCK_UNLOCKED; + priv_p->dma_reg_lock = SPIN_LOCK_UNLOCKED; + priv_p->core_reg_lock = SPIN_LOCK_UNLOCKED; + + pci_read_config_byte(priv_p->pci_dev_p, PCI_CLASS_REVISION, &priv_p->card_rev); + pci_read_config_byte(priv_p->pci_dev_p, PCI_LATENCY_TIMER, &pci_latency); + + /* init poll waitqueue */ + init_waitqueue_head(&priv_p->poll_waitq); + + MSG(INTERNAL_LOG, minor, "END"); +} + +/** +* @brief FMB Hardware Private Data release +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +static void fmb_hw_private_data_release(struct fmb_hard_private* priv_p) +{ + int minor; + + minor = priv_p->minor; + + MSG(INTERNAL_LOG, minor, "START"); + + /* initialize the core private data */ + memset( &s_Fmb_hard_private_list[minor], 0, sizeof(struct fmb_hard_private)); + s_Fmb_hard_private_list[minor].minor = -1; + + MSG(INTERNAL_LOG, minor, "END"); +} + +/********************************************************/ +/* systemcall basic API Function */ +/********************************************************/ + +/** +* @brief FMB system call open() +* @param[in] *ip Information in filesystem +* @param[in] *fp File pointer +* @return 0 +* @note None +* @attention None +*/ + +static int fmb_hw_open(struct inode* ip_p, struct file* fp_p) +{ + int minor; + + minor = MINOR(ip_p->i_rdev); + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + + fp_p->private_data = &s_Fmb_hard_private_list[minor]; + + MSG(DRIVER_FUNC_LVL, minor, "END"); + return 0; +} + + +/** +* @brief FMB system call close() +* @param[in] *ip Information in filesystem +* @param[in] *fp File pointer +* @return 0 +* @note None +* @attention None +*/ + +static int fmb_hw_release(struct inode* ip_p, struct file* fp_p) +{ + int minor; + struct fmb_hard_private* priv_p = (struct fmb_hard_private*)fp_p->private_data; + + minor = priv_p->minor; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + MSG(DRIVER_FUNC_LVL, minor, "END"); + return 0; +} + +/** +* @brief FMB system call read() +* @param[in] *fp File pointer +* @param[in,out] *buffp Data pointer +* @param[in] len Data length +* @param[in] *offset Object pointer +* @return 0 +* @note None +* @attention None +*/ + +static ssize_t fmb_hw_read(struct file* fp, char __user* buffp_p, size_t len, loff_t* offset_p) +{ + int minor; + int rc; + struct fmb_hard_private* priv_p = (struct fmb_hard_private*)fp->private_data; + + minor = priv_p->minor; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + rc = Fmb_api_read(priv_p, fp, buffp_p, len, offset_p); + MSG(DRIVER_FUNC_LVL, minor, "END"); + return rc; +} + +/** +* @brief FMB system call write() +* @param[in] *fp File pointer +* @param[in,out] *buffp Data pointer +* @param[in] len Data length +* @param[in] *offset Object pointer +* @return 0 +* @note None +* @attention None +*/ + +static ssize_t fmb_hw_write(struct file* fp, const char __user* buffp_p, size_t len, loff_t* offset_p) +{ + int minor; + int rc; + struct fmb_hard_private* priv_p = (struct fmb_hard_private*)fp->private_data; + + minor = priv_p->minor; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + rc = Fmb_api_write(priv_p, fp, buffp_p, len, offset_p); + MSG(DRIVER_FUNC_LVL, minor, "END"); + return rc; +} + +/** +* @brief FMB system call poll() +* @param[in] *fp File pointer +* @param[in,out] *pt File poll table +* @return 0 +* @note None +* @attention None +*/ + +static unsigned int fmb_hw_poll(struct file* fp_p, poll_table* pt_p) +{ + int minor; + int rc; + struct fmb_hard_private* priv_p = (struct fmb_hard_private*)fp_p->private_data; + + minor = priv_p->minor; + rc = 0; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + poll_wait(fp_p, &priv_p->poll_waitq, pt_p); + + if (Fmb_core_get_factor_num(priv_p->core_priv_p)) { + /** factor info get active */ + MSG(DEBUG_LVL, minor, "factor info get active"); + rc = POLLPRI; + } + MSG(DRIVER_FUNC_LVL, minor, "END"); + return rc; +} + +/** +* @brief FMB system call ioctl() +* @param[in] *ip Information in filesystem +* @param[in] *fp File pointer +* @param[in] cmd Command number from application +* @param[in] arg Argument from application +* @return 0 +* @note None +* @attention None +*/ + +static int fmb_hw_ioctl(struct inode* ip_p, struct file* fp_p, + unsigned int cmd, unsigned long arg) +{ + int minor; + int rc; + struct fmb_hard_private* priv_p = (struct fmb_hard_private*)fp_p->private_data; + + minor = priv_p->minor; + rc = 0; + + MSG(DRIVER_FUNC_LVL, minor, "cmd:0x%x,START", cmd); + + /* ioctl() to FMB Codec */ + rc = Fmb_api_ioctl(priv_p, cmd, arg); + + MSG(DRIVER_FUNC_LVL, minor, "cmd:0x%x,END", cmd); + return rc; +} + +/********************************************************/ +/* */ +/* Hardware dependence Interrupt process function */ +/* */ +/********************************************************/ + +/** +* @brief FMB Hardware interrupt +* @param[in] irq Interruption number +* @param[in] *dev_id device id +* @param[in] *regs Pointer of register information +* @return IRQ_HANDLED Normal end +* @note None +* @attention None +*/ + +static irqreturn_t fmb_hw_interrupt(int irq, void *dev_id) +{ + int minor; + int dma0Int; + int dma1Int; + unsigned long intcsr; + unsigned long dmacsr; + unsigned long fpciintst; + struct fmb_hard_private* priv_p = (struct fmb_hard_private*)dev_id; + + dma0Int = 0; + dma1Int = 0; + + minor = priv_p->minor; + + MSG(CODEC_FUNC, minor, "START"); + MSG(DRIVER_FUNC_LVL, minor, "START"); + + intcsr = Fmb_hw_reg_read_dma(priv_p, INTSOURCE); + + if (intcsr & 0x00000010) { + /* DMA ch0 interrrupt */ + MSG(DMA0MSG_LVL, minor, "DMA ch0 interrrupt message"); + + dmacsr = Fmb_hw_reg_read_dma(priv_p, DMA0CMDSTS); + dmacsr |= 0x8; + Fmb_hw_reg_write_dma(priv_p, DMA0CMDSTS, dmacsr); + dma0Int = 1; + + MSG(DRIVER_FUNC_LVL, minor, "DMA ch0 interrrupt Registration"); + } + + if (intcsr & 0x00000020) { + /* DMA ch1 interrrupt */ + MSG(DMA1MSG_LVL, minor, "DMA ch1 interrrupt message"); + + dmacsr = Fmb_hw_reg_read_dma(priv_p, DMA1CMDSTS); + dmacsr |= 0x8; + Fmb_hw_reg_write_dma(priv_p, DMA1CMDSTS, dmacsr); + dma1Int = 1; + + MSG(DRIVER_FUNC_LVL, minor, "DMA ch1 interrrupt Registration"); + } + + if (intcsr & 0x00000001) { + /* LXINT */ + fpciintst = Fmb_hw_reg_read_lsi_master(priv_p, FPCI_INTST); + if (fpciintst & FPCI_INTMASK_XERROR ){ + Fmb_core_xerror_irq(priv_p->core_priv_p); + + MSG(DRIVER_FUNC_LVL, minor, "XERROR interrrupt Registration"); + } + + if(fpciintst & FPCI_INTMASK_INT ){ + + Fmb_core_int_irq(priv_p->core_priv_p); + MSG(DRIVER_FUNC_LVL, minor, "INT interrrupt Registration"); + } + + if(fpciintst & FPCI_INTMASK_EDERR ){ + + Fmb_core_ederr_irq(priv_p->core_priv_p); + MSG(DRIVER_FUNC_LVL, minor, "EDERR interrrupt Registration"); + } + + if(fpciintst & FPCI_INTMASK_DDERR ){ + + Fmb_core_dderr_irq(priv_p->core_priv_p); + MSG(DRIVER_FUNC_LVL, minor, "DDERR interrrupt Registration"); + } + + Fmb_hw_reg_write_lsi_master(priv_p, FPCI_INTST, fpciintst); + MSG(DRIVER_FUNC_LVL, minor, "LXINT interrrupt Registration"); + } + + if (dma0Int) { + Fmb_core_dma_rcv_irq(priv_p->core_priv_p); + MSG(DRIVER_FUNC_LVL, minor, "DMA forwarding interrupt for reception"); + } + + if (dma1Int) { + Fmb_core_dma_snd_irq(priv_p->core_priv_p); + MSG(DRIVER_FUNC_LVL, minor, "DMA forwarding interrupt for transmission"); + } + + MSG(DRIVER_FUNC_LVL, minor, "END"); + MSG(CODEC_FUNC, minor, "END"); + return IRQ_HANDLED; +} + + +/** +* @brief FMB Hardware interrupt set +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +* +*/ + +void Fmb_hw_interrupt_set(struct fmb_hard_private* priv_p) +{ + int minor; + int result; + + minor = priv_p->minor; + + MSG(INTERNAL_FUNC, minor, "START"); + + result = request_irq(priv_p->pci_dev_p->irq, fmb_hw_interrupt, + IRQF_DISABLED | IRQF_SHARED, FMB_DRIVER_NAME, (void *)priv_p); + if(result < 0) { + Fmb_core_remove(priv_p->core_priv_p); + fmb_hw_unmemmap(priv_p); + pci_disable_device(priv_p->pci_dev_p); + cdev_del(&priv_p->cdev_info); + MSG(KERN_ERR_LVL, minor, "Can not fmb_hw_interrupt reuest"); + }else if(result == 0){ + MSG(DEBUG_LVL, minor, "interrupt Handler Registration"); + } + + MSG(INTERNAL_FUNC, minor, "END"); +} + + +/********************************************************/ +/* */ +/* Driver module initialization function */ +/* */ +/********************************************************/ +/*------------------------------------------------------*/ +/* Data for driver registration */ +/*------------------------------------------------------*/ +static struct file_operations fmb_fops = +{ + .owner = THIS_MODULE, + .read = fmb_hw_read, + .write = fmb_hw_write, + .poll = fmb_hw_poll, + .ioctl = fmb_hw_ioctl, + .open = fmb_hw_open, + .release = fmb_hw_release, +}; + + +/** +* @brief FMB system call probe() +* @param[in] dev pci device Structure pointer +* @param[in] pci_id pci device id pointer +* @return 0 +* @note None +* @attention None +*/ + +static int __devinit fmb_hw_probe(struct pci_dev* pci_p, const struct pci_device_id* pci_id_p) +{ + + int minor; + int result; + struct fmb_hard_private* priv_p; + unsigned long flags; + dev_t dev; + + minor = -1; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + result = pci_enable_device(pci_p); + if(result != 0){ + MSG(KERN_ERR_LVL, minor, "pci device enable error"); + return -ENODEV; + } + + spin_lock_irqsave(&s_Fmb_hw_lock, flags); + if (s_Fmb_cards_active == FMB_MAX_CARDS) { + spin_unlock_irq(&s_Fmb_hw_lock); + pci_disable_device(pci_p); + MSG(INTERNAL_ERR_LVL, minor, "No remainder of private data."); + return -ENOMEM; + } + + priv_p = &s_Fmb_hard_private_list[s_Fmb_cards_active]; + + priv_p->pci_dev_p = pci_p; + priv_p->minor = FMB_MINOR_NUM_START + s_Fmb_cards_active; + s_Fmb_cards_active++; + + minor = priv_p->minor; + + spin_unlock_irqrestore(&s_Fmb_hw_lock, flags); + + fmb_hw_private_data_init(priv_p); + result = fmb_hw_memmap(priv_p); + if(result < 0){ + MSG(INTERNAL_ERR_LVL, minor, "memmap error"); + return -ENOMEM; + } + + pci_set_master(priv_p->pci_dev_p); + pci_set_drvdata(priv_p->pci_dev_p,priv_p); + + fmb_card_powerdown(priv_p); + fmb_card_reset(priv_p); + + result = Fmb_core_probe(priv_p); + if(result < 0){ + fmb_hw_unmemmap(priv_p); + pci_disable_device(priv_p->pci_dev_p); + MSG(INTERNAL_ERR_LVL, minor, "core_probe error"); + return -ENOMEM; + } + + Fmb_hw_codec_lsi_init(priv_p); + fmb_hw_irq_init(priv_p); + + dev = MKDEV(s_Fmb_driver_version_major, minor); + cdev_init(&priv_p->cdev_info, &fmb_fops); + priv_p->cdev_info.owner = THIS_MODULE; + priv_p->cdev_info.ops = &fmb_fops; + result = cdev_add(&priv_p->cdev_info, dev, 1); + if(result < 0) { + Fmb_core_remove(priv_p->core_priv_p); + fmb_hw_unmemmap(priv_p); + pci_disable_device(priv_p->pci_dev_p); + MSG(KERN_ERR_LVL, minor, "Can not module:fmb_driver registe"); + return -EBUSY; + } + + result = request_irq(priv_p->pci_dev_p->irq, fmb_hw_interrupt, + IRQF_DISABLED | IRQF_SHARED, FMB_DRIVER_NAME, (void *)priv_p); + if(result < 0) { + Fmb_core_remove(priv_p->core_priv_p); + fmb_hw_unmemmap(priv_p); + pci_disable_device(pci_p); + cdev_del(&priv_p->cdev_info); + MSG(KERN_ERR_LVL, minor, "Can not fmb_hw_interrupt reuest"); + return -EBUSY; + }else if(result == 0){ + MSG(DEBUG_LVL, minor, "interrupt Handler Registration"); + } + + MSG(RESOURCE_LVL, minor, "Driver Version:(%s)\n", VERSION); + MSG(DRIVER_FUNC_LVL, minor, "END"); + return 0; +} + +/** +* @brief FMB system call remove() +* @param[in] dev pci device Structure pointer +* @return 0 +* @note None +* @attention None +*/ +static void __devexit fmb_hw_remove(struct pci_dev* pci_p) +{ + int minor; + struct fmb_hard_private* priv_p; + + priv_p = (struct fmb_hard_private*)pci_get_drvdata(pci_p); + + minor = priv_p->minor; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + free_irq(priv_p->pci_dev_p->irq, priv_p); + + Fmb_hw_reg_write_dma(priv_p, INTENABLE, 0x00000000); + + Fmb_core_remove(priv_p->core_priv_p); + + fmb_card_powerdown(priv_p); + + Fmb_hw_clear_irq(priv_p); + fmb_hw_unmemmap(priv_p); + + pci_disable_device(pci_p); + + cdev_del(&priv_p->cdev_info); + + fmb_hw_private_data_release(priv_p); + + s_Fmb_cards_active--; + + MSG(DRIVER_FUNC_LVL, minor, "END"); +} + +/*----------------------------------------------------------------------------*/ +/* Registration processing to PCI bus driver */ +/*----------------------------------------------------------------------------*/ +static struct pci_device_id s_Fmb_hw_pci_tbl[] __devinitdata = { + { FMB_PCI_VENDOR_ID, FMB_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, s_Fmb_hw_pci_tbl); + +static struct pci_driver s_Fmb_hw_driver = { + .name = FMB_DRIVER_NAME, + .id_table = s_Fmb_hw_pci_tbl, + .probe = fmb_hw_probe, + .remove = fmb_hw_remove, +}; + +/** +* @brief FMB Hardware initialize module +* @param[in] None +* @return 0 Normal end +* @return -EBUSY Can not module registe + Can not interrupt reuest +* @note None +* @attention None +*/ + +static int __init fmb_hw_init_module(void) +{ + int minor; + int cnt; + int result; + int rc; + + minor = -1; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + memset( s_Fmb_hard_private_list, 0x00, sizeof( s_Fmb_hard_private_list ) ); + for (cnt = 0; cnt < FMB_MAX_CARDS; cnt++){ + s_Fmb_hard_private_list[cnt].minor = -1; + } + + Fmb_core_init_module(); + + result = alloc_chrdev_region(&s_dev, FMB_MINOR_NUM_START, FMB_MAX_CARDS, FMB_DRIVER_NAME); + if(result < 0){ + MSG(KERN_ERR_LVL, minor, "Majors number allocation error"); + return -EBUSY; + } + s_Fmb_driver_version_major = MAJOR(s_dev); + MSG(DEBUG_LVL, minor, "Majors number = %d", s_Fmb_driver_version_major); + + rc = pci_register_driver (&s_Fmb_hw_driver); + if(rc < 0){ + MSG(KERN_ERR_LVL, minor, "PCI driver registration error"); + unregister_chrdev_region(s_dev, FMB_MAX_CARDS); + return -EBUSY; + } + MSG(DRIVER_FUNC_LVL, minor, "END"); + return rc; +} + +/** +* @brief FMB Hardware cleanup module +* @param[in] None +* @return None +* @note None +* @attention None +*/ + +static void __exit fmb_hw_cleanup_module(void) +{ + int minor; + + minor = -1; + + MSG(DRIVER_FUNC_LVL, minor, "START"); + + unregister_chrdev_region(s_dev, FMB_MAX_CARDS); + + pci_unregister_driver (&s_Fmb_hw_driver); + + MSG(DRIVER_FUNC_LVL, minor, "END"); +} + +module_init(fmb_hw_init_module); +module_exit(fmb_hw_cleanup_module); + diff --git a/fmb_driver/fmb_hw.h b/fmb_driver/fmb_hw.h new file mode 100644 index 0000000..f73ed7b --- /dev/null +++ b/fmb_driver/fmb_hw.h @@ -0,0 +1,273 @@ +/** +* @brief Hardware External Function header file for FMB LSI Linux driver +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +/****************************************************************************/ +#ifndef __FMB_HW_H__ +#define __FMB_HW_H__ + + +/********************************************************/ +/* Constant definition for customizing */ +/********************************************************/ +/** driver name */ +#define FMB_DRIVER_NAME "h55fmb" + +/** FMB_API Linux driver system timer */ +#define FMB_CODEC_CACK_SYS_TIME 100 /* ms */ + +#define FMB_CODEC_BOOTLOADER_BOOTUP_TIME 1000 /* us */ +#define FMB_CODEC_BOOTLOADER_BOOTUP_DELAY_TIME 1 /* us */ +#define FMB_CODEC_FIRM_BOOTUP_TIME 100 /* ms */ +#define FMB_CODEC_FIRM_BOOTUP_DELAY_TIME 1 /* ms */ + +#define FMB_CARD_RESET_DELAY_TIME1 1 /* ms */ +#define FMB_CARD_RESET_DELAY_TIME2 500 /* ms */ + +#define FMB_MINOR_NUM_START 0 +#define FMB_MAX_CARDS 8 // 2 /**< MAX card num */ +#define FMB_PCI_DEVICE_ID 0x2033 /**< PCI Device ID */ +#define FMB_PCI_VENDOR_ID 0x10CF /**< PCI Vendor ID */ +#define FMB_DEFAULT_NUM_CARDS 1 /**< Default card num */ + +/********************************************************/ +/* PCI adress //IO step1 */ +/********************************************************/ +/** PCI register size **/ +#define FMB_DMA_SIZE 0x000000E9 +#define FMB_CORE_SIZE 0x00200000 +#define FMB_CORE_LSI_SIZE 0x001DFFFC + + +/** PCI register offset **/ +/** BAR0 **/ +#define INTSOURCE 0x00 +#define INTENABLE 0x04 +#define TAADDRESS 0x10 +#define TCSTATUS 0x14 + +#define DMA0CMDSTS 0x40 +#define DMA0PCIADR 0x44 +#define DMA0TCOUNT 0x48 +#define DMA1CMDSTS 0x50 +#define DMA1PCIADR 0x54 +#define DMA1TCOUNT 0x58 + +#define OUSER0 0x80 +#define IUSER0 0x84 + +/** BAR1 **/ +#define FPCI_REG_BASE 0x1E0000 +#define FPCI_CNT (FPCI_REG_BASE + 0x0110) +#define FPCI_INTST (FPCI_REG_BASE + 0x0210) +#define FPCI_INTEN (FPCI_REG_BASE + 0x0214) +#define FPCI_CODEC_CNT (FPCI_REG_BASE + 0x0410) +#define FPCI_ENC_CNT (FPCI_REG_BASE + 0x2010) +#define FPCI_DEC_CNT (FPCI_REG_BASE + 0x4010) + +#define FPCI_INTMASK_INT 0x10000000 +#define FPCI_INTMASK_XERROR 0x80000000 +#define FPCI_INTMASK_EDERR 0x00400000 +#define FPCI_INTMASK_DDERR 0x00040000 + +/* API_IRQST_CMD */ +#define API_IRQST_TCPU_CMD 0x0004 +#define API_IRQST_TACK_CMD 0x0008 +#define API_IRQST_VSYNC_CMD 0x0010 + +/** + * @brief The hardware-dependent part of private data<br> + */ +struct fmb_hard_private +{ + spinlock_t lock_hw_priv; + wait_queue_head_t poll_waitq; + + unsigned long dma_base; /**< HW private data pointer */ + unsigned long core_base; + + spinlock_t dma_reg_lock; + spinlock_t core_reg_lock; + struct cdev cdev_info; /**< cdev structure */ + unsigned char card_rev; /**< PCI Class Rivision */ + struct pci_dev* pci_dev_p; /**< pci device pointer */ + int minor; /**< minor number */ + struct fmb_core_private* core_priv_p; /**< core private data pointer*/ +}; + +/********************************************************/ +/* FMB Hardware External Function */ +/********************************************************/ + +/** +* @brief Register Read to DMA +* @param[in] priv_p private data pointer +* @param[in] addr DMA register address +* @return val register read value +* @note None +* @attention None +*/ +unsigned long Fmb_hw_reg_read_dma(struct fmb_hard_private* priv_p, unsigned long addr); + +/** +* @brief Register Write to DMA +* @param[in] priv_p private data pointer +* @param[in] addr DMA register address +* @param[in] data register write value +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_reg_write_dma(struct fmb_hard_private* priv_p, unsigned long addr, unsigned long data); + +/** +* @brief Register Read to LSI +* @param[in] priv_p private data pointer +* @param[in] addr DMA register address +* @return val register read value +* @note None +* @attention None +*/ +unsigned short Fmb_hw_reg_read_lsi(struct fmb_hard_private* priv_p, unsigned long addr); + +/** +* @brief Register Write to LSI +* @param[in] priv_p private data pointer +* @param[in] addr LSI register address +* @param[in] data register write value +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_reg_write_lsi(struct fmb_hard_private* priv_p, unsigned long addr, unsigned short data); + +/** +* @brief Register Read to PCI(master) +* @param[in] priv_p private data pointer +* @param[in] addr DMA register address +* @return val register read value +* @note None +* @attention None +*/ +unsigned long Fmb_hw_reg_read_lsi_master(struct fmb_hard_private* priv_p, unsigned long addr); + +/** +* @brief Register Write to PCI(master) +* @param[in] priv_p private data pointer +* @param[in] addr LSI register address +* @param[in] data register write value +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_reg_write_lsi_master(struct fmb_hard_private* priv_p, unsigned long addr, unsigned long data); + +/** +* @brief Register Read Modfi Write to LSI +* @param[in] priv_p private data pointer +* @param[in] addr LSI register address +* @param[in] shift shift value at the time of writing +* @param[in] mask mask value at the time of writing +* @param[in] data register write value +* @return val register read value +* @note None +* @attention None +*/ +unsigned short Fmb_hw_reg_rmw_lsi(struct fmb_hard_private* priv_p, unsigned long addr, unsigned short shift,unsigned short mask, unsigned short data); + +/** +* @brief Check access area for lsi +* @param[in] priv_p private data pointer +* @param[in] offset_addr offset address to specified PCI +* @param[in] access_size Size of access area +* @return 0 Normal end +* @return -EINVAL The content of the parameter is illegal. +* @note None +* @attension None +*/ +int Fmb_hw_check_addr_lsi(struct fmb_hard_private* priv_p, unsigned long offset_addr, unsigned long access_size); + +/** +* @brief Check access area for PCI +* @param[in] priv_p private data pointer +* @param[in] pci_type Type of specified PCI (Not used) +* @param[in] offset_addr offset address to specified PCI +* @param[in] access_size Size of access area +* @return 0 Normal end +* @return -EINVAL The content of the parameter is illegal. +* @note None +* @attention None +*/ + +int Fmb_hw_check_addr_pci(struct fmb_hard_private* priv_p, unsigned long pci_type, unsigned long offset_addr, + unsigned long access_size); + +/** +* @brief DMA/LSI Clear Interrupt +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ + +void Fmb_hw_clear_irq(struct fmb_hard_private* priv_p ); + +/** +* @brief DMA/LSI Enable Interrupt Vector +* @param[in] priv_p private data pointer +* @param[in] irq_type Interrupt type +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_enable_irq(struct fmb_hard_private* priv_p, int irq_type ); + +/** +* @brief DMA/LSI Disable Interrupt Vector +* @param[in] priv_p private data pointer +* @param[in] irq_type Interrupt type +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_disable_irq(struct fmb_hard_private* priv_p, int irq_type); + +/** +* @brief FMB Codec Lsi Initialize +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_codec_lsi_init(struct fmb_hard_private* priv_p); + +/** +* @brief FMB Codec Lsi Reset +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_codec_lsi_reset(struct fmb_hard_private* priv_p); + +/** +* @brief FMB Hardware interrupt set +* @param[in] priv_p private data pointer +* @return None +* @note None +* @attention None +*/ +void Fmb_hw_interrupt_set(struct fmb_hard_private* priv_p); + +#endif /* ifndef __FMB_HW_H__ */ diff --git a/fmb_driver/fmb_msg.h b/fmb_driver/fmb_msg.h new file mode 100644 index 0000000..9c739d0 --- /dev/null +++ b/fmb_driver/fmb_msg.h @@ -0,0 +1,285 @@ +/** +* @brief The kernel message macro file for the MB86-API Linux driver +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +/****************************************************************************/ + +#ifndef __FMB_MSG_H__ +#define __FMB_MSG_H__ + +#include <linux/time.h> +#include "fmb_hw.h" + +#define MSG_CTL_DYNAMIC +#define MSG_DEFAULT_LVL 0x3F + +#define KERN_ERR_LVL 0 /* 0x0001 */ +#define LSI_ERR_LVL 1 /* 0x0002 */ +#define CRIT_LVL 2 /* 0x0004 */ +#define ERR_LVL 3 /* 0x0008 */ +#define INTERNAL_ERR_LVL 4 /* 0x0010 */ +#define RESOURCE_LVL 5 /* 0x0020 */ +/*------------- default level --------------------*/ +#define DRIVER_FUNC_LVL 6 /* 0x0040 */ +#define INTERNAL_FUNC 7 /* 0x0080 */ +#define INTERNAL_LOG 8 /* 0x0100 */ +#define DEBUG_LVL 9 /* 0x0200 */ +#define CMDMSG_LVL 10 /* 0x0400 */ +#define SYSMSG_LVL 11 /* 0x0800 */ +#define VIDEOMSG_LVL 12 /* 0x1000 */ +#define AUDIOMSG_LVL 13 /* 0x2000 */ +#define DMA0MSG_LVL 14 /* 0x4000 */ +#define DMA1MSG_LVL 15 /* 0x8000 */ +#define CODEC_LVL 16 /* 0x10000 */ +#define CODEC_FUNC 17 /* 0x20000 */ +#define IOCTL_FUNC 18 /* 0x40000 */ + + +#define DISABLE_WRITE_FIRM_LOG + + +#ifdef MSG_CTL_DYNAMIC +#ifndef MSG_DESCRIPTION +#define MSG_DESCRIPTION "\n" \ + "\tSelect the output message level(default: msg_lvl=0x3F)\n" \ + "\tShow Kernel error message 0x00001\n" \ + "\tShow MB86 LSI error message 0x00002\n" \ + "\tNone 0x00004\n" \ + "\tNone 0x00008\n" \ + "\tShow Driver internal error messsage 0x00010\n" \ + "\tShow Hard/OS resource that driver uses massage 0x00020\n" \ + "\tShow Start/end message of system call function 0x00040\n" \ + "\tShow Start/end message of driver external function 0x00080\n" \ + "\tShow Start/end message of driver internal function 0x00100\n" \ + "\tShow Debug message 0x00200\n" \ + "\tShow Interrupt from command message 0x00400\n" \ + "\tShow Interrupt from system message 0x00800\n" \ + "\tShow Interrupt from video message 0x01000\n" \ + "\tShow Interrupt from audio message 0x02000\n" \ + "\tShow Interrupt from dma0 message 0x04000\n" \ + "\tShow Interrupt from dma1 message 0x08000\n" \ + "\tShow Codec read/write message 0x10000\n" \ + "\tShow Start/end message of codec setting function 0x20000\n" \ + "\tShow Start message of ioctl setting function 0x40000\n" \ + +#endif /* MSG_DESCRIPTION */ +#define PREPARE_DEBUG() \ + long msg_lvl = MSG_DEFAULT_LVL; \ + module_param(msg_lvl, long, S_IRUGO); \ + MODULE_PARM_DESC(msg_lvl, MSG_DESCRIPTION); +#define PREPARE_DEBUG_FOR_FUNC() \ + extern long msg_lvl; +#else /* MSG_CTL_DYNAMIC */ +#define PREPARE_DEBUG do + { + } while(0) +#define PREPARE_DEBUG_FOR_FUNC do + { + } while(0) +#endif /* MSG_CTL_DYNAMIC */ + +#ifdef MSG_CTL_DYNAMIC +#else /* MSG_CTL_DYNAMIC */ +#define MSG_CTL_PREFIX do + { + } while(0) +#endif /* MSG_CTL_DYNAMIC */ + +/* + sprintf( g_timechar, "????.??????" ); \ +*/ + +#define __MESSAGE( fi, l, f, lvl, m, fmt,arg... ) do \ +{ \ + struct timeval g_tv = {0}; \ + char g_timechar[16] = {0}; \ + \ + if ((msg_lvl >> lvl) & 0x01) { \ + do_gettimeofday( &g_tv ); \ + sprintf( g_timechar, "%02d.%06d", (int)(g_tv.tv_sec % 60), (int)g_tv.tv_usec ); \ + \ + if (m < 0) { \ + switch (lvl) \ + { \ + case KERN_ERR_LVL: \ + printk( KERN_EMERG FMB_DRIVER_NAME"(%s) : <0> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case LSI_ERR_LVL: \ + printk( KERN_ALERT FMB_DRIVER_NAME"(%s) : <1> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case CRIT_LVL: \ + printk( KERN_CRIT FMB_DRIVER_NAME"(%s) : <2> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case ERR_LVL: \ + printk( KERN_ERR FMB_DRIVER_NAME"(%s) : <3> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case INTERNAL_ERR_LVL: \ + printk( KERN_WARNING FMB_DRIVER_NAME"(%s) : <4> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case RESOURCE_LVL: \ + printk( KERN_NOTICE FMB_DRIVER_NAME"(%s) : <5> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case DRIVER_FUNC_LVL: \ + printk( KERN_INFO FMB_DRIVER_NAME"(%s) : <6> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case INTERNAL_FUNC: \ + printk( KERN_INFO FMB_DRIVER_NAME"(%s) : <7> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case INTERNAL_LOG: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <8> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case DEBUG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <9> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case CMDMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <10> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case SYSMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <11> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case VIDEOMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <12> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case AUDIOMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <13> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case DMA0MSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <14> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case DMA1MSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <15> %s(%i) %s: " fmt "\n", \ + g_timechar, fi, l, f, ##arg ); \ + break; \ + case CODEC_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <16> : " fmt "\n", \ + g_timechar, ##arg ); \ + break; \ + case CODEC_FUNC: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <17> %s(): " fmt "\n", \ + g_timechar, f, ##arg ); \ + break; \ + case IOCTL_FUNC: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"(%s) : <18> %s(): " fmt "\n", \ + g_timechar, f, ##arg ); \ + break; \ + default: \ + break; \ + } \ + } \ + else { \ + switch (lvl) \ + { \ + case KERN_ERR_LVL: \ + printk( KERN_EMERG FMB_DRIVER_NAME"%d(%s) : <0> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case LSI_ERR_LVL: \ + printk( KERN_ALERT FMB_DRIVER_NAME"%d(%s) : <1> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case CRIT_LVL: \ + printk( KERN_CRIT FMB_DRIVER_NAME"%d(%s) : <2> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case ERR_LVL: \ + printk( KERN_ERR FMB_DRIVER_NAME"%d(%s) : <3> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case INTERNAL_ERR_LVL: \ + printk( KERN_WARNING FMB_DRIVER_NAME"%d(%s) : <4> %s(%i) %s: " fmt "\n",\ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case RESOURCE_LVL: \ + printk( KERN_NOTICE FMB_DRIVER_NAME"%d(%s) : <5> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case DRIVER_FUNC_LVL: \ + printk( KERN_INFO FMB_DRIVER_NAME"%d(%s) : <6> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case INTERNAL_FUNC: \ + printk( KERN_INFO FMB_DRIVER_NAME"%d(%s) : <7> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case INTERNAL_LOG: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <8> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case DEBUG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <9> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case CMDMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <10> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case SYSMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <11> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case VIDEOMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <12> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case AUDIOMSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <13> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case DMA0MSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <14> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case DMA1MSG_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <15> %s(%i) %s: " fmt "\n", \ + m, g_timechar, fi, l, f, ##arg ); \ + break; \ + case CODEC_LVL: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <16> : " fmt "\n", \ + m, g_timechar, ##arg ); \ + break; \ + case CODEC_FUNC: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <17> %s(): " fmt "\n", \ + m, g_timechar, f, ##arg ); \ + break; \ + case IOCTL_FUNC: \ + printk( KERN_DEBUG FMB_DRIVER_NAME"%d(%s) : <18> %s(): " fmt "\n", \ + m, g_timechar, f, ##arg ); \ + break; \ + default: \ + break; \ + } \ + } \ + } \ +} while(0) + +#define MSG( lvl,minor,fmt, arg... ) __MESSAGE( __FILE__, __LINE__, __FUNCTION__, \ + lvl, minor, fmt, ##arg ) + +#endif /* __FMB_MSG_H__ */ + diff --git a/fmb_driver/install.sh b/fmb_driver/install.sh new file mode 100755 index 0000000..442ff82 --- /dev/null +++ b/fmb_driver/install.sh @@ -0,0 +1,91 @@ +#!/bin/sh +#----------------------------------------------------------- +# install.sh --- Instal script for the MB86H55 driver +#----------------------------------------------------------- + +KERN_RELEASE=`uname -r` +LIBDIR="/lib/modules/$KERN_RELEASE/$MDIR" +FIRM_PATH="/usr/local/etc/mb86h55.bin" + +module="h55fmb" +device_num="0 1 2 3 4 5 6 7" +device="/dev/h55fmb" +#device0="/dev/h55fmb0" +#device1="/dev/h55fmb1" + +# +# Check root account +# +uid=`id | sed 's/uid=//' | sed 's/(.*//'` +if [ $uid != 0 ]; then + echo "ERROR: You are not root.!!" + exit +fi + +# +# Edit /etc/rc.d/rc.local +# +grep h55fmb /etc/rc.d/rc.local > /dev/null +if [ $? != 0 ];then + echo "/etc/rc.d/rc6.d/S99$module" >> /etc/rc.d/rc.local +fi + +# +# Copy restart script +# +\cp S99$module /etc/rc.d/rc6.d/ +chmod 744 /etc/rc.d/rc6.d/S99$module + +# +# Unload old driver module +# +grep $module /proc/modules > /dev/null +if [ $? = 0 ];then + echo -n "Unloading old device driver... " + /sbin/rmmod $module + echo "done." +fi + +# +# Remove old device special files +# +for i in $device_num; do + rm -f $device$i + #echo $device$i +done +#rm -f $device0 +#rm -f $device1 + +# +# Install new driver module +# +echo -n "Making device driver... " +make clean >/dev/null +make >& /dev/null +make install >/dev/null +echo "done." + +# +# Load new driver module +# +echo -n "Loading new device driver... " +/sbin/insmod $LIBDIR/$module.ko +# /sbin/insmod $LIBDIR/$module.ko msg_lvl=1023 +# /sbin/insmod $LIBDIR/$module.ko msg_lvl=511 +echo "done." + +# +# Get major number from /proc/devices +# +major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices) + +# +# Create device special files +# +for i in $device_num; do + if [ ! -e $device$i ];then + mknod $device$i c $major $i + chmod 666 $device$i + fi +done + diff --git a/fmb_player_apl/.cproject b/fmb_player_apl/.cproject new file mode 100644 index 0000000..7df0a52 --- /dev/null +++ b/fmb_player_apl/.cproject @@ -0,0 +1,876 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?> + +<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> +<storageModule moduleId="org.eclipse.cdt.core.settings"> +<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.866633619"> +<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.866633619" moduleId="org.eclipse.cdt.core.settings" name="Debug"> +<externalSettings/> +<extensions> +<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +</extensions> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<configuration artifactExtension="" artifactName="fmb_player_apl" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.debug.866633619" name="Debug" parent="cdt.managedbuild.config.gnu.exe.debug"> +<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.866633619." name="/" resourcePath=""> +<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.547480422" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug"> +<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug.520437752" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> +<builder buildPath="${workspace_loc:/fmb_player_apl/Debug}" id="cdt.managedbuild.target.gnu.builder.exe.debug.1884395972" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.debug"/> +<tool id="cdt.managedbuild.tool.gnu.archiver.base.1174136251" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1824815171" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug"> +<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1327866457" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> +<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.2087736491" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> +</tool> +<tool command="gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1225841012" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug"> +<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.1960067613" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> +<option id="gnu.c.compiler.exe.debug.option.debugging.level.640035757" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> +<option id="gnu.c.compiler.option.include.paths.1529969449" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> +<listOptionValue builtIn="false" value=""${workspace_loc:/fmb_player_apl_branch/include}""/> +<listOptionValue builtIn="false" value=""${workspace_loc:/mmux_driver}""/> +<listOptionValue builtIn="false" value=""${workspace_loc:/fmb_driver}""/> +</option> +<option id="gnu.c.compiler.option.preprocessor.def.symbols.2059702621" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> +<listOptionValue builtIn="false" value="_GNU_SOURCE"/> +<listOptionValue builtIn="false" value="MULTI_CH"/> +<listOptionValue builtIn="false" value="VERSION=\"1.1.2.0\""/> +</option> +<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.899827832" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.767619071" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug"> +<option id="gnu.c.link.option.libs.1928243400" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs"> +<listOptionValue builtIn="false" value="pthread"/> +</option> +<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1728972758" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> +<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> +<additionalInput kind="additionalinput" paths="$(LIBS)"/> +</inputType> +<outputType id="cdt.managedbuild.tool.gnu.c.linker.output.832298084" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.output"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1878274381" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug"/> +<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.225207515" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug"> +<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1251862362" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> +</tool> +</toolChain> +</folderInfo> +<folderInfo id="cdt.managedbuild.config.gnu.exe.debug.866633619.933509004" name="/" resourcePath="Debug"> +<toolChain id="cdt.managedbuild.toolchain.gnu.exe.debug.2126164002" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.debug" unusedChildren=""> +<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.debug" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.debug"/> +<tool id="cdt.managedbuild.tool.gnu.archiver.base.1403836937" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base.1174136251"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1036909541" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug.1824815171"> +<option id="gnu.cpp.compiler.exe.debug.option.optimization.level.1821567223" name="Optimization Level" superClass="gnu.cpp.compiler.exe.debug.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/> +<option id="gnu.cpp.compiler.exe.debug.option.debugging.level.54166917" name="Debug Level" superClass="gnu.cpp.compiler.exe.debug.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.920899406" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1225841012"> +<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.exe.debug.option.optimization.level.346858391" name="Optimization Level" superClass="gnu.c.compiler.exe.debug.option.optimization.level" valueType="enumerated"/> +<option id="gnu.c.compiler.exe.debug.option.debugging.level.1509996133" name="Debug Level" superClass="gnu.c.compiler.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/> +<option id="gnu.c.compiler.option.preprocessor.def.symbols.328459272" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> +<listOptionValue builtIn="false" value="_GNU_SOURCE"/> +<listOptionValue builtIn="false" value="MULTI_CH"/> +<listOptionValue builtIn="false" value="VERSION=\"1.1.2.0\""/> +</option> +<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1975858992" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.debug.574693009" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.debug.767619071"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1618356257" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.debug.1878274381"/> +<tool id="cdt.managedbuild.tool.gnu.assembler.exe.debug.800787067" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.debug.225207515"> +<inputType id="cdt.managedbuild.tool.gnu.assembler.input.258711705" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> +</tool> +</toolChain> +</folderInfo> +</configuration> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/> +<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> +<storageModule moduleId="scannerConfiguration"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.866633619;cdt.managedbuild.config.gnu.exe.debug.866633619.933509004;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.920899406;cdt.managedbuild.tool.gnu.c.compiler.input.1975858992"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1409249817;cdt.managedbuild.config.gnu.exe.release.1409249817.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.2125887305;cdt.managedbuild.tool.gnu.c.compiler.input.348045149"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.866633619;cdt.managedbuild.config.gnu.exe.debug.866633619.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1225841012;cdt.managedbuild.tool.gnu.c.compiler.input.899827832"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> +<buildTargets> +<target name="clean" path="Release" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildArguments/> +<buildTarget>clean</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +<target name="all" path="Release" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildArguments/> +<buildTarget>all</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +</buildTargets> +</storageModule> +</cconfiguration> +<cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1409249817"> +<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1409249817" moduleId="org.eclipse.cdt.core.settings" name="Release"> +<externalSettings/> +<extensions> +<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +</extensions> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<configuration artifactName="fmb_player_apl" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1409249817" name="Release" parent="cdt.managedbuild.config.gnu.exe.release"> +<folderInfo id="cdt.managedbuild.config.gnu.exe.release.1409249817." name="/" resourcePath=""> +<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1817846585" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release"> +<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.299302199" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> +<builder buildPath="${workspace_loc:/fmb_player_apl/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.705973202" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/> +<tool id="cdt.managedbuild.tool.gnu.archiver.base.2103147889" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.217164907" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release"> +<option id="gnu.cpp.compiler.exe.release.option.optimization.level.123139752" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> +<option id="gnu.cpp.compiler.exe.release.option.debugging.level.702932793" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> +</tool> +<tool command="gcc $(CFLAGS)" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.2125887305" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release"> +<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.287214886" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/> +<option id="gnu.c.compiler.exe.release.option.debugging.level.325689185" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> +<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.348045149" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1663923019" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release"> +<option id="gnu.c.link.option.shared.1273474555" name="Shared (-shared)" superClass="gnu.c.link.option.shared"/> +<option id="gnu.c.link.option.libs.1767512218" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs"> +<listOptionValue builtIn="false" value="pthread"/> +</option> +<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1331089960" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> +<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> +<additionalInput kind="additionalinput" paths="$(LIBS)"/> +</inputType> +</tool> +<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.723033137" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"> +<option id="gnu.cpp.link.option.shared.1602310632" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.322487277" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release"> +<inputType id="cdt.managedbuild.tool.gnu.assembler.input.223006296" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> +</tool> +</toolChain> +</folderInfo> +<folderInfo id="cdt.managedbuild.config.gnu.exe.release.1409249817.1292616523" name="/" resourcePath="Release"> +<toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.1468037884" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release" unusedChildren=""> +<targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/> +<tool id="cdt.managedbuild.tool.gnu.archiver.base.993609792" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base.2103147889"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.1990725489" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.217164907"> +<option id="gnu.cpp.compiler.exe.release.option.optimization.level.739639334" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/> +<option id="gnu.cpp.compiler.exe.release.option.debugging.level.1822951329" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> +</tool> +<tool command="gcc ${CFLAGS} " commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1059487362" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release.2125887305"> +<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.1691182135" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/> +<option id="gnu.c.compiler.exe.release.option.debugging.level.1665729556" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/> +<option id="gnu.c.compiler.option.preprocessor.def.symbols.53730874" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols"/> +<option id="gnu.c.compiler.option.include.paths.1117860321" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths"/> +<option id="gnu.c.compiler.option.preprocessor.undef.symbol.712983356" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol"/> +<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1423208965" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.linker.exe.release.348451189" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release.1663923019"> +<option id="gnu.c.link.option.shared.1931847192" name="Shared (-shared)" superClass="gnu.c.link.option.shared"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1804554406" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.723033137"> +<option id="gnu.cpp.link.option.shared.187701551" name="Shared (-shared)" superClass="gnu.cpp.link.option.shared"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.2086838277" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release.322487277"> +<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1142625672" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> +</tool> +</toolChain> +</folderInfo> +</configuration> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/> +<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> +<storageModule moduleId="scannerConfiguration"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.866633619;cdt.managedbuild.config.gnu.exe.debug.866633619.933509004;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.920899406;cdt.managedbuild.tool.gnu.c.compiler.input.1975858992"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1409249817;cdt.managedbuild.config.gnu.exe.release.1409249817.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.2125887305;cdt.managedbuild.tool.gnu.c.compiler.input.348045149"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.866633619;cdt.managedbuild.config.gnu.exe.debug.866633619.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.1225841012;cdt.managedbuild.tool.gnu.c.compiler.input.899827832"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> +<buildTargets> +<target name="clean" path="Release" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildArguments/> +<buildTarget>clean</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +<target name="all" path="Release" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildArguments/> +<buildTarget>all</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +</buildTargets> +</storageModule> +</cconfiguration> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<project id="fmb_player_apl.cdt.managedbuild.target.gnu.exe.1523455318" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/> +</storageModule> +</cproject> diff --git a/fmb_player_apl/.project b/fmb_player_apl/.project new file mode 100644 index 0000000..4bda167 --- /dev/null +++ b/fmb_player_apl/.project @@ -0,0 +1,81 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>fmb_player_apl_branch</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + <dictionary> + <key>?name?</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.append_environment</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.autoBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildArguments</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildCommand</key> + <value>make</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildLocation</key> + <value>${workspace_loc:/fmb_player_apl/Debug}</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.cleanBuildTarget</key> + <value>clean</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.contents</key> + <value>org.eclipse.cdt.make.core.activeConfigSettings</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableAutoBuild</key> + <value>false</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableCleanBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableFullBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.fullBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.stopOnError</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> + <value>true</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/fmb_player_apl/Release/makefile b/fmb_player_apl/Release/makefile new file mode 100644 index 0000000..8fb7e51 --- /dev/null +++ b/fmb_player_apl/Release/makefile @@ -0,0 +1,48 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +-include ../makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include subdir.mk +-include src/util/subdir.mk +-include src/scr/subdir.mk +-include src/sce/subdir.mk +-include src/com/subdir.mk +-include src/cmd/subdir.mk +-include objects.mk + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(C_DEPS)),) +-include $(C_DEPS) +endif +endif + +-include ../makefile.defs + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: fmb_player_apl + +# Tool invocations +fmb_player_apl: $(OBJS) $(USER_OBJS) + @echo 'Building target: $@' + @echo 'Invoking: GCC C Linker' + gcc -o"fmb_player_apl" $(OBJS) $(USER_OBJS) $(LIBS) + @echo 'Finished building target: $@' + @echo ' ' + +# Other Targets +clean: + -$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) fmb_player_apl + -@echo ' ' + +.PHONY: all clean dependents +.SECONDARY: + +-include ../makefile.targets diff --git a/fmb_player_apl/Release/objects.mk b/fmb_player_apl/Release/objects.mk new file mode 100644 index 0000000..bf47de3 --- /dev/null +++ b/fmb_player_apl/Release/objects.mk @@ -0,0 +1,7 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +USER_OBJS := + +LIBS := -lpthread diff --git a/fmb_player_apl/Release/sources.mk b/fmb_player_apl/Release/sources.mk new file mode 100644 index 0000000..8765fe6 --- /dev/null +++ b/fmb_player_apl/Release/sources.mk @@ -0,0 +1,21 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +O_SRCS := +C_SRCS := +S_UPPER_SRCS := +OBJ_SRCS := +ASM_SRCS := +OBJS := +C_DEPS := +EXECUTABLES := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +src/util \ +src/scr \ +src/sce \ +src/com \ +src/cmd \ + diff --git a/fmb_player_apl/Release/src/cmd/subdir.mk b/fmb_player_apl/Release/src/cmd/subdir.mk new file mode 100644 index 0000000..41a71a1 --- /dev/null +++ b/fmb_player_apl/Release/src/cmd/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../src/cmd/FmbCmd.c \ +../src/cmd/FmbCmdTbl.c + +OBJS += \ +./src/cmd/FmbCmd.o \ +./src/cmd/FmbCmdTbl.o + +C_DEPS += \ +./src/cmd/FmbCmd.d \ +./src/cmd/FmbCmdTbl.d + + +# Each subdirectory must supply rules for building sources it contributes +src/cmd/%.o: ../src/cmd/%.c + @echo 'Building file: $<' + @echo 'Invoking: GCC C Compiler' + gcc $(CFLAGS) -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/fmb_player_apl/Release/src/com/subdir.mk b/fmb_player_apl/Release/src/com/subdir.mk new file mode 100644 index 0000000..15718b8 --- /dev/null +++ b/fmb_player_apl/Release/src/com/subdir.mk @@ -0,0 +1,51 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../src/com/FmbComBitrate.c \ +../src/com/FmbComCore.c \ +../src/com/FmbComDevice.c \ +../src/com/FmbComDriver.c \ +../src/com/FmbComFile.c \ +../src/com/FmbComPci.c \ +../src/com/FmbComRecv.c \ +../src/com/FmbComResolution.c \ +../src/com/FmbComStream.c \ +../src/com/FmbComplayer.c + +OBJS += \ +./src/com/FmbComBitrate.o \ +./src/com/FmbComCore.o \ +./src/com/FmbComDevice.o \ +./src/com/FmbComDriver.o \ +./src/com/FmbComFile.o \ +./src/com/FmbComPci.o \ +./src/com/FmbComRecv.o \ +./src/com/FmbComResolution.o \ +./src/com/FmbComStream.o \ +./src/com/FmbComplayer.o + +C_DEPS += \ +./src/com/FmbComBitrate.d \ +./src/com/FmbComCore.d \ +./src/com/FmbComDevice.d \ +./src/com/FmbComDriver.d \ +./src/com/FmbComFile.d \ +./src/com/FmbComPci.d \ +./src/com/FmbComRecv.d \ +./src/com/FmbComResolution.d \ +./src/com/FmbComStream.d \ +./src/com/FmbComplayer.d + + +# Each subdirectory must supply rules for building sources it contributes +src/com/%.o: ../src/com/%.c + @echo 'Building file: $<' + @echo 'Invoking: GCC C Compiler' + gcc $(CFLAGS) -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/fmb_player_apl/Release/src/sce/subdir.mk b/fmb_player_apl/Release/src/sce/subdir.mk new file mode 100644 index 0000000..7e005ba --- /dev/null +++ b/fmb_player_apl/Release/src/sce/subdir.mk @@ -0,0 +1,57 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../src/sce/FmbAp.c \ +../src/sce/FmbSceAudioFmtCore.c \ +../src/sce/FmbSceBitrate.c \ +../src/sce/FmbSceDecode.c \ +../src/sce/FmbSceEncode.c \ +../src/sce/FmbSceReset.c \ +../src/sce/FmbSceStream.c \ +../src/sce/FmbSceVideoFmtCore.c \ +../src/sce/FmbSceVideoFmtExtsyncCore.c \ +../src/sce/FmbSceWait.c \ +../src/sce/FmbScenario.c \ +../src/sce/MmuxAp.c + +OBJS += \ +./src/sce/FmbAp.o \ +./src/sce/FmbSceAudioFmtCore.o \ +./src/sce/FmbSceBitrate.o \ +./src/sce/FmbSceDecode.o \ +./src/sce/FmbSceEncode.o \ +./src/sce/FmbSceReset.o \ +./src/sce/FmbSceStream.o \ +./src/sce/FmbSceVideoFmtCore.o \ +./src/sce/FmbSceVideoFmtExtsyncCore.o \ +./src/sce/FmbSceWait.o \ +./src/sce/FmbScenario.o \ +./src/sce/MmuxAp.o + +C_DEPS += \ +./src/sce/FmbAp.d \ +./src/sce/FmbSceAudioFmtCore.d \ +./src/sce/FmbSceBitrate.d \ +./src/sce/FmbSceDecode.d \ +./src/sce/FmbSceEncode.d \ +./src/sce/FmbSceReset.d \ +./src/sce/FmbSceStream.d \ +./src/sce/FmbSceVideoFmtCore.d \ +./src/sce/FmbSceVideoFmtExtsyncCore.d \ +./src/sce/FmbSceWait.d \ +./src/sce/FmbScenario.d \ +./src/sce/MmuxAp.d + + +# Each subdirectory must supply rules for building sources it contributes +src/sce/%.o: ../src/sce/%.c + @echo 'Building file: $<' + @echo 'Invoking: GCC C Compiler' + gcc $(CFLAGS) -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/fmb_player_apl/Release/src/scr/subdir.mk b/fmb_player_apl/Release/src/scr/subdir.mk new file mode 100644 index 0000000..40882b4 --- /dev/null +++ b/fmb_player_apl/Release/src/scr/subdir.mk @@ -0,0 +1,183 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../src/scr/ConfEndOfPlay.c \ +../src/scr/ConfPauseStart.c \ +../src/scr/ConfPlay1pic.c \ +../src/scr/ConfPlayNormal.c \ +../src/scr/ConfRec1pic.c \ +../src/scr/ConfRecording.c \ +../src/scr/ExecPlay1pic.c \ +../src/scr/ExecPlayNormal.c \ +../src/scr/ExecPlayPause.c \ +../src/scr/ExecPlaySlow.c \ +../src/scr/ExecRecording.c \ +../src/scr/ExecScriptCommand.c \ +../src/scr/MainMenu.c \ +../src/scr/Screen.c \ +../src/scr/ScreenError.c \ +../src/scr/SelMultiDev.c \ +../src/scr/SelRecordDev.c \ +../src/scr/SelSingleDev.c \ +../src/scr/SetAudioBitrateAacEnc.c \ +../src/scr/SetAudioBitrateAc3Enc.c \ +../src/scr/SetAudioBitrateLpcmEnc.c \ +../src/scr/SetAudioBitrateMpeg1l2Enc.c \ +../src/scr/SetAudioFormatDec.c \ +../src/scr/SetAudioFormatEnc.c \ +../src/scr/SetConfigCom.c \ +../src/scr/SetFile.c \ +../src/scr/SetFileStartPos.c \ +../src/scr/SetFirmCom.c \ +../src/scr/SetInOutPidCom.c \ +../src/scr/SetInputPortDec.c \ +../src/scr/SetOption.c \ +../src/scr/SetOutputPortEnc.c \ +../src/scr/SetPidTypeCom.c \ +../src/scr/SetSubMenuCom.c \ +../src/scr/SetSubMenuDec.c \ +../src/scr/SetSubMenuEnc.c \ +../src/scr/SetSystemBitrate.c \ +../src/scr/SetTsPacketCom.c \ +../src/scr/SetTsTypeCom.c \ +../src/scr/SetVedioOut.c \ +../src/scr/SetVideoBitrateCbr.c \ +../src/scr/SetVideoBitrateVbr.c \ +../src/scr/SetVideoFormatDec.c \ +../src/scr/SetVideoFormatEnc.c \ +../src/scr/SetVideoFrameDec.c \ +../src/scr/SetVideoFrameEnc.c \ +../src/scr/SetVideoInOut.c \ +../src/scr/SetVideoOutBypass.c \ +../src/scr/SetVideoOutH264.c \ +../src/scr/SetVideoOutMode.c \ +../src/scr/SetVideoRatecontrol.c \ +../src/scr/SetVideoResolutionDec.c \ +../src/scr/SetVideoResolutionEnc.c \ +../src/scr/SetVideoScalerEnc.c + +OBJS += \ +./src/scr/ConfEndOfPlay.o \ +./src/scr/ConfPauseStart.o \ +./src/scr/ConfPlay1pic.o \ +./src/scr/ConfPlayNormal.o \ +./src/scr/ConfRec1pic.o \ +./src/scr/ConfRecording.o \ +./src/scr/ExecPlay1pic.o \ +./src/scr/ExecPlayNormal.o \ +./src/scr/ExecPlayPause.o \ +./src/scr/ExecPlaySlow.o \ +./src/scr/ExecRecording.o \ +./src/scr/ExecScriptCommand.o \ +./src/scr/MainMenu.o \ +./src/scr/Screen.o \ +./src/scr/ScreenError.o \ +./src/scr/SelMultiDev.o \ +./src/scr/SelRecordDev.o \ +./src/scr/SelSingleDev.o \ +./src/scr/SetAudioBitrateAacEnc.o \ +./src/scr/SetAudioBitrateAc3Enc.o \ +./src/scr/SetAudioBitrateLpcmEnc.o \ +./src/scr/SetAudioBitrateMpeg1l2Enc.o \ +./src/scr/SetAudioFormatDec.o \ +./src/scr/SetAudioFormatEnc.o \ +./src/scr/SetConfigCom.o \ +./src/scr/SetFile.o \ +./src/scr/SetFileStartPos.o \ +./src/scr/SetFirmCom.o \ +./src/scr/SetInOutPidCom.o \ +./src/scr/SetInputPortDec.o \ +./src/scr/SetOption.o \ +./src/scr/SetOutputPortEnc.o \ +./src/scr/SetPidTypeCom.o \ +./src/scr/SetSubMenuCom.o \ +./src/scr/SetSubMenuDec.o \ +./src/scr/SetSubMenuEnc.o \ +./src/scr/SetSystemBitrate.o \ +./src/scr/SetTsPacketCom.o \ +./src/scr/SetTsTypeCom.o \ +./src/scr/SetVedioOut.o \ +./src/scr/SetVideoBitrateCbr.o \ +./src/scr/SetVideoBitrateVbr.o \ +./src/scr/SetVideoFormatDec.o \ +./src/scr/SetVideoFormatEnc.o \ +./src/scr/SetVideoFrameDec.o \ +./src/scr/SetVideoFrameEnc.o \ +./src/scr/SetVideoInOut.o \ +./src/scr/SetVideoOutBypass.o \ +./src/scr/SetVideoOutH264.o \ +./src/scr/SetVideoOutMode.o \ +./src/scr/SetVideoRatecontrol.o \ +./src/scr/SetVideoResolutionDec.o \ +./src/scr/SetVideoResolutionEnc.o \ +./src/scr/SetVideoScalerEnc.o + +C_DEPS += \ +./src/scr/ConfEndOfPlay.d \ +./src/scr/ConfPauseStart.d \ +./src/scr/ConfPlay1pic.d \ +./src/scr/ConfPlayNormal.d \ +./src/scr/ConfRec1pic.d \ +./src/scr/ConfRecording.d \ +./src/scr/ExecPlay1pic.d \ +./src/scr/ExecPlayNormal.d \ +./src/scr/ExecPlayPause.d \ +./src/scr/ExecPlaySlow.d \ +./src/scr/ExecRecording.d \ +./src/scr/ExecScriptCommand.d \ +./src/scr/MainMenu.d \ +./src/scr/Screen.d \ +./src/scr/ScreenError.d \ +./src/scr/SelMultiDev.d \ +./src/scr/SelRecordDev.d \ +./src/scr/SelSingleDev.d \ +./src/scr/SetAudioBitrateAacEnc.d \ +./src/scr/SetAudioBitrateAc3Enc.d \ +./src/scr/SetAudioBitrateLpcmEnc.d \ +./src/scr/SetAudioBitrateMpeg1l2Enc.d \ +./src/scr/SetAudioFormatDec.d \ +./src/scr/SetAudioFormatEnc.d \ +./src/scr/SetConfigCom.d \ +./src/scr/SetFile.d \ +./src/scr/SetFileStartPos.d \ +./src/scr/SetFirmCom.d \ +./src/scr/SetInOutPidCom.d \ +./src/scr/SetInputPortDec.d \ +./src/scr/SetOption.d \ +./src/scr/SetOutputPortEnc.d \ +./src/scr/SetPidTypeCom.d \ +./src/scr/SetSubMenuCom.d \ +./src/scr/SetSubMenuDec.d \ +./src/scr/SetSubMenuEnc.d \ +./src/scr/SetSystemBitrate.d \ +./src/scr/SetTsPacketCom.d \ +./src/scr/SetTsTypeCom.d \ +./src/scr/SetVedioOut.d \ +./src/scr/SetVideoBitrateCbr.d \ +./src/scr/SetVideoBitrateVbr.d \ +./src/scr/SetVideoFormatDec.d \ +./src/scr/SetVideoFormatEnc.d \ +./src/scr/SetVideoFrameDec.d \ +./src/scr/SetVideoFrameEnc.d \ +./src/scr/SetVideoInOut.d \ +./src/scr/SetVideoOutBypass.d \ +./src/scr/SetVideoOutH264.d \ +./src/scr/SetVideoOutMode.d \ +./src/scr/SetVideoRatecontrol.d \ +./src/scr/SetVideoResolutionDec.d \ +./src/scr/SetVideoResolutionEnc.d \ +./src/scr/SetVideoScalerEnc.d + + +# Each subdirectory must supply rules for building sources it contributes +src/scr/%.o: ../src/scr/%.c + @echo 'Building file: $<' + @echo 'Invoking: GCC C Compiler' + gcc $(CFLAGS) -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/fmb_player_apl/Release/src/util/subdir.mk b/fmb_player_apl/Release/src/util/subdir.mk new file mode 100644 index 0000000..643f60c --- /dev/null +++ b/fmb_player_apl/Release/src/util/subdir.mk @@ -0,0 +1,27 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +C_SRCS += \ +../src/util/Debug.c \ +../src/util/Utility.c + +OBJS += \ +./src/util/Debug.o \ +./src/util/Utility.o + +C_DEPS += \ +./src/util/Debug.d \ +./src/util/Utility.d + + +# Each subdirectory must supply rules for building sources it contributes +src/util/%.o: ../src/util/%.c + @echo 'Building file: $<' + @echo 'Invoking: GCC C Compiler' + gcc $(CFLAGS) -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<" + @echo 'Finished building: $<' + @echo ' ' + + diff --git a/fmb_player_apl/include/CmdUtil.h b/fmb_player_apl/include/CmdUtil.h new file mode 100644 index 0000000..1fa5023 --- /dev/null +++ b/fmb_player_apl/include/CmdUtil.h @@ -0,0 +1,389 @@ +/** +* @brief Common header file for MB86 test program +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#ifndef __FMB_CMD_H__ +#define __FMB_CMD_H__ + +#include <stdio.h> +#include <stdlib.h> +#include <err.h> +#include <string.h> +#include <sys/ioctl.h> +#include <sys/utsname.h> +#include <fcntl.h> +#include <errno.h> +#include <unistd.h> + +#include <fmb_drv.h> + +/********************************************************/ +/* Command define */ +/********************************************************/ + +#define NG_USAGE -2 +#define NG_PARAM_ERROR -3 +#define NG_OPTION_ERROR -4 +#define NG_VERIFY_ERROR -5 + +#define NG_ERR_MALLOC -10 +#define NG_ERR_IOCTL -11 + +#define VERIFY_PARAM "/v" + + +#define HEXDEC_CHAR "x0123456789abcdefABCDEF" + +/********************************************************/ +/* Command description */ +/********************************************************/ + +enum FMBCmdEnm { + FMB_CMD_GPARAM, + FMB_CMD_SPARAM, + FMB_CMD_SCMD, + FMB_CMD_SVPARAM, + FMB_CMD_VCMD, + FMB_CMD_SAPARAM, + FMB_CMD_ACMD, + FMB_CMD_SACK, + FMB_CMD_RCBUF, + FMB_CMD_SMSG, + FMB_CMD_VMSG, + FMB_CMD_AMSG, + FMB_CMD_GFACT, + FMB_CMD_RFACT, + FMB_CMD_ASYNC, + FMB_CMD_GLSI, + FMB_CMD_SLSI, + FMB_CMD_DLSI, + FMB_CMD_GPCI, + FMB_CMD_SPCI, + FMB_CMD_GDATA, + FMB_CMD_SDATA, + FMB_CMD_VER, + FMB_CMD_STRM, + FMB_CMD_SLEEP, + FMB_CMD_LOGSTART, + FMB_CMD_LOGSTOP, + FMB_CMD_GOPSTART, + FMB_CMD_GOPSTOP, + FMB_CMD_BOOT, + FMB_CMD_HELP, + FMB_CMD_WAIT_MODE, + FMB_CMD_WAIT_SEQEND, + FMB_CMD_WAIT_SYMSG, + FMB_CMD_WAIT_SYACK, + FMB_CMD_WAIT_STRM_SEND, + FMB_CMD_WAIT_STRM_RCV, + FMB_CMD_PAUSE, + +}; +///Kind of stream mode. +enum FMBStremModeEnum{ + FMBEnmRcv, ///<Stream recive + FMBEnmSend, ///<Stream send + FMBEnmRcvSend, ///<Stream recive and send + FMBEnmNothing, ///<Stream Nothing +}; + +/********************************************************/ +/* parameter check information */ +/********************************************************/ + +struct param_check { + unsigned short short_cnvdata; /* convert data for short type */ + unsigned long long_cnvdata; /* convert data for long type */ + unsigned long result; /* parameter check result */ +}; + +/********************************************************/ +/* ioctl control information */ +/********************************************************/ +///Ioctl interface union. +union cmd_if_union { + struct fmb_param_info param_info; + struct fmb_ctl_param_info ctl_param_info; + struct fmb_lib_cmd_sys_info{ + unsigned short id; + unsigned short sub_id; + struct fmb_cmd_sys_info cmd_sys_info; + }lib_cmd_sys_info; + struct fmb_cmd_video_info cmd_video_info; + struct fmb_cmd_audio_info cmd_audio_info; + struct fmb_cmd_ack_sys_info cmd_ack_sys_info; + struct fmb_cmd_info_reset cmd_info_reset; + struct fmb_msg_sys_info msg_sys_info; + struct fmb_msg_video_info msg_video_info; + struct fmb_msg_audio_info msg_audio_info; + struct fmb_factor_info factor_info; + struct fmb_factor_reset factor_reset; + struct fmb_async_info async_info; + struct fmb_reg_info reg_info; + struct fmb_internal_info internal_info; + struct fmb_pci_reg_info pci_reg_info; + struct fmb_lib_version_info{ + char driver_ver[FMB_DRIVER_VERSION_LENGTH]; + unsigned short firm_ver[FMB_VERSION_REG_SIZE / 2]; + struct fmb_version_info version_info; + }lib_version_info; +}; +///Ioctl lib private information. +struct ioctl_private_inf { + enum FMBCmdEnm cmd_id; ///<Ioctl ID. + union cmd_if_union cmd_str; + unsigned short* private_buf; + unsigned short private_data; + unsigned long private_ldata; + int fd; +}; + +struct ioctl_inf { + unsigned short short_cnvdata; /* convert data for short type */ + unsigned long long_cnvdata; /* convert data for long type */ + unsigned long result; /* parameter check result */ +}; + +/********************************************************/ +/* function call information */ +/********************************************************/ + +typedef int (*FUNCTION)(struct ioctl_private_inf*, int , char**); + +struct jump_head_table { + char* option_parameter; /* option parameter string */ + FUNCTION function_addr; + unsigned int ioctl_cmd; +}; + +/********************************************************/ +/* error message information */ +/********************************************************/ + +#define MSG_ERR_MALLOC "malloc()" +#define MSG_ERR_IOCTL "ioctl()" + + +/********************************************************/ +/* prototype description */ +/********************************************************/ +unsigned short FmbgetVmode( void ); + +unsigned short FmbgetVseqend( void ); + +unsigned short FmbgetSbody( void ); + +int FmbCreateArgment(char* keybuff,char** argvStr); + +int FmbgetArg(char* sarchchar , int argc, char** argv); + +int FmbgetArgOwn(char* sarchchar , int argc, char** argv); + +void FmbErrPrint(char* comment , char* file , int line); + +void FmbErrPrintUsr(char* comment , char* file , int line); + +int FmbIoctlmain( int argc, char** argv); + +void FmbUsageMainPrint(void); + +void FmbStartCommandPrint(enum FMBCmdEnm command_id); + +void FmbEndCommandPrint(enum FMBCmdEnm command_id); + +struct SceTableType* FmbCeateCommandScenario(char* cmdbuff); + +/********************************************************/ +/* Utility description */ +/********************************************************/ + +///Boolean type +typedef enum BoolEnum{ + FALSE, + TRUE +} BOOL; + +/** +* @brief The number of indices of the array is returned. +* @param[in] array Target array. +* @return Number of array elements. +* @note None +* @attention None +*/ +#define ArraySizeOf(array) (sizeof(array) / sizeof(array[0])) + +//It rounds up below the decimal point, and it converts it into the integer type. +unsigned int RoundUpDouble(double value); + +//The character string is converted into the integer of the sign none. +//The value of the minus is returned for an invalid character string. +int StrToUnsignedInt(char *str); + +__off64_t StrToOff64(char *str); + + +//It exclusive enters. +void EnterEx(void); + +//It comes off exclusion. +void ExitEx(void); + +void fprintOut( FILE *stream,const char *formatPtr, ...); +void gprintOut( const char *formatPtr, ...); +void printOut( const char *formatPtr, ...); +void vfprintOut (FILE *stream, __const char *formatPtr,_G_va_list arg_list); + +BOOL StartLogFile(char* filepath ,char* att); + +BOOL StopLogFile(void); + +BOOL StartGopFile(char* filepath ,char* att); + +BOOL StopGopFile(void); + + +/********************************************************/ +/* Debug description */ +/********************************************************/ + +///Debug module property +struct DbgInfo{ + BOOL isFuncTrace; + BOOL isRecvTrace; + BOOL isRecvDumpTrace; + BOOL isFmbLog; + BOOL isFmbLogCmd; + BOOL isSceTrace; + BOOL isScrLog; + BOOL isMessageFilterOn; + BOOL isAV_SYNC_Exit; + BOOL isFmbLogEvent; + BOOL isScrEventLog; + BOOL isTS_PSIZE_Exit; + BOOL isNotRecMessages; +}; + +extern struct DbgInfo g_dbg; + +void TraceFunc( BOOL isIn, + const char *fileName, + const char *funcName); + +void InitDbg(char *dbgOption); + +/** +* @brief The result of the function that sets the error code in errno is inspected. +* @param[in] isOk TRUE:No problem FALSE:Log and abnormal end. +* @param[in] comment Comment for logging. +* @return None +* @note None +* @attention None +*/ +#define ASSERT_SYS(isOk, comment) \ + do{\ + if(!(isOk)){\ + fprintf(stderr, "ERR:%s(%d)",__FILE__, __LINE__);\ + err(1, (comment));\ + }\ + }while(0) + +/** +* @brief Inspection processing for program contradiction check. +* @param[in] isOk TRUE:No problem FALSE:Log and abnormal end. +* @param[in] comment Comment for logging. +* @return None +* @note None +* @attention None +*/ +#define ASSERT_USR(isOk, comment) \ + do{\ + if(!(isOk)){\ + fprintf(stderr, "ERR:%s(%d):", __FILE__, __LINE__);\ + fprintf(stderr, "%s\n", (comment));\ + exit(1);\ + }\ + }while(0) + + +/** +* @brief The function trace is output to the standard error output. +* @param[in] isIn TRUE:Function in. FALSE:Function out. +* @return None +* @note None +* @attention None +*/ +#define FMB_FUNC(isIn) \ + do{\ + if(g_dbg.isFuncTrace){\ + TraceFunc((isIn), __FILE__, __func__);\ + }\ + }while(0) + +void TraceRecv(int num, char *format, ...); +void LogFmb(char *format, ...); +void TraceSce(char *format, ...); +void TraceRecvDump(int num, char *head, unsigned short rcvs[], int size); +void LogScr(char *format, ...); + +void InitFuncTraceMain(); +void InitFuncTraceRecv(int num); +void InitFuncTraceRecvStream(int num); +void InitFuncTraceSendStream(int num); +void InitFuncTraceBoot(int num); + +void SetFuncTraceCallDepth(int num, int callDepthMain, int callDepthRecv, + int callDepthRecSt, int callDepthSndSt, int callDepthBoot); +void LogFmbEvent(int evnt[], int num); +void LogScrEvent(char *format, ...); +void LogFmbCmd(char *format, ...); + +/********************************************************/ +/* prototype description */ +/********************************************************/ + +int get_field_param(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_field_param(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int send_cmd_sys(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_video_param(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int send_cmd_video(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_audio_param(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int send_cmd_audio(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_sys_cmd_ack(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int reset_cmd_info(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_msg_sys(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_msg_video(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_msg_audio(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_factor(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int reset_factor(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_async_info(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_lsi_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_lsi_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int dump_lsi_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_pci_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_pci_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_drv_internal_info(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_drv_internal_info(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_i2c_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int set_i2c_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int get_version_info(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int strm_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int sleep_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int logstart_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int logstop_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int gopstart_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int gopstop_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int boot_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); +int help_command(struct ioctl_private_inf* pri_inf, int argc, char** argv); + +#endif /* ndef __FMB_CMD_H__ */ diff --git a/fmb_player_apl/include/FmbAp.h b/fmb_player_apl/include/FmbAp.h new file mode 100644 index 0000000..bd4b5d2 --- /dev/null +++ b/fmb_player_apl/include/FmbAp.h @@ -0,0 +1,651 @@ +/** +* @brief API of the device module is declared. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#ifndef __FMBDEVICE_H_ +#define __FMBDEVICE_H_ + +#include "MmuxAp.h" + + +/** +* @brief Audio format. +* @note None +* @attention None +*/ +enum FMBAudioFormatEnum{ + FMBEnmAudioFmtMpeg1l2, + FMBEnmAudioFmtAc3, + FMBEnmAudioFmtAac, + FMBEnmAudioFmtLpcm, + FMBEnmAudioFmtMax +}; + +/** +* @brief Audio LPCM bitrate. +* @note None +* @attention None +*/ +enum FMBAudioLpcmEnum{ + FMBEnmAudioLpcm16stereo, +}; + +/** +* @brief Input and output port. +* @note None +* @attention None +*/ +enum FMBPortEnum{ + FMBEnmPortFile, + FMBEnmPortStreamport, +}; + + +/** +* @brief Video rate control. +* @note None +* @attention None +*/ +enum FMBVideoRateCtlEnum{ + FMBEnmVideoRateCtlCbr, + FMBEnmVideoRateCtlVbr, +}; + + +/** +* @brief Video format control. +* @note None +* @attention None +*/ + +enum FMBVideoFormatEnum{ + FMBEnmVideoFmt1920x1080, + FMBEnmVideoFmt1440x1080, + FMBEnmVideoFmt1280x720, + FMBEnmVideoFmt720x480, + FMBEnmVideoFmt720x576, + FMBEnmVideoFmtMax +}; + +/** +* @brief Video frame rate control. +* @note None +* @attention None +*/ + +enum FMBVideoFrameEnum{ + FMBEnmVideoFrm_60p, + FMBEnmVideoFrm_5994p, + FMBEnmVideoFrm_50p, + FMBEnmVideoFrm_60i, + FMBEnmVideoFrm_5994i, + FMBEnmVideoFrm_50i, + FMBEnmVideoFrmMax +}; + +/** +* @brief Video resolution control. +* @note None +* @attention None +*/ + +enum FMBVideoResolutionEnum{ + FMBEnmVideoRsltn_NONE = 0, + FMBEnmVideoRsltn_1920_1080_60p, + FMBEnmVideoRsltn_1920_1080_59p, + FMBEnmVideoRsltn_1920_1080_50p, + FMBEnmVideoRsltn_1920_1080_60i, + FMBEnmVideoRsltn_1920_1080_59i, + FMBEnmVideoRsltn_1920_1080_50i, + FMBEnmVideoRsltn_1440_1080_60i, + FMBEnmVideoRsltn_1440_1080_59i, + FMBEnmVideoRsltn_1440_1080_50i, + FMBEnmVideoRsltn_1280_720_60p, + FMBEnmVideoRsltn_1280_720_59p, + FMBEnmVideoRsltn_1280_720_50p, + FMBEnmVideoRsltn_720_480_60i, + FMBEnmVideoRsltn_720_480_59i, + FMBEnmVideoRsltn_720_576_50i, + FMBEnmVideoRsltnMax +}; + +/** +* @brief Video Scaler for encode. +* @note None +* @attention None +*/ + +enum FMBVideoScalerEncEnum{ + FMBEnmVideoSclEnc_NotUse, + FMBEnmVideoSclEncMax +}; + +/** +* @brief Request status. +* @note None +* @attention None +*/ + +enum FMBRequestEnum{ + FMBEnmReqNothing, + FMBEnmReqInitEnc1pic, + FMBEnmReqInitEnc, + FMBEnmReqInitDec, + FMBEnmReqInitDec1pic, + FMBEnmReqInitStartPause, + FMBEnmReqStartEnc, + FMBEnmReqStartEnc1Pic, + FMBEnmReqStartDecNormal, + FMBEnmReqStartDecSlow, + FMBEnmReqStartDecFrameAdvance, + FMBEnmReqStartDec1pic, + FMBEnmReqPause, + FMBEnmReqStop, + FMBEnmReqReset, + FMBEnmReqMute, + FMBEnmReqAutoStop, + FMBEnmReqStopDecCore, + FMBEnmReqStartCommand, +}; + + +/** +* @brief Function mode. +* @note None +* @attention None +*/ + +enum FMBFuncModeEnum{ + FMBEnmFuncModeEnc, + FMBEnmFuncModeDec, +}; + + +/** +* @brief Kind of bitrate calcuration. +* @note None +* @attention None +*/ +enum FMBBitrateCalcEnum{ + FMBEnmBitrateCalcVideobase, + FMBEnmBitrateCalcSystembase, +}; + + +/** +* @brief TS packet type +* @note None +* @attention None +*/ + +enum FMBTsPacketTypeEnum{ + FMBEnmInputTsPacket, + FMBEnmOutputTsPacket, + FMBEnmTsPacketMax +}; + +/** +* @brief TS format. +* @note None +* @attention None +*/ + +enum FMBTsFormatEnum{ + FMBEnmTsFormat188, + FMBEnmTsFormat192, + FMBEnmTsFormat192e, +}; + + +/** +* @brief State of waiting send stream thread. +* @note None +* @attention None +*/ +enum FMBStreamSendEndStateEnum{ + FMBEnmStreamSendEndOff, + FMBEnmStreamSendEndOn, +}; + + +/** +* @brief Running state of request. +* @note None +* @attention None +*/ + +enum FMBResultEnum{ + FMBEnmResultContinue, ///<The request is being executed. + FMBEnmResultRequestComplete, ///<The request was completed. +}; + +/** +* @brief PID type. +* @note None +* @attention None +*/ + +enum FMBPidTypeEnum{ + FMBEnmInputVideoPid, + FMBEnmInputAudioPid, + FMBEnmInputPmtPid, + FMBEnmInputSitPid, + FMBEnmInputPcrPid, + FMBEnmOutputVideoPid, + FMBEnmOutputAudioPid, + FMBEnmOutputPmtPid, + FMBEnmOutputSitPid, + FMBEnmOutputPcrPid, + + FMBEnmPidMax +}; + +/** +* @brief Device number. +* @note None +* @attention None +*/ +enum FMBDeviceNumEnum { + FMBEnmDevice_NONE = -1, + FMBEnmDevice_0 = 0, + FMBEnmDevice_1, + FMBEnmDevice_2, + FMBEnmDevice_3, + FMBEnmDevice_4, + FMBEnmDevice_5, + FMBEnmDevice_6, + FMBEnmDevice_7, + + FMBEnmDeviceMax +}; + +/** +* @brief CBR max bitrate value. +* @note None +* @attention None +*/ +#define FMB_MAX_BITRATE_CBR 65535 + + +/** +* @brief VBR max bitrate value. +* @note None +* @attention None +*/ +#define FMB_MAX_BITRATE_VBR 65535 + +/** +* @brief Number of function mode. +* @note None +* @attention None +*/ +#define FMB_FUNCTION_MODE_NUM 3 + +/** +* @brief PID max value. +* @note None +* @attention None +*/ +#define FMB_MAX_PID_VALUE 0x1FFF + +#define FMB_MAX_STREAM 2 // FMBEnmStreamMAX + + +#define FMB_AUDIO_FORMAT_KIND 4 + +//#define FMB_TS_PACKET_TYPE 3 + +#define FMB_DEVNAME_CHAR "fmb" +#define FMB_DEVNAME_MAX_CHAR 24 +#define FMB_KEYBUFF_MAX_CHAR 202 +#define FMB_BITRATE_MAX_CHAR FMB_KEYBUFF_MAX_CHAR +#define FMB_FACTOR_MAX_CHAR 512 +#define FMB_ERRINFO_MAX_CHAR 512 +#define FMB_FILEPATH_MAX_CHAR FMB_KEYBUFF_MAX_CHAR +#define FMB_FIRMPATH_MAX_CHAR FMB_KEYBUFF_MAX_CHAR + +#define FMB_FILEPATH_MIN_CODE_RANGE 0x21 +#define FMB_FILEPATH_MAX_CODE_RANGE 0x7E +#define FMB_KEY_ESC 0x1b +#define FMB_KEY_CTRL_O 0x0f +#define FMB_KEY_CTRL_X 0x18 + +#define FMB_CODE_INVALID_KIND 8 +#define FMB_CODE_QUOTATION_MARKS 0x22 +#define FMB_CODE_ASTERISK 0x2A +#define FMB_CODE_COLON 0x3A +#define FMB_CODE_LESS_THAN_SIGN 0x3C +#define FMB_CODE_GRATER_THAN_SIGN 0x3E +#define FMB_CODE_QUESTION_MARK 0x3F +#define FMB_CODE_BACKSLASH 0x5C +#define FMB_CODE_BERTIE_KALVER 0x7C + +#define FMB_DEFUALT_BITRATE_CBR_ENC 6000 +#define FMB_DEFUALT_BITRATE_VBR_AVE_ENC 6000 +#define FMB_DEFUALT_BITRATE_VBR_PEAK_ENC 9000 +#define FMB_DEFUALT_BITRATE_AUDIO 256 +#define FMB_DEFUALT_BITRATE_AUDIO_LPCM 1536 //< 16bit 48Khz stereo2ch=(16*48*2)kbps +#define FMB_DEFUALT_FILEPATH_OUT_ENC "./outputstream.mpg" +#define FMB_DEFUALT_FILEPATH_IN_DEC "./inputstream.mpg" +#define FMB_DEFUALT_FILENAME "./stream" +#define FMB_DEFUALT_FILENAME_EXT ".mpg" + +#define FMB_DEFAULT_INPUT_VIDEO_PID 0x1011 +#define FMB_DEFAULT_INPUT_AUDIO_PID 0x1100 +#define FMB_DEFAULT_INPUT_PMT_PID 0x0100 +#define FMB_DEFAULT_INPUT_SIT_PID 0x001f +#define FMB_DEFAULT_INPUT_PCR_PID 0x1001 +#define FMB_DEFAULT_OUTPUT_VIDEO_PID 0x1011 +#define FMB_DEFAULT_OUTPUT_AUDIO_PID 0x1100 +#define FMB_DEFAULT_OUTPUT_PMT_PID 0x0100 +#define FMB_DEFAULT_OUTPUT_SIT_PID 0x001f +#define FMB_DEFAULT_OUTPUT_PCR_PID 0x1001 + +///< PCI address BAR0 +#define PCI_OUSER_ADDR 0x80 + +///< PCI address BAR1 +#define PCI_ENC_IF_CTL_ADDR 0x1E2010 +#define PCI_ENC_IF_OPT_ADDR 0x1E2014 +#define PCI_DEC_IF_CTL_ADDR 0x1E4010 +#define PCI_DEC_IF_OPT_ADDR 0x1E4014 + +///< LSI control register +#define LSI_GPIO_CNT_ADDR 0x90014 +#define LSI_GPIO_OUT_ADDR 0x90018 + +///< VBR max audio bitrate value. +#define FMB_MAX_AUDIO_BITRATE_VBR 512 + +///< VBR min audio bitrate value. +#define FMB_MIN_AUDIO_BITRATE_VBR 128 + +///< Audio Format menu strings. +#define AUDIO_FMT_UNSUPPORTED_STR "(unsupported)" +#define AUDIO_FMT_UNSUPPORTED_STR_LEN 14 +#define AUDIO_FMT_VALIDCHAR_LEN 8 + +/** +* @brief Bitrate struct data. +* @note None +* @attention None +*/ + +struct FMBVideoBitrateParam{ + unsigned short vRateMode; + unsigned long vBitrate; + unsigned short vAveBitrate; + unsigned short vMinBitrate; + unsigned short vMaxBitrate; + unsigned long muxRate; + BOOL isValid; +}; + + +struct FMBVideoBitrateProp { + enum FMBVideoRateCtlEnum videoRateCtl; ///<Kind of video bitrate control + enum FMBBitrateCalcEnum bitrateCalckind; ///<System bitrate calcurate weither system base or video base. + int videoBitrateCbr; ///<Video bitrate in CBR + int videoBitrateVbrAverage; ///<Video average bitrate in VBR + int videoBitrateVbrPeak; ///<Video peak bitrate in VBR + int systemMuxRate; ///<System bitrate + struct FMBVideoBitrateParam videoBitrateParam; ///<Video bitrate parameter(struct data) +}; + +/** +* @brief Property struct data. +* @note None +* @attention None +*/ + +struct FMBProperty{ + enum FMBAudioFormatEnum audioFmt; ///<Audio Format + int audioFmtReload; ///<Audio Format Reload data + int audioBitrateCbr[FMB_AUDIO_FORMAT_KIND]; ///<Audio average bitrate (kbps) + int audioBitrateVbrAverage; ///<Audio average bitrate (kbps) + int audioBitrateVbrPeak; ///<Audio peak bitrate ,only use AAC(kbps) + enum FMBAudioLpcmEnum audioLpcm; ///<Audio LPCM + enum FMBPortEnum inputPort; ///<Kind of input port + enum FMBPortEnum outputPort; ///<Kind of output port + char inputfile[FMB_FILEPATH_MAX_CHAR]; ///<Input file path + char outputfile[FMB_FILEPATH_MAX_CHAR]; ///<Output file path + struct FMBVideoBitrateProp videoBitrateProp; + enum FMBVideoFormatEnum videoFmt; ///<Kind of video format + enum FMBVideoFrameEnum videoFrm; ///<Kind of video frame + enum FMBVideoResolutionEnum videoRsltn; ///<Kind of video resolution + enum FMBVideoScalerEncEnum videoScalerEnc; ///<Kind of video Scaler enc + double speedSlow; ///<play slow speed + BOOL isMute; ///<TRUE:Audio-status is mute. FALSE:Audio-status is not mute. +}; + + +/** +* @brief Common property struct data.. +* @note None +* @attention None +*/ +struct FMBComProperty{ + enum FMBFuncModeEnum setMode; ///<Kind of Mode(enc/dec) + enum FMBRequestEnum currentRequest; ///<Kind of current request + enum FMBRequestEnum lastRequest; ///<Kind of last request + BOOL isInternalDecodeStatus; ///<TRUE:Status is decoding. FALSE:Status is not decoding. + int deviceFd; //<device handle. + char devicePath[FMB_DEVNAME_MAX_CHAR]; ///<save device path(when application start,devicePath is set(/dev/fjfmb0 or /dev/fjfmb1 etc).) + char deviceName[FMB_DEVNAME_MAX_CHAR]; ///<save device name(when application start,deviceName is set(fjfmb0 or fjfmb1 etc).) + enum FMBTsFormatEnum tsFormat[FMBEnmTsPacketMax]; ///<Kind of TS format(188 ,192,192e) + enum FMBStreamSendEndStateEnum waitStreamSendEnd; ///<wait indication Stream send end + enum FMBPidTypeEnum PidType; ///<Current PID Type + enum FMBTsPacketTypeEnum TsType; ///<Current TS packet type + int PidValue[FMBEnmPidMax]; ///<PID value + char configPath[FMB_FIRMPATH_MAX_CHAR]; ///<save config path + HANDLE hEmptyScet; + enum FMBDeviceNumEnum deviceNum; + int fdPipeWrite; + int fdPipeRead; + enum FMBResultEnum fmbRc; +}; + + +struct RecvEnv { + char *p_devicePath; ///<save device path(when application start,devicePath is set(/dev/fjfmb0 or /dev/fjfmb1 etc).) + enum FMBDeviceNumEnum deviceNum; + int *p_fdPipeWrite; + int *p_fdPipeRead; +}; + +struct RecvThread { + struct RecvEnv t_env; + pthread_t thread; +}; + +struct BootEnv { + char driver_ver[FMB_DRIVER_VERSION_LENGTH]; + unsigned short firm_ver[FMB_VERSION_REG_SIZE / 2]; + + char *p_firmPath; + unsigned short *p_firmLSIVer; + struct fmb_version_info *p_version_info; + unsigned long *p_subSystemId; + int *p_deviceFd; + HANDLE *p_sceHandle; + int *p_fdPipeRead; +}; + +struct BootThread { + struct BootEnv t_env; + pthread_t thread; +}; + +struct StreamThread { + void* start_routine; + unsigned char* fBuf; + BOOL isThread; + BOOL isStop; + BOOL isForceStop; + int fmbfd; + int fd; + unsigned int streamSize; + BOOL isFrameUpdate; + BOOL isSeqEnd; + BOOL isSystemCmdAck; + int fSize; + int priority; + __off64_t fileStartPos; + __off64_t fileEndPos; + enum FMBDeviceNumEnum deviceNum; + int *p_fdPipeWrite; +}; + +struct FMBDeviceInfo { + struct FMBProperty t_Property_A[FMB_FUNCTION_MODE_NUM]; + struct FMBComProperty t_ComProperty; + struct RecvThread t_RecvThread; + struct BootThread t_BootThread; + struct StreamThread t_StreamThread_A[FMB_MAX_STREAM]; + + int used; + BOOL stateAutoStop; + unsigned short firmLSIVer; + struct fmb_version_info version_info; + unsigned long subSystemId; + HANDLE hSceCurrent; //Scenario executing it now. +}; + + +/** +* @brief Information struct data.. +* @note None +* @attention None +*/ +struct FMBInfo { + BOOL isDeviceSelecting; + enum FMBDeviceNumEnum currentDeviceNum; + enum MMUXDeviceNumEnum currentMmxuDevNum; + int totalCodecChip; + int countCodecChip; + int totalBorad; + char firmPath_A[FMB_FIRMPATH_MAX_CHAR]; ///<save farm path + struct FMBDeviceInfo *pt_deviceInfo_A[FMBEnmDeviceMax]; + MmuxHandle hdMmux_A[MMUXDeviceMax]; +}; + + +int FmbInit(struct FMBDeviceInfo *p_DevInfo, enum FMBDeviceNumEnum deviceNum); +void FmbTerminate(struct FMBDeviceInfo *p_DevInfo); +void FmbInitEnc1pic(void); +void FmbInitEnc(void); +void FmbInitDec(void); +void FmbInitDec1pic(void); +void FmbInitStartPause(void); +void FmbStartEnc(void); +void FmbStartEnc1Pic(void); +void FmbStartDecNormal(void); +void FmbStartDec1pic(void); +enum FMBResultEnum FmbStartDecSlow(void); +void FmbStartDecFrameAdvance(void); +void FmbPause(void); +void FmbSetMuteMode(void); +void FmbStop(void); +void FmbDecStopCore(void); +void FmbStop1picDec(void); +void FmbReset(void); +BOOL FmbCancelRequest(void); +BOOL FmbCheckSenario(void); +enum FMBResultEnum FmbStartCommand(char* cmdbuf); +enum FMBResultEnum FmbStartCommandSenario(struct SceTableType* cmdtable); +void FmbApplySettingGpioVideoFormat(void); + + +int FmbInitInfo(void); +void FmbReleaseInfo(void); +int FmbCreatDevInfoAll(void); +void FmbDellDevInfoAll(void); +int FmbCreatDevInfo( char *p_devicePath ); +void FmbDelDevInfo(enum FMBDeviceNumEnum deviceNum); + +int FmbGetDeviceTotal(void); +int FmbGetBoardTotal(void); + +void FmbEnableDeviceSel(void); +void FmbDisableDeviceSel(void); +BOOL FmbIsNotDeviceSelecting(void); + +void FmbSetCurDeviceNum(enum FMBDeviceNumEnum deviceNum); +enum FMBDeviceNumEnum FmbGetCurDeviceNum(void); +enum FMBDeviceNumEnum FmbGetCurDevNumOnBoard(void); + +struct FMBDeviceInfo *FmbGetCurDevInfo(void); +struct FMBDeviceInfo *FmbGetDevInfo(enum FMBDeviceNumEnum deviceNum); +struct FMBProperty *FmbGetProperty(enum FMBDeviceNumEnum deviceNum); +struct FMBComProperty *FmbGetComProperty(enum FMBDeviceNumEnum deviceNum); + +int FmbGetRecvWtireHd(enum FMBDeviceNumEnum deviceNum); +int FmbGetRecvReadHd(enum FMBDeviceNumEnum deviceNum); +int FmbGetDeviceHd(enum FMBDeviceNumEnum deviceNum); +HANDLE FmbGetHandSceCurrent(void); +void FmbSetHandSceCurrent(HANDLE hSceCurrent); + +enum MMUXDeviceNumEnum FmbGetCurMmuxDevNum(void); +void FmbSetCurMmuxDevNum(enum MMUXDeviceNumEnum deviceNum); +MmuxHandle FmbGetCurMmuxHd(void); +MmuxHandle FmbGetMmuxHd(enum MMUXDeviceNumEnum deviceNum); + +enum FMBDeviceNumEnum FmbSetFirstDev(void); +enum FMBDeviceNumEnum FmbSetNextDev(void); +void FmbMultiCall(void (*fun)(void)); + +void FmbEnableDevUse(enum FMBDeviceNumEnum deviceNum); +void FmbDisableDevUse(enum FMBDeviceNumEnum deviceNum); +void FmbEnableDevUseAll(void); +void FmbDisableDevUseAll(void); +int FmbIsDevUse(enum FMBDeviceNumEnum deviceNum); + +enum FMBResultEnum OnFmbMessage(int fd); + +//The bitrate-parameter set in the core is actually calculated. +BOOL FmbCalcVideoBitrateParam(struct FMBVideoBitrateProp *p_VidoBitrateProp, + enum FMBVideoFrameEnum videoFrm, + enum FMBAudioFormatEnum audioFmt); + +void DrvSetIsNotify(HANDLE sceHandle, BOOL isNotify); + +inline enum FMBVideoResolutionEnum FmbRsltnMmux2Fmb(enum MMUX_RESOLUTION resolution_Mmux); +void FmbSetVideoFormat(enum FMBVideoResolutionEnum resolution_Fmb, enum FMBFuncModeEnum setmode); +int FmbAutoSetCurVideoFormat(void); + + +extern struct FMBInfo* const gp_FmbInfo; + +struct FMBDeviceInfo *gp_FmbDevInfo; +extern struct FMBProperty *gp_FmbProperty; +extern struct FMBComProperty *gp_FmbComProperty; + + +extern const char *g_FmbNamePort[]; ///< Input & Output Port name +extern const char *g_FmbNameVideoRateCtls[]; ///< Video rate control name +extern const char *g_FmbNameVideoFmts[]; ///< Video format name +extern const char *g_FmbNameAudioFmts[]; ///< Audio format name +extern const char *g_FmbNameVideoFrms[]; ///< Video framerate name +extern const char *g_FmbNameVideoRsltn[]; ///< Video resolution name +extern const char *g_FmbNameVideoSclEncs[]; ///< Video scaler encode name +extern const char *g_FmbNamePacketSize[]; ///< Packet size name(H52_ESL-0126) +extern const char *g_FmbNameTSFormat[]; ///< TS format name +extern const unsigned short g_FmbGpioVideoFormat[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; ///< Video Format GPIO setting +extern const unsigned short g_FmbInitVideoFormat[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; ///< V_FORMAT setting +extern const unsigned short g_FmbInitVideoIpFormat[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; ///< V_IP_FORMAT setting +extern const unsigned short g_FmbInitVideoSclEnc[FMBEnmVideoFmtMax][FMBEnmVideoSclEncMax]; ///< V_STRM_FORMAT setting +extern const unsigned short g_FmbVideoEsInfoFormatBD0C[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; ///< ES_INFO_0C(BD) setting +extern const unsigned short g_FmbVideoEsInfoFormatDVB06[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; ///< ES_INFO_06(DVB) setting +#endif //__FMBDEVICE_H_ + diff --git a/fmb_player_apl/include/FmbCmn.h b/fmb_player_apl/include/FmbCmn.h new file mode 100644 index 0000000..63fe990 --- /dev/null +++ b/fmb_player_apl/include/FmbCmn.h @@ -0,0 +1,323 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+
+/** +* @brief Common header file in device module. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#ifndef __FMBCMN_H_ +#define __FMBCMN_H_ + +#include <fmb_drv.h> +#include "CmdUtil.h" +#include "SceCmn.h" +#include "MmuxAp.h" +#include "FmbAp.h" + +#define OK 0 +#define NG -1 + +#define OFF 0 +#define ON 1 + +/* + Core enum +*/ + +///Kind of device in LSI. +enum FMBCoreDviceEnum{ + FMBEnmCoreDeviceSystem, ///<System + FMBEnmCoreDeviceAudio, ///<Audio + FMBEnmCoreDeviceVideo, ///<Video + FMBEnmCoreDeviceStream, ///<Stream +}; + +///Kind of event from LSI. +enum FMBCoreEventEnum{ + FMBEnmCoreFromAck, ///<Ack event + FMBEnmCoreFromMsg, ///<Message event + FMBEnmCoreFromSteamEndMsg, ///<Stream End Message event + FMBEnmCoreFromInputKey, ///<Input Key event +}; + +///Type of argument to recv module that waits for event. +struct RecvEventArgType{ + enum FMBDeviceNumEnum devNum; ///<Kind of device number + enum FMBCoreDviceEnum dev; ///<Kind of device + enum FMBCoreEventEnum evnt; ///<Kind of event + union{ + struct{ + int id; + int sub_id; + }SysAck; + struct{ + int id; + int sub_id; + int body; + }SysMsg; + struct{ + int mode; + int submode; + int seq_end; + }VideoMsg; + struct{ + int mute; + int ch; + }AduioMsg; + struct{ + int id; + }StreamMsg; + } WaitDetail; ///<Event of detail +}; + + +/* + Driver input/output. +*/ + +#define DEFAULT_FMB_DRIVER "/dev/h55fmb0" +#define DEFAULT_FMB_PATH "/dev/h55fmb" + + +#define DEFAULT_FMB_FIRMPATH "/usr/local/etc/mb86h56.bin" +#define DEFAULT_FMB_SECONDARY_FIRMPATH "/usr/local/etc/mb86h55.bin" +#define FMB_FIRM_TIMEOUT 10000 +#define FIRM_WRITE_SIZE (512 * 1024) /* 512KB */ + +#define DEFAULT_FMB_CONFIGPATH "/usr/local/etc/fmb_player_apl_" +#define DEFAULT_FMB_CONFIGEXT ".conf" + +//The MB86 device driver is opened. +int DrvOpen(char *argDriverPath); + +//The MB86 device driver is closed. +void DrvClose(int fd); + +//The ioctl wrapper. +int DrvIoctl(int fd, int req, void *pvArg); + +//The ioctl wrapper(use only FmbCmd). +int DrvIoctlCmd(int fd, int req, void *pvArg); + +//The MB86 device driver cmd-info is reseted. +enum SceResultEnum DrvResetCmdInfo(HANDLE sceHandle, unsigned long type, unsigned long dummy1, unsigned long dummy2); + +//The MB86 device driver cmd-info is reseted. +enum SceResultEnum DrvResetFactor(HANDLE sceHandle, unsigned long factor, unsigned long dummy1, unsigned long dummy2); + +//The MB86 device driver internal data is set. +enum SceResultEnum DrvSetInternal(HANDLE sceHandle, unsigned long type, unsigned long data, unsigned long dummy2); + +//Write a firmware and boot up the firmware +enum SceResultEnum DrvBootUp(HANDLE sceHandle, char *firmPath, unsigned long dummy2,unsigned long dummy3); + +int DrvBootAll(void); +int CheckVersionInfo(void); + +/* PCI type */ +#define PCI_TYPE_BAR0 0 +#define PCI_TYPE_BAR1 1 +#define PCI_TYPE_BAR2 2 + +//To set the register value to each PCI +enum SceResultEnum PciSetReg( HANDLE sceHandle, + unsigned long reg_type, + unsigned long offset, + unsigned long prm_data); + +//To get the register value to each PCI +unsigned long PciGetReg( HANDLE sceHandle, + unsigned long reg_type, + unsigned long offset); + +//To set the register value to LSI +enum SceResultEnum LsiSetReg( HANDLE sceHandle, + unsigned long offset, + unsigned long value, + unsigned long dummy); + +//To get the register value to LSI +unsigned long LsiGetReg( HANDLE sceHandle, + unsigned long offset); + +//To set the register value to LSI +enum SceResultEnum LsiSetRegPtr( HANDLE sceHandle, + unsigned long offset, + unsigned long valuep, + unsigned long dummy); + +///Kind of file. +enum FMBFileEnum{ + FMBEnmOutFile, ///<case the output file + FMBEnmInFile, ///<case the input file +}; + +///Kind of file position. +enum FMBFilePosEnum{ + FMBEnmStartPos, ///<case the start position + FMBEnmEndPos, ///<case the end position +}; + +///Kind of result file access. +enum FMBFileResultEnum{ + FMBEnmFileNormal, ///<Normal end + FMBEnmFileAccesFail, ///<File access fail + FMBEnmFileExecutionFail, ///<File access fail + FMBEnmFilePacketSizeFail, ///<File Packet Size fail + FMBEnmFileOtherFail, ///<File Open fail +}; + +///Kind of stream thread. +enum FMBStremThreadEnum{ + FMBEnmStreamRcv, ///<Stream recive thread + FMBEnmStreamSend, ///<Stream send thread + FMBEnmStreamMAX, ///<Stream thread max +}; + +///Kind of Run mode. +enum FMBRunModeEnum{ + FMBEnmRunModeNormal, ///<Normal mode + FMBEnmRunModeCommand, ///<Command mode +}; + +/* + get event from core +*/ +//Get System info for the Linux driver::ioctl(FMB_API_GET_SYS_MSG) +void CoreGetAsyncInfo(struct fmb_async_info *async_info); + +//Get System Ack for the Linux driver::ioctl(FMB_API_GET_SYS_MSG) +void CoreAckGetSys(struct fmb_cmd_ack_sys_info *msg_ack_info); + +//Get System Message for the Linux driver::ioctl(FMB_API_GET_SYS_MSG) +void CoreMsgGetSys(struct fmb_msg_sys_info *msg_sys_info); + +//Get Audio Message for the Linux driver::ioctl(FMB_API_GET_AUDIO_MSG) +void CoreMsgGetAudio(struct fmb_msg_audio_info *msg_audio_info); + +//Get Video Message for the Linux driver::ioctl(FMB_AP_GET_VIDEO_MSG) +void CoreMsgGetVideo(struct fmb_msg_video_info *msg_video_info); + +//Get Async Factor for the Linux driver::ioctl(FMB_API_GET_FACTOR) +void CoreFactorGet(struct fmb_factor_info *factor_info); + + + +/* + Core scenario funcs +*/ + +//Set parameter for the Linux driver::ioctl(FMB_API_SET_PARAM) +enum SceResultEnum CoreParamSet(HANDLE sceHandle, unsigned long id, unsigned long value, unsigned long dummy); + +//Send System Command for the Linux driver::ioctl(FMB_API_SEND_SYS_CMD) +enum SceResultEnum CoreCmdSendSys(HANDLE sceHandle, unsigned long cmd, unsigned long subCmd, unsigned long body); + +//Send Video Command for the Linux driver::ioctl(FMB_API_SEND_VIDEO_CMD) +enum SceResultEnum CoreCmdSendVideo(HANDLE sceHandle, unsigned long mode, unsigned long subMode, unsigned long vDispTime); + +//Send Video Command for the Linux driver::ioctl(FMB_API_SEND_VIDEO_CMD) +enum SceResultEnum CoreCmdSendAudio(HANDLE sceHandle, unsigned long mute, unsigned long ch, unsigned long dummy); + +//Set parameter pointer for the Linux driver::ioctl(FMB_API_SET_PARAM) +enum SceResultEnum CoreParamSetPtr(HANDLE sceHandle, unsigned long id, unsigned long valuep, unsigned long dummy); + +//Send System Command pointer for the Linux driver::ioctl(FMB_API_SEND_SYS_CMD) +enum SceResultEnum CoreCmdSendSysPtr(HANDLE sceHandle, unsigned long cmd, unsigned long subCmd, unsigned long bodyp); + +//Set parameter pointer's pointer for the Linux driver::ioctl(FMB_API_SET_PARAM) +enum SceResultEnum CoreParamSetPtrPtr(HANDLE sceHandle, unsigned long id, unsigned long valuepp, unsigned long dummy); + + +/* + Event reception function from driver +*/ +int FmbRecvBegin(struct RecvThread *p_RecvThread); + +BOOL FmbRecvGetEventInfo(struct RecvEventArgType *evnt, int fdPipeRead); + +void FmbRecvSendEvent(const struct RecvEventArgType *evnt, int fdPipeWrite); + +/* + Stream function from driver +*/ +#define FMB_STREAM_THREAD_RECV_PRI 99 +#define FMB_STREAM_THREAD_SEND_PRI 98 + +#define FMB_STREAM_THREAD_RECV_FSIZE 128 * 1024 +#define FMB_STREAM_THREAD_SEND_FSIZE 64 * 1024 + +#define FMB_STREAM_PACKET_CHK_TH 10 + +BOOL FmbStreamBegin( enum FMBStremThreadEnum threadKind, HANDLE sceHandle ); + +void FmbStreamRest( HANDLE hScet ); + +void FmbSetStreamStop( enum FMBStremThreadEnum, struct StreamThread *p_StreamThread ); + +void FmbSetStreamFrameUpdate( enum FMBStremThreadEnum, struct StreamThread *p_StreamThread); + +void FmbSetStreamSeqEnd( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread ); + +void FmbSetSystemCmdAck( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread ); + +void FmbSetStreamSize(enum FMBStremThreadEnum threadKind, int strm_size,struct StreamThread *p_StreamThread); + +__off64_t FmbGetStrmFilePos(enum FMBFilePosEnum filPoseenum ); + +void FmbSetStrmFilePos(enum FMBFilePosEnum filPoseenum , __off64_t position); + +//Open the stream file. +enum FMBFileResultEnum FmbFileOpen(enum FMBFileEnum , + char* filepath , int* errPacketCnt); + +BOOL FmbConfigFileOpen(char* filepath ,char* att); + +BOOL FmbConfigFileClose(void); + +BOOL FmbConfigFileSave(void); + +BOOL FmbConfigFileLoad(void); + +__off64_t FmbGetFileSize(char* filepath ); + +BOOL FmbIsDifferentFile(char* in_filepath , char* out_filepath); + +BOOL FmbIsExistenceFile(char* filepath ); + +/* + written in Peak-Rate of TS-Info(FmbSceEncode.c) +*/ +enum SceResultEnum WritePeakRateInTsInfo(HANDLE sceHandle, + unsigned long tsInfo1c, unsigned long tsInfo1f, unsigned long dummy); + +enum SceResultEnum WriteVideoFormat(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3); + +enum SceResultEnum WriteEsInfoVideo(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3); + +enum SceResultEnum WriteEsInfoAudio(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3); + +#endif //__FMBCMN_H_ diff --git a/fmb_player_apl/include/MmuxAp.h b/fmb_player_apl/include/MmuxAp.h new file mode 100644 index 0000000..cf77cfe --- /dev/null +++ b/fmb_player_apl/include/MmuxAp.h @@ -0,0 +1,155 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _MMUXAP_H_ // [ _MMUXAP_H_
+#define _MMUXAP_H_
+
+#include "mmux.h"
+
+ +enum MMUXDeviceNumEnum { + MMUXDevice_NONE = -1, + MMUXDevice_0 = 0, + MMUXDevice_1 = 1, + MMUXDeviceMax, +}; + +enum MMUX_RESOLUTION { + MMUX_RESOLUTION_1080P_60, + MMUX_RESOLUTION_1080P_59, + MMUX_RESOLUTION_1080P_50, + MMUX_RESOLUTION_1080I_60, + MMUX_RESOLUTION_1080I_59, + MMUX_RESOLUTION_1080I_50, + MMUX_RESOLUTION_1080P_24, + MMUX_RESOLUTION_1080P_23, + MMUX_RESOLUTION_720P_60, + MMUX_RESOLUTION_720P_59, + MMUX_RESOLUTION_720P_50, + MMUX_RESOLUTION_720P_24, + MMUX_RESOLUTION_720P_23, + MMUX_RESOLUTION_480i, + MMUX_RESOLUTION_576i_50, + MMUX_RESOLUTION_UNKNOWN = 0x1f, +}; + +enum MMUX_INPUT { + MMUX_INPUT_NONE = -1, + MMUX_INPUT_0 = 0, + MMUX_INPUT_1, + MMUX_INPUT_2, + MMUX_INPUT_3, + + MMUX_INPUT_MAX, +}; + +enum MMUX_OUTPUT { + MMUX_OUTPUT_NONE = -1, + MMUX_OUTPUT_0 = 0, + + MMUX_OUTPUT_MAX, +}; + +enum MMUX_OUTPUT_SRC { + MMUX_OUT_SRC_NONE = -1, + MMUX_OUT_SRC_IN_0 = 0, + MMUX_OUT_SRC_IN_1, + MMUX_OUT_SRC_IN_2, + MMUX_OUT_SRC_IN_3, + MMUX_OUT_SRC_CODEC_0, + MMUX_OUT_SRC_CODEC_1, + MMUX_OUT_SRC_CODEC_2, + MMUX_OUT_SRC_CODEC_3, + + MMUX_OUT_SRC_MAX, +}; +enum MMUX_OUTPUT_MODE { + MMUX_OUT_MODE_NONE = -1, + MMUX_OUT_MODE_BYPASS = 0, + MMUX_OUT_MODE_H264, + + MMUX_OUT_MODE_MAX, +}; + +struct CodecIO { + enum MMUX_INPUT inNum; // 0~ + enum MMUX_OUTPUT outNum; // 0~ + enum MMUX_RESOLUTION inResolution; + //enum MMUX_RESOLUTION outResolution; + unsigned long fgInputConncet:1; + unsigned long fgInputDisable:1; +}; + +struct MmuxVer { + unsigned long CPLD; + unsigned long FPGA; + unsigned long MCU; + char driver[MMUX_VER_LEN]; +}; + + +typedef void* MmuxHandle; + + +MmuxHandle MmuxInit(int deviceNum); +void MmuxRelease(MmuxHandle hdMmux); + +char const *MmuxGetResolutionStr(int resolution); +char const *MmuxGetCodecSrcStr(int srcNum); +char const *MmuxGetOutputSrcStr(int outputSrc); + +int MmuxGetVer(MmuxHandle hdMmux, struct MmuxVer *p_Ver); + +enum MMUX_INPUT MmuxGetCodecSrc(MmuxHandle hdMmux, int codecNum); +int MmuxSetCodecSrc(MmuxHandle hdMmux, int codecNum, enum MMUX_INPUT srcNum); + +enum MMUX_OUTPUT MmuxGetCodecDst(MmuxHandle hdMmux, int codecNum); + +enum MMUX_RESOLUTION MmuxGetCodecSrcResolution(MmuxHandle hdMmux, int codecNum); + +int MmuxIsCodecSrcConnect(MmuxHandle hdMmux, int codecNum); +int MmuxIsCodecSrcDisable(MmuxHandle hdMmux, int codecNum); + +int MmuxGetCodecStatus(MmuxHandle hdMmux, int codecNum, struct CodecIO *p_Codec); + +enum MMUX_OUTPUT_SRC MmuxGetOutputSrc(MmuxHandle hdMmux, int outputNum); +int MmuxSetOutputSrc(MmuxHandle hdMmux, int outputNum, enum MMUX_OUTPUT_SRC outputSrc); + +enum MMUX_OUTPUT_MODE MmuxGetOutputMode(MmuxHandle hdMmux, int outputNum); + +int MmuxCalcCodecChipTotal(void); +int MmuxCalcBoardTotal(void); + + +#endif // _MMUXAP_H_ ] diff --git a/fmb_player_apl/include/SceCmn.h b/fmb_player_apl/include/SceCmn.h new file mode 100644 index 0000000..14b0c34 --- /dev/null +++ b/fmb_player_apl/include/SceCmn.h @@ -0,0 +1,155 @@ +/**
+* @brief Scenario Common header file.
+* @since 2009/01/08
+* @note None
+* @attention None
+* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B>
+*/
+
+/*
+ * 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.
+ */
+
+#ifndef __SCECMN_H_
+#define __SCECMN_H_
+
+typedef void *HANDLE; ///<Type of scenario handle
+
+#include "FmbAp.h"
+/*
+ scenario
+*/
+
+#define SCE_IGNORE 0xffffffff ///<When the event is waited, the condition is disregarded.
+//typedef void *HANDLE; ///<Type of scenario handle
+
+///scenario result
+enum SceResultEnum{
+ SceEnmResultSyncEnd, ///<It executed it synchronously.
+ SceEnmResultAsyncEnd, ///<It asynchronously executed it.
+ SceEnmResultRetry, ///<It is necessary to execute it again.
+};
+
+///Type of scenario function.
+typedef enum SceResultEnum (*ScenarioFuncType)(HANDLE sceHandle, unsigned long arg1, unsigned long arg2, unsigned long arg3);
+
+///scenario table
+struct SceTableType{
+ ScenarioFuncType scenarioFunc; ///<Scenario function.
+ int arg1; ///<Argument 1
+ int arg2; ///<Argument 2
+ int arg3; ///<Argument 3
+};
+
+//The scenario object is made.
+HANDLE _SceCreate(struct SceTableType *sceTbl, const char *name ,char* freeReqBuf, enum FMBDeviceNumEnum deviceNum);
+
+/**
+* @brief The scenario object is made.
+* @param[in] sceTbl
+* @return None
+* @note None
+* @attention None
+*/
+#define SceCreate(sceTbl,buf,deviceNum) _SceCreate((sceTbl), #sceTbl , (buf), deviceNum)
+
+//The scenario object is annulled.
+void SceClose(HANDLE scenarioHandle);
+
+//The scenario is executed.
+//TRUE:Continue of Scenario FALSE:End of Scenario
+BOOL SceGo(HANDLE scenarioHandle, void *arg);
+
+//The scenario is synchronously executed.
+void _SceGoSync(struct SceTableType *sceTbl, const char *name, void *arg, enum FMBDeviceNumEnum deviceNum);
+
+/**
+* @brief The scenario is synchronously executed.
+* @param[in] sceTbl
+* @param[in] arg
+* @return None
+* @note None
+* @attention None
+*/
+#define SceGoSync(sceTbl, arg, deviceNum) _SceGoSync((sceTbl), #sceTbl, (arg), deviceNum)
+
+//Reset scenario. The following are executed from the beginning.
+void SceReset(HANDLE scenarioHandle);
+
+//The argument is returned.
+void *SceGetArg(HANDLE scenarioHandle);
+
+//The argument is returned.
+void SceCleartArg(HANDLE scenarioHandle);
+
+//The reproduction speed is reset.
+enum SceResultEnum ResetSlowSpeed(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2);
+
+// Get device handle.
+int SceGetDevHandle(HANDLE scenarioHandle);
+
+// Get device number.
+enum FMBDeviceNumEnum SceGetDevNum(HANDLE scenarioHandle); +
+
+//< Prototype declared
+
+/*
+ wait scenario functions
+*/
+//The system response is waited for.
+enum SceResultEnum WaitSysAckFor(HANDLE sceHandle, unsigned long cackId, unsigned long subCackId, unsigned long dummy2);
+
+//The system message is waited for.
+enum SceResultEnum WaitSysMsgFor(HANDLE sceHandle, unsigned long msgId, unsigned long subMsgId, unsigned long body00);
+
+//The video message is waited for.
+enum SceResultEnum WaitVideoMsgFor(HANDLE sceHandle, unsigned long mode, unsigned long subMode, unsigned long dummy2);
+
+//The Audio message is waited for.
+enum SceResultEnum WaitAudioMsgFor(HANDLE sceHandle, unsigned long mute, unsigned long ch, unsigned long dummy);
+
+//< (FmbSceWait.c)
+enum SceResultEnum WaitThreadEndFor(HANDLE sceHandle, unsigned long Id, unsigned long dummy1, unsigned long dummy2);
+
+//The system response is waited for.
+enum SceResultEnum WaitCmdSysAckFor(HANDLE sceHandle, unsigned long cackId, unsigned long subCackId, unsigned long dummy2);
+
+//The system message is waited for.
+enum SceResultEnum WaitCmdSysMsgFor(HANDLE sceHandle, unsigned long msgId, unsigned long subMsgId, unsigned long body00);
+
+//The video message is waited for.
+enum SceResultEnum WaitCmdVideoMsgFor(HANDLE sceHandle, unsigned long mode, unsigned long subMode, unsigned long dummy2);
+
+//The Audio message is waited for.
+enum SceResultEnum WaitCmdAudioMsgFor(HANDLE sceHandle, unsigned long mute, unsigned long ch, unsigned long dummy);
+
+//< (FmbSceWait.c)
+enum SceResultEnum WaitCmdThreadEndFor(HANDLE sceHandle, unsigned long Id, unsigned long dummy1, unsigned long dummy2);
+
+//< (FmbSceWait.c)
+enum SceResultEnum WaitCmdInputKeyFor(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3);
+
+
+//< (FmbStream.c)
+enum SceResultEnum StartSendThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2);
+
+enum SceResultEnum StartRecvThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2);
+
+enum SceResultEnum StopSendThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2);
+
+enum SceResultEnum StopRecvThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2);
+
+enum SceResultEnum RestStreamThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2);
+
+//< (FmbCommand.c)
+enum SceResultEnum FmbCommandSend(HANDLE sceHandle, unsigned long cmdBuf, unsigned long dummy1, unsigned long dummy2);
+
+//< (ExecScriptCommand.c)
+void FmbSetPauseCommand(void);
+
+#endif //__SCECMN_H_
+
diff --git a/fmb_player_apl/include/Screen.h b/fmb_player_apl/include/Screen.h new file mode 100644 index 0000000..86962e5 --- /dev/null +++ b/fmb_player_apl/include/Screen.h @@ -0,0 +1,384 @@ +/** +* @brief API of a screen common module is declared. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#ifndef __SCREEN_H_ +#define __SCREEN_H_ + +#include "FmbCmn.h" +#include "FmbAp.h" + +//Event function when key is input. +typedef BOOL (*OnKeyHitType)(char ch); + +//Event function when 1-line is input. +typedef BOOL (*OnLineInputType)(char *lineStr); + +//Event function when fmb-request is complete. +typedef BOOL (*OnFMBRequestCompleteType)(enum FMBRequestEnum req); + +//Event function when show the screen. +typedef BOOL (*OnShowType)(void); + +// +typedef BOOL (*IsShowChild)(void); + + + +///Enumeration that identifies screen. +enum ScreenEnum{ + ScrEnmMainMenu, + ScrEnmSetSubMenuEnc, + ScrEnmSetSubMenuDec, + ScrEnmSetAudioBitrateMpeg1l2Enc, + ScrEnmSetAudioBitrateAc3Enc, + ScrEnmSetAudioBitrateAacEnc, + ScrEnmSetAudioBitrateLpcmEnc, + ScrEnmSetAudioFormatEnc, + ScrEnmSetAudioFormatDec, + ScrEnmSetInputPortDec, + ScrEnmSetOutputPortEnc, + ScrEnmSetVideoRatecontrol, + ScrEnmSetVideoBitrateCbr, + ScrEnmSetVideoBitrateVbr, + ScrEnmSetVideoFormatEnc, + ScrEnmSetVideoFormatDec, + ScrEnmSetVideoFrameEnc, + ScrEnmSetVideoFrameDec, + ScrEnmSetVideoScalerEnc, + ScrEnmConfEncoding, + ScrEnmConfDecNormal, + ScrEnmConfDec1pic, + ScrEnmConfPauseStart, + ScrEnmConfEnc1pic, + ScrEnmEncoding, + ScrEnmDecPause, + ScrEnmDecNormal, + ScrEnmDec1pic, + ScrEnmDecSlow, + ScrEnmEndOfPlay, + ScrEnmSetFile, + ScrEnmSetFileStartPos, + ScrEnmSetSystemBitrate, + ScrEnmSetSubMenuCom, + ScrEnmSetTsPacketCom, + ScrEnmSetPidTypeCom, + ScrEnmSetInOutPidCom, + ScrEnmSetTsTypeCom, + ScrEnmSetFirmCom, + ScrEnmSetConfigCom, + ScrEnmScreenError, + ScrEnmSetOption, + ScrEnmEecScriptCommand, + ScrEnmSelSingleDev, + ScrEnmSelMultiDev, + ScrEnmSelRecordDev, + ScrEnmSetVideoInOut, + ScrEnmSetVideoOut, + ScrEnmSetVideoRsltnEnc, + ScrEnmSetVideoRsltnDec, + ScrEnmSetVideoOutMode, + ScrEnmSetVideoOutBypass, + ScrEnmSetVideoOutH264, + + ScrEnmNumOfScreen +}; + +///Kind of screen input mode +enum ScreenInputModeEnum{ + ScrEnmModeOriginal, ///<Original settings. + ScrEnmMode1key, ///<It returns soon when one character is input. + ScrEnmModeKeybuffer, ///<It doesn't return until 'Enter' is pressed. +}; + +///Kind of port. +enum FMBInOutPortEnum{ + FMBEnmOutPort, ///<case the output port + FMBEnmInPort, ///<case the input port +}; + +///Kind of video bitrate VBR. +enum ScreenVideoBitrateVbrEnum{ + ScrEnmVideoBitrateVbrAverage, + ScrEnmVideoBitrateVbrPeak, +}; + +///Kind of audio bitrate VBR. +enum ScreenAudioBitrateVbrEnum{ + ScrEnmAudioBitrateVbrAverage, + ScrEnmAudioBitrateVbrPeak, +}; + +///Kind of decode type. +enum ScreenDecodeTypeEnum{ + ScrEnmDecType, + ScrEnmDec1picType, +}; + +///Kind of the file setting screen type. +enum ScreenSetFileTypeEnum{ + ScrEnmSetFileOutputEnc, + ScrEnmSetFileInputDec, +}; + +///Kind of the sub menu setting screen type. +enum ScreenSetSubMenuTypeEnum{ + ScrEnmSetSubMenuEncType, + ScrEnmSetSubMenuDecType, +}; + +///Kind of confirmation screen type. +enum ScreenConfTypeEnum{ + ScrEnmConfEncodingType, + ScrEnmConfDecNormalType, + ScrEnmConfPauseStartType, + ScrEnmConfReserve, + ScrEnmConfEnc1picType, + ScrEnmConfDec1picType, +}; + +///Video format check +enum FMBCheckVideoFormatEnum{ + FMBEnmVFmtNG, + FMBEnmVFmtOK, + FMBEnmVFmtLimitations, +}; + +///Audio format check +enum FMBCheckAudioFormatEnum{ + FMBEnmAFmtNG, + FMBEnmAFmtDVB, + FMBEnmAFmtBD, +}; + +///Screen mode +enum ScreenMode{ + ScrEnmNormalMode, + ScrEnmScriptCommandMode, + ScrEnmOptionMode, + ScrEnmNumOfScreenMode +}; + +///Error screen message +struct ErrorScreenMessage{ + char *factor; ///<Error factor + char information[FMB_ERRINFO_MAX_CHAR]; ///<Error information + char *reaction; ///<Reaction +}; + +///Kind of result character string check. +enum FMBCharChkResultEnum{ + FMBEnmNormal, ///<Normal end + FMBEnmTooLongCharErr, ///<Too long char error + FMBEnmInvalidValueErr, ///<Invalid value error +}; + +///Screen module property +struct Screen{ + const char *displayString; ///<Display strings + const char *validChars; ///<Character that can be input + const char *prompt; ///<Prompt string + OnKeyHitType OnKeyFunc; ///<Event function when key is input. + OnLineInputType OnLineInputFunc; ///<Event function when 1-line is input. + OnFMBRequestCompleteType OnFmbRequestCompleteFunc; ///<Event function when fmb-request is complete. + OnShowType OnShowFunc; ///<Event function when show the screen. + IsShowChild IsShowChildFunc; + enum ScreenEnum childScreen; +}; + +///Screen collection module property +struct ScreenCollection{ + struct Screen screens[ScrEnmNumOfScreen]; ///<Screen informations + enum ScreenInputModeEnum inputMode[ScrEnmNumOfScreenMode]; ///<Input mode:1-key or Key-buffer + enum ScreenEnum prevScreen[ScrEnmNumOfScreenMode]; ///<Previous screen + enum ScreenEnum currentScreen[ScrEnmNumOfScreenMode]; ///<Current screen + enum ScreenEnum nextScreen; ///<Next screen + BOOL isScreenChanged; ///<changed:TRUE + BOOL isScreenModeChanged; ///<changed:TRUE + enum ScreenMode nextMode; ///<Next screen mode + enum ScreenMode currentMode; ///<Current screen mode +}; + + +/********************************************************/ +/* error message */ +/********************************************************/ + +#define FMB_INPUTERR_TOO_LONG_CHAR "It is too long." +#define FMB_INPUTERR_INVALID_VALUE "Invalid value specified." +#define FMB_INPUTERR_TOO_LARGE_VALUE "The value is too large." +#define FMB_INPUTERR_TOO_SMALL_VALUE "Please enter a value larger than the average value." +#define FMB_INPUTERR_INVALID_COMBINATION "Invalid combination specified." +#define FMB_INPUTERR_FILE_NOTHING "The file is not existence." +#define FMB_INPUTERR_FILE_PATH "Invalid the file path." + +/********************************************************/ +/* error screen message information */ +/********************************************************/ + +#define FMB_ERRSCR_FACT_OVERFLOW "System bitrate/Video bitrate Overflow" //Overflow +#define FMB_ERRSCR_FACT_INFILEPATH "Input filepath error" //Input filepath error +#define FMB_ERRSCR_FACT_OUTFILEPATH "Output filepath error" //Output filepath error +#define FMB_ERRSCR_FACT_TERMINATING "Terminating previous request" //Terminating error +#define FMB_ERRSCR_FACT_INPACKET_SIZE "Input packet size unmatch occurred.(the %dth packet)" //Input packet size error +#define FMB_ERRSCR_FACT_OUTPACKET_SIZE "Output packet size unmatch occurred.(the %dth packet)" //Output packet size error +#define FMB_ERRSCR_FACT_SAME_FILEPATH "Output filepath is the same as input filepath." //Same input and output filepath error +#define FMB_ERRSCR_FACT_VIDEOFORMAT "This video settings are the unsupport combinations." //Video format error +#define FMB_ERRSCR_FACT_INPACKET_SIZE2 "This input packet size is a unsupport in the file intput." //Input packet size error +#define FMB_ERRSCR_FACT_OUTPACKET_SIZE2 "This output packet size is a unsupport in the file output." //Output packet size error +#define FMB_ERRSCR_FACT_INPUTPORT "This function is not supported in the stream port input. " //Input port error +#define FMB_ERRSCR_FACT_OUTPUTPORT "This function is not supported in the stream port output. " //Output port error + +#define FMB_ERRSCR_MSGINFO_NOTHING "Nothing" + +#define FMB_ERRSCR_REACT_OVERFLOW "Please check settings for video bitrate, audio bitrate, and video format." //Overflow reaction +#define FMB_ERRSCR_REACT_INFILEPATH "Please check input filepath." //Input filepath reaction +#define FMB_ERRSCR_REACT_OUTFILEPATH "Please check output filepath." //Output filepath reaction +#define FMB_ERRSCR_REACT_EXECRETRY "Please retry later." //Execution reaction +#define FMB_ERRSCR_REACT_INPACKET_SIZE "Please check settings for packet size and input file." //Input packet size reaction +#define FMB_ERRSCR_REACT_OUTPACKET_SIZE "Please check settings for packet size and output file." //Output packet size reaction +#define FMB_ERRSCR_REACT_SAME_FILEPATH "Please check input filepath and output filepath." //Same input and output filepath reaction +#define FMB_ERRSCR_REACT_VIDEOFORMAT "Please check video format setting, video framerate setting, video scaler setting and TS format." //Video format reaction +#define FMB_ERRSCR_REACT_INPUTPORT "Please check input port setting." //Input port reaction +#define FMB_ERRSCR_REACT_OUTPUTPORT "Please check output port setting." //Output port reaction + +//Initialize screens +void InitScreens(void); + +//Set screen mode +enum ScreenInputModeEnum SetScreenMode(enum ScreenInputModeEnum inputMode); + +//It changes to the specified screen. +void ChangeScreenTo(enum ScreenEnum scrEnm); + +//It changes to the specified screen and mode. +void ChangeScreenAndModeTo(enum ScreenEnum scrEnm, enum ScreenMode scrMode); + +//Event when input is done to standard input +BOOL OnStdinInput(void); + +BOOL OnFmbRequestResponse(void); + +//The state of the screen (..can input.. impropriety) is set. +void SetInputEnabled(BOOL isEnable); + +//The state of the screen (..can input.. impropriety) is returned. +BOOL GetInputEnabled(void); + +//The message of the input error is displayed. +void MsgDispInputErr(char *msg); +void MsgDispInputErrNoPrompt(char *msg); + +//It returns to the another mode. +void ReturnToAnotherScreenMode(enum ScreenMode scrMode); + +//It changes to the previous screen. +void ChangePrevScreenTo(enum ScreenMode scrMode, enum ScreenEnum scrEnm); + +//The delimitation line is displayed. +void DrawDelimitationLine(void); + +//Initialize Screen funcs +void InitMainMenu(struct Screen *scr); +void InitSetSubMenuEnc(struct Screen *scr); +void InitSetSubMenuDec(struct Screen *scr); +void InitSetAudioBitrateMpeg1l2Enc(struct Screen *scr); +void InitSetAudioBitrateAc3Enc(struct Screen *scr); +void InitSetAudioBitrateAacEnc(struct Screen *scr); +void InitSetAudioBitrateLpcmEnc(struct Screen *scr); +void InitSetAudioFormatEnc(struct Screen *scr); +void InitSetAudioFormatDec(struct Screen *scr); +void InitSetInputPortEnc(struct Screen *scr); +void InitSetInputPortDec(struct Screen *scr); +void InitSetOutputPortEnc(struct Screen *scr); +void InitSetOutputPortDec(struct Screen *scr); +void InitSetVideoRatecontrol(struct Screen *scr); +void InitSetVideoBitrateCbr(struct Screen *scr); +void InitSetVideoBitrateVbr(struct Screen *scr); +void InitSetVideoFormatEnc(struct Screen *scr); +void InitSetVideoFormatDec(struct Screen *scr); +void InitSetVideoFrameEnc(struct Screen *scr); +void InitSetVideoFrameDec(struct Screen *scr); +void InitSetVideoScalerEnc(struct Screen *scr); +void InitConfEncoding(struct Screen *scr); +void InitConfDecNormal(struct Screen *scr); +void InitConfDec1pic(struct Screen *scr); +void InitConfPauseStart(struct Screen *scr); +void InitConfEnc1pic(struct Screen *scr); +void InitEncoding(struct Screen *scr); +void InitDecPause(struct Screen *scr); +void InitDecNormal(struct Screen *scr); +void InitDec1pic(struct Screen *scr); +void InitDecSlow(struct Screen *scr); +void InitEndOfPlay(struct Screen *scr); +void InitSetFile(struct Screen *scr); +void InitSetFileStartPos(struct Screen *scr); +void InitSetSystemBitrate(struct Screen *scr); +void InitSetSubMenuCom(struct Screen *scr); +void InitSetTsPacketCom(struct Screen *scr); +void InitSetPidTypeCom(struct Screen *scr); +void InitSetInOutPidCom(struct Screen *scr); +void InitSetTsTypeCom(struct Screen *scr); +void InitSetFirmCom(struct Screen *scr); +void InitSetConfigCom(struct Screen *scr); +void InitScreenError(struct Screen *scr); +void InitSetOption(struct Screen *scr); +void InitSriptCommand(struct Screen *scr); +void InitSelSingleDev(struct Screen *scr); +void InitSelMultiDev(struct Screen *scr); +void InitSelRecordDev(struct Screen *scr); +void InitSetVideoIO(struct Screen *scr); +void InitSetVideoOut(struct Screen *scr); +void InitSetVideoResolutionEnc(struct Screen *scr); +void InitSetVideoResolutionDec(struct Screen *scr); +void InitSetVideoOutMode(struct Screen *scr); +void InitSetVideoOutBypass(struct Screen *scr); +void InitSetVideoOutH264(struct Screen *scr); + +//The video bitrate character string is edited. +void ScrEditVideoBitrateString(char *destBuff, int destBuffSize); + +//The audio bitrate character string is edited. +void ScrEditAudioBitrateString(char *destBuff, int destBuffSize); + +//The file character string is edited. +void ScrEditFilePathString(enum FMBInOutPortEnum portenum, char *destBuff, int destBuffSize); + +///select mark "*" +extern const char g_selectMarks[16][16]; + +//The previous of the screen is returned. +enum ScreenEnum GetPrevScreen(void); + +//Audio format table for reload. +extern const int g_ReloadAudio[FMB_AUDIO_FORMAT_KIND]; + +///Invalid character code. +extern const int g_invalidCharaCode[FMB_CODE_INVALID_KIND]; + +//The file character string check. +enum FMBCharChkResultEnum ScrChkCodeStringBuff(char *destBuff, size_t len); + +//The confirmation of setting data. +BOOL ScrConfSetData(enum ScreenConfTypeEnum scrConfEnm); + +//The video format check. +//extern unsigned short g_Firm_LSI_Ver; +//extern unsigned long g_SubsystemId; +extern enum FMBRunModeEnum g_RunMode; +extern const enum FMBCheckVideoFormatEnum g_VideoFormatCheckEnc[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; +extern const enum FMBCheckVideoFormatEnum g_VideoFormatCheckDec[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax]; +extern enum FMBCheckAudioFormatEnum g_AudioFormatCheck[FMBEnmAudioFmtMax]; + +#endif //__SCREEN_H_ diff --git a/fmb_player_apl/makefile.defs b/fmb_player_apl/makefile.defs new file mode 100644 index 0000000..e73ec5f --- /dev/null +++ b/fmb_player_apl/makefile.defs @@ -0,0 +1,8 @@ +
+#Set CFLAGS
+CFLAGS = -I"../../fmb_driver"
+CFLAGS += -I"../../mmux_driver"
+CFLAGS += -I"../include"
+CFLAGS += -D_GNU_SOURCE
+CFLAGS += -DVERSION=\"0.0.2.1\"
+CFLAGS += -DUSE_MMUX
diff --git a/fmb_player_apl/src/cmd/FmbCmd.c b/fmb_player_apl/src/cmd/FmbCmd.c new file mode 100644 index 0000000..423daaf --- /dev/null +++ b/fmb_player_apl/src/cmd/FmbCmd.c @@ -0,0 +1,3007 @@ +/** +* @brief Control API function of Linux driver +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <stdlib.h> +#include <unistd.h> +#include "FmbCmn.h" + +#define FMB_MAX_ARG_NUM 20 +#define FMB_MAX_STRING_LEN 256 +#define PROG_NAME "fmb_ioctl_apl" + +#define BANK_SIZE (512 * 1024) +#define FMB_LSIBIN_PUT 1 +#define FMB_LSIBIN_GET 2 +#define SWAPW(x) (((x>>8)&0x00ff) | ((x<<8)&0xff00)) + +static unsigned short s_vmsg_mode = 0xFFFF; +static unsigned short s_vmsg_seqend = 0xFFFF; +static unsigned short s_smsg_body = 0xFFFF; +static unsigned int vudata_cnt = 0; +static unsigned long internal_info_data = 0; + +static enum FMBStremModeEnum s_Strmmode = FMBEnmNothing; + +extern const struct jump_head_table g_internal_jump_table[]; + +static void usage_print(struct ioctl_private_inf* pri_inf_p); +static void result_print(struct ioctl_private_inf* pri_inf_p); +static void api_ditail_err_print(struct ioctl_private_inf* pri_inf_p); +static void api_timeout_print(struct ioctl_private_inf* pri_inf_p); +static void error_print(struct ioctl_private_inf* pri_inf_p , int err); +static int check_unsigned_string(const char* string); +static struct param_check param_check_unsignlong(char* input_param); +static struct param_check param_check_unsignshort(char* input_param); +static struct param_check param_check_signlong(char* input_param); +static void data_dump(unsigned short max_num, unsigned short* msg); + +static BOOL setCmdtable(char* lineString,struct SceTableType* cmdScenariop); + +static unsigned short vdatabuf[141] = { + 0x0000, /* mode value (default) */ + 0x0000, /* inter_gop_gap value (default) */ + 0x0002, /* tfrff value (default) */ + 0x0000, /* extra_info_bit value (default) */ + 0x000a, /* vdisptime value (default) */ + 0x0000, /* sub_mode value (default) */ + 0x0000 /* vudata_length value (default) */ + }; +static unsigned long vidbuf[141] = { + 0x00060001, /* parameter id for mode */ + 0x00060002, /* parameter id for inter_gop_gap */ + 0x00060004, /* parameter id for tfrff */ + 0x00060005, /* parameter id for extra_info_bit */ + 0x00060006, /* parameter id for vdisptime */ + 0x00060008, /* parameter id for sub_mode */ + 0x00060009 /* parameter id for vudata_length */ + }; + +static unsigned short adatabuf[11] = { + 0x0000, /* a_mute value (default) */ + 0x0000, /* a_ch value (default) */ + 0x8000, /* lch_scale value (default) */ + 0x8000, /* rch_scale value (default) */ + 0x0002, /* d_ac3_compression value (default) */ + 0x0080, /* d_ac3_dynrng_cut value (default) */ + 0x0080, /* d_ac3_dynrng_boost value (default) */ + 0x8000, /* lsch_scale value (default) */ + 0x8000, /* rsch_scale value (default) */ + 0x8000, /* cch_scale value (default) */ + 0x8000, /* lfech_scale value (default) */ + }; +static unsigned long aidbuf[11] = { + 0x00070001, /* parameter id for a_mute */ + 0x00070002, /* parameter id for a_ch */ + 0x00070003, /* parameter id for lch_scale */ + 0x00070004, /* parameter id for rch_scale */ + 0x00070005, /* parameter id for d_ac3_compression */ + 0x00070006, /* parameter id for d_ac3_dynrng_boost */ + 0x00070007, /* parameter id for d_ac3_dynrng_cut */ + 0x00070008, /* parameter id for lsch_scale */ + 0x00070009, /* parameter id for rsch_scale */ + 0x0007000a, /* parameter id for cch_scale */ + 0x0007000b /* parameter id for lfech_scale */ + }; + + +/** + * @brief Get the video message mode. + * + * @param[in] none + * @return mode video message mode + * @note None + * @attention None + */ +unsigned short FmbgetVmode( void ) +{ + unsigned short mode; + + mode = s_vmsg_mode; + s_vmsg_mode = 0xFFFF; + + return mode; +} +/** + * @brief Get the video message seq end. + * + * @param[in] none + * @return mode video message seq end + * @note None + * @attention None + */ +unsigned short FmbgetVseqend( void ) +{ + unsigned short seqend; + + seqend = s_vmsg_seqend; + s_vmsg_seqend = 0xFFFF; + + return seqend; +} +/** + * @brief Get the system message body. + * + * @param[in] none + * @return mode system message body + * @note None + * @attention None + */ +unsigned short FmbgetSbody( void ) +{ + unsigned short body; + + body = s_smsg_body; + s_smsg_body = 0xFFFF; + + return body; +} + +/** + * @brief Get the argument. + * + * @param[in] srchchar Serch character code + * @param[in] argc input character code counter + * @param[in,out] argv input character codes + * @return index argument index + * @note None + * @attention None + */ +int FmbgetArg(char* sarchchar , int argc, char** argv) +{ + int i; + for (i=1 ; i < argc ; i++){ + if ((strcmp(argv[i], sarchchar) == 0)) { + if ( (i+1) < argc ){ + return (i+1); + } + } + } + return 0; + +} +/** + * @brief Get the argument. + * + * @param[in] srchchar Serch character code + * @param[in] argc input character code counter + * @param[in,out] argv input character codes + * @return index argument index + * @note None + * @attention None + */ +int FmbgetArgOwn(char* sarchchar , int argc, char** argv) +{ + int i; + for (i=1 ; i < argc ; i++){ + if ((strcmp(argv[i], sarchchar) == 0)) { + return i; + } + } + return 0; + +} +/** + * @brief Create the argument. + * + * @param[in] keybuff buffer + * @param[out] argvStr argument messages + * @return argument count + * @note None + * @attention None + */ + +int FmbCreateArgment(char* keybuff,char** argvStr) +{ + int argc; + int search_flg; + int i,j; + int len; + + FMB_FUNC(TRUE); + + len = strlen(keybuff); + argc=0; + search_flg = ON; + j = 0; + for(i=0;i<(len+1);i++){ + if ( keybuff[i]=='\n' || keybuff[i]=='\r' || keybuff[i]=='\0'){ + if (search_flg==OFF){ + argvStr[argc][j]=0x00; + } + argc++; + break; + } + if (keybuff[i] != ' '){ + if (search_flg==ON){ + search_flg = OFF; + argc++; + argvStr[argc][j]=keybuff[i]; + j++; + } + else{ + argvStr[argc][j]=keybuff[i]; + j++; + } + } + else{ + if (search_flg==OFF){ + argvStr[argc][j]=0x00; + search_flg = ON; + j=0; + } + } + } + + LogFmb("argc :%d",argc); + for (i=1;i<argc;i++) { + LogFmb("argv[%d]:%s ",i,argvStr[i]); + } + + FMB_FUNC(FALSE); + + return argc; + + +} +/** + * @brief Create the scenario of script. + * + * @param[in] cmdbuff buffer + * @return pointer on the scenario of script + * @note None + * @attention None + */ + +struct SceTableType* FmbCeateCommandScenario(char* cmdbuff) +{ + int i; + int ret; + char argvStr[FMB_MAX_ARG_NUM][FMB_MAX_STRING_LEN]; + char* argv[FMB_MAX_ARG_NUM]; + int argc=1; + FILE *fp; + char s[FMB_KEYBUFF_MAX_CHAR]; + int lCnt=0; + struct SceTableType* cmdTablep=NULL; + + for (i=1;i<FMB_MAX_ARG_NUM;i++){ + argv[i] = argvStr[i]; + } + argc=FmbCreateArgment((char*)cmdbuff,argv); + + if( argc < 3 ){ + fprintOut(stdout, "scrpt filename\n"); + FmbErrPrintUsr("Illegal parameter.",__FILE__,__LINE__); + free(cmdbuff); + return NULL; + } + + if((FmbCheckSenario()) == FALSE) { + fprintOut(stdout, "error: script is still being executed.\n"); + return NULL; + } + + if( (fp = fopen(argv[2],"r")) == NULL){ + FmbErrPrint("Illegal filepath.",__FILE__,__LINE__); + free(cmdbuff); + return NULL; + } + + while (fgets(s, FMB_KEYBUFF_MAX_CHAR, fp) != NULL) { + if ( s[0] == ' ' || s[0] == '/' || s[0] == '#' || s[0] == '\n' || s[0] == '\r'){ + continue; + } + lCnt++; + } + if(lCnt!=0){ + cmdTablep = malloc( (sizeof(struct SceTableType)) * (lCnt+1) ); + if(cmdTablep==NULL){ + FmbErrPrint("Command Buffer malloc NG.",__FILE__,__LINE__); + fclose(fp); + free(cmdbuff); + return NULL; + } + memset(cmdTablep,0,(sizeof(struct SceTableType)) * (lCnt+1)); + rewind(fp); + + lCnt=0; + i=0; + while (fgets(s, FMB_KEYBUFF_MAX_CHAR, fp) != NULL) { + i++; + if ( s[0] == ' ' || s[0] == '/' || s[0] == '#' || s[0] == '\n' || s[0] == '\r'){ + continue; + } + s[FMB_KEYBUFF_MAX_CHAR-1]='\0'; + ret = setCmdtable(s,&cmdTablep[lCnt]); + if (ret != TRUE){ + FmbErrPrintUsr("Illegal command.",s,i); + fclose(fp); + free(cmdbuff); + free(cmdTablep); + return NULL; + } + lCnt++; + } + } + + + fclose(fp); + free(cmdbuff); + return cmdTablep; +} + +BOOL setCmdtable(char* lineString,struct SceTableType* cmdScenariop) +{ + int i; + char argvStr[FMB_MAX_ARG_NUM][FMB_MAX_STRING_LEN]; + char* argv[FMB_MAX_ARG_NUM]; + int argc=1; + int len; + char* cmdbuf; + struct param_check param_check_out; + + for (i=1;i<FMB_MAX_ARG_NUM;i++){ + argv[i] = argvStr[i]; + } + argc=FmbCreateArgment((char*)lineString,argv); + if(argc<2) return FALSE; + + if ( strcmp("pause",argv[1])==0 ) { + cmdScenariop->scenarioFunc = WaitCmdInputKeyFor; + cmdScenariop->arg1 = SCE_IGNORE; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + } + else if( strcmp("wait",argv[1])==0) { + if (argc<3) return FALSE; + if ( strcmp("mode",argv[2])==0) { + if (argc<4) return FALSE; + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return FALSE; + } + cmdScenariop->scenarioFunc = WaitCmdVideoMsgFor; + cmdScenariop->arg1 = param_check_out.short_cnvdata; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + + }else if ( strcmp("seqend",argv[2])==0) { + if (argc<4) return FALSE; + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return FALSE; + } + cmdScenariop->scenarioFunc = WaitCmdVideoMsgFor; + cmdScenariop->arg1 = SCE_IGNORE; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = param_check_out.short_cnvdata; + + }else if ( strcmp("symsg",argv[2])==0) { + cmdScenariop->scenarioFunc = WaitCmdSysMsgFor; + cmdScenariop->arg1 = SCE_IGNORE; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + if (argc>3){ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return FALSE; + } + cmdScenariop->arg1 = param_check_out.short_cnvdata; + } + if (argc>4){ + param_check_out = param_check_unsignshort(argv[4]); + if (param_check_out.result != OK) { + return FALSE; + } + cmdScenariop->arg2 = param_check_out.short_cnvdata; + } + if (argc>5){ + param_check_out = param_check_unsignshort(argv[5]); + if (param_check_out.result != OK) { + return FALSE; + } + cmdScenariop->arg3 = param_check_out.short_cnvdata; + } + + }else if ( strcmp("syack",argv[2])==0) { + cmdScenariop->scenarioFunc = WaitCmdSysAckFor; + cmdScenariop->arg1 = SCE_IGNORE; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + if (argc>3){ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return FALSE; + } + cmdScenariop->arg1 = param_check_out.short_cnvdata; + } + + }else if ( strcmp("strm",argv[2])==0) { + if (argc<4) return FALSE; + if ( strcmp("snd",argv[3])==0) { + cmdScenariop->scenarioFunc = WaitCmdThreadEndFor; + cmdScenariop->arg1 = (int)FMBEnmStreamSend; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + + }else if ( strcmp("rcv",argv[3])==0) { + cmdScenariop->scenarioFunc = WaitCmdThreadEndFor; + cmdScenariop->arg1 = (int)FMBEnmStreamRcv; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + + }else{ + return FALSE; + } + }else{ + return FALSE; + } + } + else{ + len = strlen(lineString); + if (len==0) return FALSE; + cmdbuf = malloc(len); + if (cmdbuf==NULL) return FALSE; + memcpy(cmdbuf,lineString,len); + cmdScenariop->scenarioFunc = FmbCommandSend; + cmdScenariop->arg1 = (int)cmdbuf; + cmdScenariop->arg2 = SCE_IGNORE; + cmdScenariop->arg3 = SCE_IGNORE; + + } + + return TRUE; /* pgr0524 */ +} +/** + * @brief Print the error message. + * + * @param[in] lib_inf Fmb Lib information + * @param[in] comment error messages + * @param[in] file __FILE__ + * @param[in] line __LINE__ + * @return None + * @note None + * @attention None + */ +void FmbErrPrint( char* comment , char* file , int line) +{ + char* err_cause; + + err_cause = strerror(errno); + fprintOut(stdout, "%s at :%s(%d) : %s \n", comment, file , line , err_cause); + return; +} + +/** + * @brief Print the error message user. + * + * @param[in] lib_inf Fmb Lib information + * @param[in] comment error messages + * @param[in] file __FILE__ + * @param[in] line __LINE__ + * @return None + * @note None + * @attention None + */ +void FmbErrPrintUsr(char* comment , char* file , int line) +{ + + fprintOut(stdout, "%s at :%s(%d) \n", comment, file , line ); + return; +} + +/** + * @brief main of the dirver control application. + * + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[1] option + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ +enum SceResultEnum FmbCommandSend(HANDLE sceHandle, unsigned long cmdBuf, unsigned long dummy1, unsigned long dummy2) +//int FmbIoctlmain(struct fmb_lib_inf lib_inf, int argc, char** argv) +{ + int i; + int res; + struct ioctl_private_inf private_inf; + FUNCTION prgFunc=NULL; + char argvStr[FMB_MAX_ARG_NUM][FMB_MAX_STRING_LEN]; + char* argv[FMB_MAX_ARG_NUM]; + int argc=1; + + /* 0 Clear */ + memset (&private_inf , 0 , sizeof(private_inf)); + + for (i=1;i<FMB_MAX_ARG_NUM;i++){ + argv[i] = argvStr[i]; + } + argc=FmbCreateArgment((char*)cmdBuf,argv); + + fprintOut(stdout, ">"); + for( i=0 ; i<(argc-1) ; i++){ + /* printing */ + fprintOut(stdout, "%s ",argv[i+1]); + } + fprintOut(stdout, "\n"); + + /* serch function table */ + i=0; + while (g_internal_jump_table[i].function_addr != NULL) { + if(strcmp(argv[1], g_internal_jump_table[i].option_parameter) == 0) { + prgFunc = g_internal_jump_table[i].function_addr; + break; + } else { + i++; /* next */ + } + } + + private_inf.cmd_id = i; + private_inf.fd = SceGetDevHandle(sceHandle); + + if (prgFunc != NULL) { + res = prgFunc( &private_inf, argc, argv ); /* call function */ + }else{ + res = NG_OPTION_ERROR; + } + + switch (res){ + case OK: + result_print(&private_inf); + break; + case NG_USAGE: + usage_print(&private_inf); + break; + default: + error_print(&private_inf,res); + break; + } + + if (private_inf.private_buf != NULL){ + free(private_inf.private_buf); + } + + free((char*)cmdBuf); + return SceEnmResultSyncEnd; + + +} +/** + * @brief Print the usage message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ + +void FmbUsageMainPrint() +{ + char* comment; + + /* USAGE Format */ + comment = " gparam id \n" + " sparam id value \n" + " scmd cmd sub_cmd body [sync] \n" + " svparam id value \n" + " vcmd \n" + " saparam id value \n" + " acmd \n" + " sack [timeout] \n" + " rcbuf [type] \n" + " smsg [timeout] \n" + " vmsg [timeout] \n" + " amsg [timeout] \n" + " gfact [timeout] \n" + " rfact [factor] \n" + " async type [timeout] \n" + " glsi offset \n" + " slsi offset value [mask_bit] \n" + " dlsi offset size [filename] \n" + " gpci type offset \n" + " spci type offset value \n" + " gdata type \n" + " sdata type [value] \n" + " ver \n" + " strm set [-fin filename] [-fout filename] [-st start_postion] [-ed end_postion] \n" + " strm start \n" + " strm stop \n" + " sleep value \n" + " boot filename \n" + " logstr filename \n" + " logstp \n" + " gopstr filename \n" + " gopstp \n" + " scrpt filename \n"; + + /* printing */ + fprintOut(stdout, comment ); + + return ; +} +/** + * @brief Print the start command message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ +void FmbStartCommandPrint(enum FMBCmdEnm command_id) +{ + char* comment; + + /* USAGE Format */ + switch(command_id){ + case FMB_CMD_WAIT_MODE: + comment = "[wait mode] : Waiting for the video message mode\n"; + break; + case FMB_CMD_WAIT_SEQEND: + comment = "[wait seqend] : Waiting for the video message seqend\n"; + break; + case FMB_CMD_WAIT_SYMSG: + comment = "[wait symsg] : Waiting for the system message\n"; + break; + case FMB_CMD_WAIT_SYACK: + comment = "[wait syAck] : Waiting for the system ack\n"; + break; + case FMB_CMD_WAIT_STRM_SEND: + comment = "[wait strm snd] :Waiting for the stream sending\n"; + break; + case FMB_CMD_WAIT_STRM_RCV: + comment = "[wait strm rcv] :Waiting for the stream receiving\n"; + break; + case FMB_CMD_PAUSE: + comment = "[pause] :Waiting for the key input\n"; + break; + default: + return; + } + + /* printing */ + fprintOut(stdout, comment ); + + return ; +} +/** + * @brief Print the end command message. + * + * @param[in] command_id command id + * @return None + * @note None + * @attension None + */ +void FmbEndCommandPrint(enum FMBCmdEnm command_id) +{ + char* comment; + + /* USAGE Format */ + switch(command_id){ + case FMB_CMD_WAIT_MODE: + comment = "[wait mode] : End.\n"; + break; + case FMB_CMD_WAIT_SEQEND: + comment = "[wait seqend] : End.\n"; + break; + case FMB_CMD_WAIT_SYMSG: + comment = "[wait symsg] : End.\n"; + break; + case FMB_CMD_WAIT_SYACK: + comment = "[wait syAck] : End.\n"; + break; + case FMB_CMD_WAIT_STRM_SEND: + comment = "[wait strm snd] : End.\n"; + break; + case FMB_CMD_WAIT_STRM_RCV: + comment = "[wait strm rcv] : End.\n"; + break; + case FMB_CMD_PAUSE: + comment = "[pause] : End.\n"; + break; + default: + return; + } + + /* printing */ + fprintOut(stdout, comment ); + + return ; +} + +/** + * @brief Print the usage message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ + +static void usage_print(struct ioctl_private_inf* pri_inf_p) +{ + char* comment; + + /* USAGE Format */ + switch(pri_inf_p->cmd_id ){ + case FMB_CMD_GPARAM: + comment = "%s id \n\n"; + break; + case FMB_CMD_SPARAM: + comment = "%s id value \n\n"; + break; + case FMB_CMD_SCMD: + comment = "%s cmd sub_cmd body [sync] \n\n"; + break; + case FMB_CMD_SVPARAM: + comment = "%s id value \n\n"; + break; + case FMB_CMD_VCMD: + comment = "%s \n\n"; + break; + case FMB_CMD_SAPARAM: + comment = "%s id value \n\n"; + break; + case FMB_CMD_ACMD: + comment = "%s \n\n"; + break; + case FMB_CMD_SACK: + case FMB_CMD_SMSG: + case FMB_CMD_VMSG: + case FMB_CMD_AMSG: + case FMB_CMD_GFACT: + comment = "%s [timeout] \n\n"; + break; + case FMB_CMD_RCBUF: + comment = "%s [type] \n\n" + "<type> : type of buffer for reset command \n" + " 0x0001(bit:00000001) system-group command \n" + " 0x0002(bit:00000010) video-group command \n" + " 0x0004(bit:00000100) audio-group command \n\n"; + break; + case FMB_CMD_RFACT: + comment = "%s [factor] \n\n"; + break; + case FMB_CMD_ASYNC: + comment = "%s type [timeout] \n\n" + "<type> : type of internal data \n" + " 0x0000 xerror \n" + " 0x0001 vudata \n\n"; + break; + case FMB_CMD_GLSI: + comment = "%s offset \n\n"; + break; + case FMB_CMD_SLSI: + comment = "%s offset value [mask_bit]\n\n"; + break; + case FMB_CMD_DLSI: + comment = "%s offset size [filename] \n\n"; + break; + case FMB_CMD_GPCI: + comment = "%s type offset \n" + "<type> : type of internal data \n" + " 0x0000 Base Address0 \n" + " 0x0001 Base Address1 \n\n"; + break; + case FMB_CMD_SPCI: + comment = "%s type offset value \n" + "<type> : type of internal data \n" + " 0x0000 Base Address0 \n" + " 0x0001 Base Address1 \n\n"; + break; + case FMB_CMD_GDATA: + comment = "%s type \n\n" + "<type> : type of internal data \n" + " 0x0001 encode operation \n" + " 0x0002 asynchronous notification mask \n" + " 0x0003 read DMA timer flag\n" + " 0x0004 write DMA timer flag\n" + " 0x0005 IRQ Status clear flag\n" + " 0x0006 VSYNC control\n\n"; + break; + case FMB_CMD_SDATA: + comment = "%s type [value] \n\n" + "<type> : type of internal data \n" + " 0x0001 encode operation \n" + " 0x0002 asynchronous notification mask \n" + " 0x0003 read DMA timer flag\n" + " 0x0004 write DMA timer flag\n" + " 0x0005 IRQ Status clear flag\n" + " 0x0006 VSYNC control \n" + "<value> : in case of type=0x0001 \n" + " 0x0000 top field \n" + " 0x0001 bottom field \n" + " in case of type=0x0002 \n" + " 0x0001 system-group message \n" + " 0x0002 vedio-group message \n" + " 0x0004 audio-group message \n" + " 0x0008 vudata \n" + " in case of type=0x0003 or 0x0004 \n" + " 0x0000 timer off \n" + " 0x0001 timer on \n" + " in case of type=0x0005 \n" + " 0x0000 clear \n" + " 0x0001 not clear \n" + " in case of type=0x0006 \n" + " 0x0000 top/bottom field \n" + " 0x0001 top field \n" + " 0x0002 bottom field \n\n"; + break; + case FMB_CMD_VER: + comment = "%s \n\n"; + break; + case FMB_CMD_STRM: + comment = "%s directive \n\n" + "<directive> : directive of stream control\n" + " set [-fin filename] [-fout filename] [-st start_postion] [-ed end_postion]\n" + " start\n" + " stop \n\n"; + break; + case FMB_CMD_SLEEP: + comment = "%s value \n\n"; + break; + case FMB_CMD_BOOT: + comment = "%s filename \n\n"; + break; + case FMB_CMD_LOGSTART: + comment = "%s filename \n\n"; + break; + case FMB_CMD_LOGSTOP: + comment = "%s \n\n"; + break; + case FMB_CMD_GOPSTART: + comment = "%s filename \n\n"; + break; + case FMB_CMD_GOPSTOP: + comment = "%s \n\n"; + break; + case FMB_CMD_HELP: + comment = "%s \n\n"; + break; + default: + return; + } + + /* printing */ + fprintOut(stdout, comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter); + + return ; +} + +/** + * @brief Print the result message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ + +static void result_print(struct ioctl_private_inf* pri_inf_p) +{ + char* comment; + struct utsname system_info; + unsigned int i = 0; + unsigned int num = 0; + unsigned int vudata_id = 0; + + /* USAGE Format */ + switch(pri_inf_p->cmd_id ){ + case FMB_CMD_GPARAM: + case FMB_CMD_SPARAM: + comment = "[%s] : id:0x%08lx value:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->private_ldata , pri_inf_p->private_data); + break; + case FMB_CMD_SCMD: + if (pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.sync == FMB_MODE_SYNC) { + comment = "[%s] : cmd:0x%04x sub_cmd:0x%04x body:0x%04x \n" + " cack:0x%04x sub_cack:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.lib_cmd_sys_info.id , + pri_inf_p->cmd_str.lib_cmd_sys_info.sub_id, + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.body, + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.id , + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.sub_id); + } else { + comment = "[%s] : cmd:0x%04x sub_cmd:0x%04x body:0x%04x distinct:0x%08x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.lib_cmd_sys_info.id , + pri_inf_p->cmd_str.lib_cmd_sys_info.sub_id, + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.body, + (unsigned int)pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.distinct); + } + break; + case FMB_CMD_VCMD: + comment = "[%s] : mode:0x%04x sub_mode:0x%04x \n" + " extra_info_bit:0x%04x vdisptime:0x%04x \n" + " inter_gop_gap:0x%04x tfrff:0x%04x vudata_length:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->private_buf[0], pri_inf_p->private_buf[5], pri_inf_p->private_buf[3], + pri_inf_p->private_buf[4], pri_inf_p->private_buf[1], pri_inf_p->private_buf[2], + pri_inf_p->private_buf[6]); + for (i = 0; i < vudata_cnt; i += 1) { + vudata_id = vidbuf[7 + i]; + num = (vudata_id * 2) - 0xC001C; + if ( i%4 == 0 ){ + if (i+1 == vudata_cnt){ + printOut (" vudata[%02x]:0x%04x\n", num, pri_inf_p->private_buf[7+i]); + } + else { + printOut (" vudata[%02x]:0x%04x", num, pri_inf_p->private_buf[7+i]); + } + } + else if (i+1 == vudata_cnt){ + printOut(" vudata[%02x]:0x%04x\n",num, pri_inf_p->private_buf[7+i]); + } + else if (i%4 == 3){ + printOut(" vudata[%02x]:0x%04x\n",num, pri_inf_p->private_buf[7+i]); + } + else { + printOut(" vudata[%02x]:0x%04x",num, pri_inf_p->private_buf[7+i]); + } + } + vudata_cnt = 0; + break; + case FMB_CMD_SVPARAM: + comment = "[%s] : id:0x%08lx value:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->private_ldata , pri_inf_p->private_data); + break; + case FMB_CMD_ACMD: + comment = "[%s] : a_mute:0x%04x a_ch:0x%04x\n" + " lch_scale:0x%04x rch_scale:0x%04x lsch_scale:0x%04x \n" + " rsch_scale:0x%04x cch_scale:0x%04x lfech_scale:0x%04x \n" + " d_ac3_compression:0x%04x d_ac3_dynrng_cut:0x%04x \n" + " d_ac3_dynrng_boost:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->private_buf[0], pri_inf_p->private_buf[1], pri_inf_p->private_buf[2], pri_inf_p->private_buf[3], pri_inf_p->private_buf[7], + pri_inf_p->private_buf[8], pri_inf_p->private_buf[9], pri_inf_p->private_buf[10], pri_inf_p->private_buf[4], pri_inf_p->private_buf[6], + pri_inf_p->private_buf[5]); + break; + case FMB_CMD_SAPARAM: + comment = "[%s] : id:0x%08lx value:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->private_ldata , pri_inf_p->private_data); + break; + case FMB_CMD_SACK: + comment = "[%s] : cack:0x%04x sub_cack:0x%04x distinct:0x%08x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.cmd_ack_sys_info.id, + pri_inf_p->cmd_str.cmd_ack_sys_info.sub_id, + (unsigned int)pri_inf_p->cmd_str.cmd_ack_sys_info.distinct); + break; + case FMB_CMD_RCBUF: + comment = "[%s] : type:0x%08lx \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.cmd_info_reset.type); + break; + case FMB_CMD_SMSG: + comment = "[%s] : msg:0x%04x sub_msg:0x%04x body:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.msg_sys_info.id, + pri_inf_p->cmd_str.msg_sys_info.sub_id, + pri_inf_p->cmd_str.msg_sys_info.body); + break; + case FMB_CMD_VMSG: + comment = "[%s] : mode:0x%02x sub_mode:0x%02x \n" + " cmd_invalid:0x%02x v_error_level_h:0x%04x v_error_level_l:0x%04x \n" + " Hex dump \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + (pri_inf_p->private_buf[1] & 0xFF), (pri_inf_p->private_buf[41] & 0x03), + (pri_inf_p->private_buf[1] & 0x4000)>>14, (pri_inf_p->private_buf[4] & 0xffff), (pri_inf_p->private_buf[5] & 0xffff)); + data_dump((FMB_VIDEO_MSG_REG_SIZE / 2), pri_inf_p->private_buf); + break; + case FMB_CMD_AMSG: + comment = "[%s] : a_mute:0x%02x a_ch:0x%02x a_mute_st:0x%02x av_sync:0x%02x \n" + " Hex dump \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + (pri_inf_p->private_buf[2] & 0x01), (pri_inf_p->private_buf[1] & 0x03), (pri_inf_p->private_buf[2] & 0x8000)>>15, (pri_inf_p->private_buf[3] & 0x03)); + data_dump((FMB_AUDIO_MSG_REG_SIZE / 2), pri_inf_p->private_buf); + break; + case FMB_CMD_GFACT: + comment = "[%s] : factor:0x%08lx \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.factor_info.factor); + break; + case FMB_CMD_RFACT: + comment = "[%s] : factor:0x%08lx \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.factor_reset.factor); + break; + case FMB_CMD_ASYNC: + comment = "[%s] : type:0x%08lx \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.async_info.type); + if (pri_inf_p->cmd_str.async_info.type == FMB_TYPE_ASYNC_XERROR) { + comment = " xerror : %04x%04x %04x%04x %04x%04x %04x%04x \n"; + printOut (comment ,pri_inf_p->private_buf[0], pri_inf_p->private_buf[1], pri_inf_p->private_buf[2], pri_inf_p->private_buf[3], + pri_inf_p->private_buf[4], pri_inf_p->private_buf[5], pri_inf_p->private_buf[6], pri_inf_p->private_buf[7]); + } else { + comment = " vudata \n" + " Hex dump\n"; + printOut (comment ); + data_dump((FMB_VUDATA_INFO_REG_SIZE / 2), pri_inf_p->private_buf); + } + break; + case FMB_CMD_GLSI: + case FMB_CMD_SLSI: + comment = "[%s] : offset:0x%08lx value:0x%04x \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.reg_info.offset , pri_inf_p->private_data); + break; + case FMB_CMD_GPCI: + case FMB_CMD_SPCI: + comment = "[%s] : type:0x%08lx offset:0x%08lx value:0x%08lx \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.pci_reg_info.reg_type , pri_inf_p->cmd_str.pci_reg_info.offset , pri_inf_p->private_ldata); + break; + case FMB_CMD_GDATA: + case FMB_CMD_SDATA: + comment = "[%s] : type:0x%08lx value:0x%08lx \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.internal_info.type , pri_inf_p->cmd_str.internal_info.data); + break; + case FMB_CMD_VER: + uname(&system_info); + comment = "[%s] : firm : %04x-%04x-%04x-%04x \n" + " driver : %s \n" + " kernel : %s \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, + pri_inf_p->cmd_str.lib_version_info.firm_ver[0], + pri_inf_p->cmd_str.lib_version_info.firm_ver[1], + pri_inf_p->cmd_str.lib_version_info.firm_ver[2], + pri_inf_p->cmd_str.lib_version_info.firm_ver[3], + pri_inf_p->cmd_str.lib_version_info.driver_ver, + system_info.release); + break; + default: + break; + } + + return ; +} + +/** + * @brief Print the detail error message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ + +static void api_ditail_err_print(struct ioctl_private_inf* pri_inf_p) +{ + char* comment; + + /* API Detail error Format */ + switch(pri_inf_p->cmd_id ){ + case FMB_CMD_SVPARAM: + switch (pri_inf_p->cmd_str.cmd_video_info.cprm_num) { + case 1: + comment = "Can't set mode parameter \n"; + break; + case 2: + comment = "Can't set inter_gop_gap parameter \n"; + break; + case 3: + comment = "Can't set tfrff parameter \n"; + break; + case 4: + comment = "Can't set extra_info_bit parameter \n"; + break; + case 5: + comment = "Can't set vdisptime parameter \n"; + break; + case 6: + comment = "Can't set sub_mode parameter \n"; + break; + case 7: + comment = "Can't set vudata_length parameter \n"; + break; + default: + comment = "internal error \n"; + break; + } + break; + case FMB_CMD_SAPARAM: + switch (pri_inf_p->cmd_str.cmd_audio_info.cprm_num) { + case 1: + comment = "Can't set a_mute parameter \n"; + break; + case 2: + comment = "Can't set a_ch parameter \n"; + break; + case 3: + comment = "Can't set lch_scale parameter \n"; + break; + case 4: + comment = "Can't set rch_scale parameter \n"; + break; + case 5: + comment = "Can't set d_ac3_compression parameter \n"; + break; + case 6: + comment = "Can't set d_ac3_dynrng_cut parameter \n"; + break; + case 7: + comment = "Can't set d_ac3_dynrng_boost parameter \n"; + break; + case 8: + comment = "Can't set lsch_scale parameter \n"; + break; + case 9: + comment = "Can't set rsch_scale parameter \n"; + break; + case 10: + comment = "Can't set cch_scale parameter \n"; + break; + case 11: + comment = "Can't set lfech_scale parameter \n"; + break; + default: + comment = "internal error \n"; + break; + } + break; + default: + return; + } + + /* printing */ + printOut (comment); + + return ; +} + +/** + * @brief Print the timeout message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ + +static void api_timeout_print(struct ioctl_private_inf* pri_inf_p) +{ + char* comment; + int timeout; + + /* timeout Format */ + switch(pri_inf_p->cmd_id ){ + case FMB_CMD_SACK: + timeout = pri_inf_p->cmd_str.cmd_ack_sys_info.timeout; + break; + case FMB_CMD_SMSG: + timeout = pri_inf_p->cmd_str.msg_sys_info.timeout; + break; + case FMB_CMD_VMSG: + timeout = pri_inf_p->cmd_str.msg_video_info.timeout; + break; + case FMB_CMD_AMSG: + timeout = pri_inf_p->cmd_str.msg_audio_info.timeout; + break; + case FMB_CMD_GFACT: + timeout = pri_inf_p->cmd_str.factor_info.timeout; + break; + case FMB_CMD_ASYNC: + timeout = pri_inf_p->cmd_str.async_info.timeout; + break; + default: + comment = "[%s] : timeout \n"; + /* printing */ + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter ); + return; + } + comment = "[%s] : none (timeout:%ldms) \n"; + /* printing */ + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter, timeout ); + + return ; +} + +/** + * @brief Print the errro message. + * + * @param[in] pri_inf_p private information + * @return None + * @note None + * @attension None + */ + +static void error_print(struct ioctl_private_inf* pri_inf_p , int err) +{ + char* comment; + + /* Format */ + switch(err ){ + case NG_PARAM_ERROR: + comment = "error: parameter is abnormal \n"; + break; + case NG_OPTION_ERROR: + comment = "error: option parameter is abnormal \n"; + break; + case NG_VERIFY_ERROR: + switch(pri_inf_p->cmd_id){ + case FMB_CMD_SLSI: + comment = "error: no verification. offset:0x%08lx reg:0x%04x \n"; + printOut (comment , + pri_inf_p->cmd_str.reg_info.offset , pri_inf_p->private_data); + return; + case FMB_CMD_SPCI: + comment = "error: no verification. offset:0x%08lx value:0x%08lx \n"; + printOut (comment , + pri_inf_p->cmd_str.pci_reg_info.offset , pri_inf_p->private_ldata); + return; + default: + return; + } + return; + case NG_ERR_IOCTL: + switch (errno) { + case EOPNOTSUPP: + comment = "error: no support function \n"; + break; + case EINVAL: + api_ditail_err_print(pri_inf_p); + comment = "error: parameter is abnormal \n"; + break; + case ETIMEDOUT: + api_timeout_print(pri_inf_p); + return ; + case EAGAIN: + comment = "[%s] : none \n"; + printOut (comment , g_internal_jump_table[pri_inf_p->cmd_id].option_parameter); + return ; + default: + FmbErrPrint( MSG_ERR_IOCTL,__FILE__, __LINE__); + return; + } + break; + case NG_ERR_MALLOC: + FmbErrPrint( MSG_ERR_IOCTL,__FILE__, __LINE__); + return; + default: + return; + } + + fprintOut(stderr, comment); + + return ; +} + +/** + * @brief To check whether include the character which does not allow in the character string. + * + * @param[in] string input character string + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attension None + */ + +static int check_unsigned_string(const char* string) +{ + int rc; + + if (strspn(string, HEXDEC_CHAR) == strlen(string)) { + rc=0; + } else { + rc=-1; + } + + return rc; +} + + +/** + * @brief Convert and check of input parameter (type of unsigned long) + * + * @param[in] input_param input parameter of argv + * @return struct param_check convert data and convert result + * @note None + * @attention None + */ + +static struct param_check param_check_unsignlong(char* input_param) +{ + char* err_val; + struct param_check param_check_out={0}; + + if (check_unsigned_string(input_param) != 0) { + param_check_out.result = NG; + return param_check_out; + } + errno = 0; + param_check_out.short_cnvdata = 0; + param_check_out.long_cnvdata = strtoul(input_param, &err_val, 0); + if (errno != 0) { + param_check_out.result = NG; + return param_check_out; + } + if (*err_val != '\0') { + param_check_out.result = NG; + return param_check_out; + } + param_check_out.result = OK; + return param_check_out; +} + +/** + * @brief convert and check of input parameter (type of unsigned short) + * + * @param[in] input_param input parameter of argv + * @return struct param_check convert data and convert result + * @note None + * @attention None + */ + +static struct param_check param_check_unsignshort(char* input_param) +{ + char* err_val; + struct param_check param_check_out={0}; + + if (check_unsigned_string(input_param) != 0) { + param_check_out.result = NG; + return param_check_out; + } + errno = 0; + param_check_out.short_cnvdata = 0; + param_check_out.long_cnvdata = strtoul(input_param, &err_val, 0); + if (errno != 0) { + param_check_out.result = NG; + return param_check_out; + } + if (*err_val != '\0') { + param_check_out.result = NG; + return param_check_out; + } + /* overflow check */ + if (((param_check_out.long_cnvdata >> 16) & 0xffff) != 0 ) { /* pgr0539 */ + param_check_out.result = NG; + return param_check_out; + } + param_check_out.short_cnvdata = (unsigned short)param_check_out.long_cnvdata; + param_check_out.result = OK; + return param_check_out; +} +/** + * @brief Convert and check of input parameter (type of signed long) + * + * @param[in] input_param input parameter of argv + * @return struct param_check convert data and convert result + * @note None + * @attention None + */ + +static struct param_check param_check_signlong(char* input_param) +{ + char* err_val; + struct param_check param_check_out; + + errno = 0; + param_check_out.short_cnvdata = 0; + param_check_out.long_cnvdata = strtol(input_param, &err_val, 0); + if (errno != 0) { + param_check_out.result = NG; + return param_check_out; + } + if (*err_val != '\0') { + param_check_out.result = NG; + return param_check_out; + } + param_check_out.result = OK; + return param_check_out; +} + +/** + * @brief Retrieves parameters of the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] id + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_field_param(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 3) { + return NG_USAGE; + } + + /* check 1st parameter of id */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_ldata = param_check_out.long_cnvdata; + + pri_inf_p->cmd_str.param_info.prm_id = &pri_inf_p->private_ldata; + pri_inf_p->cmd_str.param_info.prm_data = &pri_inf_p->private_data; + pri_inf_p->cmd_str.param_info.prm_num = 1; + + /* call API function of retrieves the parameters from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.param_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Sets parameters of the the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] id + * argv[3] value + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int set_field_param(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 4) { + return NG_USAGE; + } + + /* check 1st parameter of id */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_ldata = param_check_out.long_cnvdata; + + /* check 2nd parameter of value */ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_data = param_check_out.short_cnvdata; + + pri_inf_p->cmd_str.param_info.prm_id = &pri_inf_p->private_ldata; + pri_inf_p->cmd_str.param_info.prm_data = &pri_inf_p->private_data; + pri_inf_p->cmd_str.param_info.prm_num = 1; + + /* call API function of sets the parameters of the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.param_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Sends a system-group command to the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] cmd + * argv[3] sub_cmd + * argv[4] body + * argv[5] [sync] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int send_cmd_sys(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 5 && argc != 6) { + return NG_USAGE; + } + + /* check 1st parameter of cmd */ + param_check_out = param_check_unsignshort(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.id = param_check_out.short_cnvdata; + pri_inf_p->cmd_str.lib_cmd_sys_info.id = pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.id; + + /* check 2nd parameter of sub_cmd */ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.sub_id = param_check_out.short_cnvdata; + pri_inf_p->cmd_str.lib_cmd_sys_info.sub_id = pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.sub_id; + + /* check 3rd parameter of body */ + param_check_out = param_check_unsignshort(argv[4]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.body = param_check_out.short_cnvdata; + + /* check 4st parameter of sync [omit is possible] */ + if (argc == 5) { + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.sync = FMB_MODE_SYNC; + } else { + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.sync = FMB_MODE_ASYNC; + param_check_out = param_check_unsignlong(argv[5]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info.distinct = (void*)param_check_out.long_cnvdata; + } + + /* call API function of sends a system-group command to the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.lib_cmd_sys_info.cmd_sys_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +//MB86H55 add start +/** + * @brief Sends a video-group command to the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] mode + * argv[3] sub_mode + * argv[4] [tfrff] + * argv[5] [extra_info_bit] + * argv[6] [vdisptime] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int set_video_param(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 4) { + return NG_USAGE; + } + + /* check 1st parameter of id */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_ldata = param_check_out.long_cnvdata; + + /* check 2nd parameter of value */ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_data = param_check_out.short_cnvdata; + + if (pri_inf_p->private_ldata < 0x00060000 || pri_inf_p->private_ldata > 0x0006008e) { + return NG_PARAM_ERROR; + } + + if (pri_inf_p->private_ldata == 0x00060001) { + vdatabuf[0] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00060002) { + vdatabuf[1] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00060004) { + vdatabuf[2] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00060005) { + vdatabuf[3] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00060006) { + vdatabuf[4] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00060008) { + vdatabuf[5] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00060009) { + vdatabuf[6] = pri_inf_p->private_data; + } + + if (pri_inf_p->private_ldata > 0x0006000d) { + vdatabuf[7 + vudata_cnt] = pri_inf_p->private_data; + vidbuf[7 + vudata_cnt] = pri_inf_p->private_ldata; + vudata_cnt++; + } + + return OK; +} +//MB86H55 add end + +/** + * @brief Sends a video-group command to the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] mode + * argv[3] sub_mode + * argv[4] [tfrff] + * argv[5] [extra_info_bit] + * argv[6] [vdisptime] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int send_cmd_video(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + int i; + + if (argc != 2) { + return NG_USAGE; + } + + pri_inf_p->private_buf = malloc(sizeof(unsigned short) * 141); + if (pri_inf_p->private_buf == NULL) { + return NG_ERR_MALLOC; + } + + memcpy(pri_inf_p->private_buf,vdatabuf,sizeof(unsigned short) * 141); + + pri_inf_p->cmd_str.cmd_video_info.cprm_num = 141; + pri_inf_p->cmd_str.cmd_video_info.cprm_id = vidbuf; + pri_inf_p->cmd_str.cmd_video_info.cprm_data = vdatabuf; + + /* call API function of sends a video-group command to the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.cmd_video_info) != OK) { + return NG_ERR_IOCTL; + } + + vdatabuf[0] = 0x0000; + vdatabuf[1] = 0x0000; + vdatabuf[2] = 0x0002; + vdatabuf[3] = 0x0000; + vdatabuf[4] = 0x000a; + for (i = 5; i < 141 ; i += 1) { + vdatabuf[i] = 0x0000; + } + + return OK; +} + +/** + * @briefSends an audio-group command to the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] a_mute + * argv[3] [a_ch] + * argv[4] [lch_scale] + * argv[5] [rch_scale] + * argv[6] [lsch_scale] + * argv[7] [rsch_scale] + * argv[8] [cch_scale] + * argv[9] [lfech_scale] + * argv[10] [d_ac3_compression] + * argv[11] [d_ac3_dynrng_cut] + * argv[12] [d_ac3_dynrng_boost] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int set_audio_param(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 4) { + return NG_USAGE; + } + + /* check 1st parameter of id */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_ldata = param_check_out.long_cnvdata; + + /* check 2nd parameter of value */ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_data = param_check_out.short_cnvdata; + + if (pri_inf_p->private_ldata < 0x00070000 || pri_inf_p->private_ldata > 0x0007000c) { + return NG_PARAM_ERROR; + } + + if (pri_inf_p->private_ldata == 0x00070001) { + adatabuf[0] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070002) { + adatabuf[1] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070003) { + adatabuf[2] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070004) { + adatabuf[3] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070005) { + adatabuf[4] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070006) { + adatabuf[5] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070007) { + adatabuf[6] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070008) { + adatabuf[7] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x00070009) { + adatabuf[8] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x0007000a) { + adatabuf[9] = pri_inf_p->private_data; + } + else if (pri_inf_p->private_ldata == 0x0007000b) { + adatabuf[10] = pri_inf_p->private_data; + } + + return OK; +} + +/** + * @briefSends an audio-group command to the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] a_mute + * argv[3] [a_ch] + * argv[4] [lch_scale] + * argv[5] [rch_scale] + * argv[6] [lsch_scale] + * argv[7] [rsch_scale] + * argv[8] [cch_scale] + * argv[9] [lfech_scale] + * argv[10] [d_ac3_compression] + * argv[11] [d_ac3_dynrng_cut] + * argv[12] [d_ac3_dynrng_boost] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int send_cmd_audio(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + + if (argc != 2 ) { + return NG_USAGE; + } + + pri_inf_p->private_buf = malloc(sizeof(unsigned short) * 11); + if (pri_inf_p->private_buf == NULL) { + return NG_ERR_MALLOC; + } + memcpy(pri_inf_p->private_buf,adatabuf,sizeof(unsigned short) * 11); + + pri_inf_p->cmd_str.cmd_audio_info.cprm_num = 11; + pri_inf_p->cmd_str.cmd_audio_info.cprm_id = aidbuf; + pri_inf_p->cmd_str.cmd_audio_info.cprm_data = adatabuf; + + /* call API function of sends an audio-group command to the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.cmd_audio_info) != OK) { + return NG_ERR_IOCTL; + } + + adatabuf[0] = 0x0000; + adatabuf[1] = 0x0000; + adatabuf[2] = 0x8000; + adatabuf[3] = 0x8000; + adatabuf[4] = 0x0002; + adatabuf[5] = 0x0080; + adatabuf[6] = 0x0080; + adatabuf[7] = 0x8000; + adatabuf[8] = 0x8000; + adatabuf[9] = 0x8000; + adatabuf[10] = 0x8000; + + return OK; +} + +/** + * @brief It retrieves a system-group command acknowledge from the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [timeout] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_sys_cmd_ack(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 2 && argc != 3) { + return NG_USAGE; + } + + + /* check 1st parameter of timeout [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.cmd_ack_sys_info.timeout = 0; + } else { + param_check_out = param_check_signlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.cmd_ack_sys_info.timeout = param_check_out.long_cnvdata; + } + + /* call API function of retrieves the acknowledge to a system-group command from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.cmd_ack_sys_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Clear the internal buffer for command. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [type] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int reset_cmd_info(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 2 && argc != 3) { + return NG_USAGE; + } + + /* check 1st parameter of type [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.cmd_info_reset.type = FMB_CMD_INFO_ALL; + } else { + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.cmd_info_reset.type = param_check_out.long_cnvdata; + } + + /* call API function of reset the internal buffer for command. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.cmd_info_reset) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Retrieves a system-group message from the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [timeout] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_msg_sys(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc !=2 && argc !=3) { + return NG_USAGE; + } + + /* check 1st parameter of timeout [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.msg_sys_info.timeout = 0; + } else { + param_check_out = param_check_signlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.msg_sys_info.timeout = param_check_out.long_cnvdata; + } + + s_smsg_body = 0xFFFF; + + /* call API function of retrieves a system-group message command from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.msg_sys_info) != OK) { + return NG_ERR_IOCTL; + } + + s_smsg_body = pri_inf_p->cmd_str.msg_sys_info.body; + + return OK; +} + +/** + * @brief Retrieves a video-group message from the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [timeout] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_msg_video(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 2 && argc != 3) { + return NG_USAGE; + } + + /* check 1st parameter of timeout [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.msg_video_info.timeout = 0; + } else { + param_check_out = param_check_signlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.msg_video_info.timeout = param_check_out.long_cnvdata; + } + + /** memory allocation */ + pri_inf_p->private_buf = malloc(sizeof(unsigned char) * FMB_VIDEO_MSG_REG_SIZE); + + if (pri_inf_p->private_buf == NULL) { + return NG_ERR_MALLOC; + } + + pri_inf_p->cmd_str.msg_video_info.msg = pri_inf_p->private_buf; + + s_vmsg_mode = 0xFFFF; + s_vmsg_seqend = 0xFFFF; + + /* call API function of retrieves a video-group message command from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.msg_video_info) != OK) { + return NG_ERR_IOCTL; + } + + s_vmsg_mode = pri_inf_p->private_buf[1] & 0xFF ; + s_vmsg_seqend = ( (pri_inf_p->private_buf[2] & 0x4)>>2 ); + + return OK; +} + +/** + * @brief Retrieves an audio-group message from the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [timeout] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_msg_audio(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 2 && argc != 3 ) { + return NG_USAGE; + } + + /* check 1st parameter of timeout [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.msg_audio_info.timeout = 0; + } else { + param_check_out = param_check_signlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.msg_audio_info.timeout = param_check_out.long_cnvdata; + } + + /** memory allocation */ + pri_inf_p->private_buf = malloc(sizeof(unsigned char) * FMB_AUDIO_MSG_REG_SIZE); + + if (pri_inf_p->private_buf == NULL) { + return NG_ERR_MALLOC; + } + + pri_inf_p->cmd_str.msg_audio_info.msg = pri_inf_p->private_buf; + + /* call API function of retrieves an audio-group message command from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.msg_audio_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Retrieves the asynchronous notification factor received from the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [timeout] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_factor(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 2 && argc != 3 ) { + return NG_USAGE; + } + + /* check 1st parameter of timeout [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.factor_info.timeout = 0; + } else { + param_check_out = param_check_signlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.factor_info.timeout = param_check_out.long_cnvdata; + } + + /* call API function of retrieves the asynchronous notification factor from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.factor_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Resets the asynchronous notification factor received from the MB86-LSI + * and asynchronous notification information. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] [factor] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int reset_factor(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 2 && argc != 3) { + return NG_USAGE; + } + + /* check 1st parameter of timeout [omit is possible] */ + if (argc == 2) { + pri_inf_p->cmd_str.factor_reset.factor = FMB_FACTOR_ASYNC_ALL; + } else { + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.factor_reset.factor = param_check_out.long_cnvdata; + } + + /* call API function of retrieves the asynchronous notification factor + and resets the nonnotification information buffer. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.factor_reset) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Retrieves the asynchronous notification factor of exclude + * received message from the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] type + * argv[3] [timeout] + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_async_info(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 3 && argc != 4) { + return NG_USAGE; + } + + /* check 1st parameter of type */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.async_info.type = param_check_out.long_cnvdata; + + /* check 2nd parameter of timeout [omit is possible] */ + if (argc == 3) { + pri_inf_p->cmd_str.async_info.timeout = 0; + } else { + param_check_out = param_check_signlong(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.async_info.timeout = param_check_out.long_cnvdata; + } + + if (pri_inf_p->cmd_str.async_info.type == FMB_TYPE_ASYNC_VUDATA) { + /** memory allocation */ + pri_inf_p->private_buf = malloc(sizeof(unsigned char) * FMB_VUDATA_INFO_REG_SIZE); + } else { + pri_inf_p->private_buf = malloc(sizeof(unsigned short) * (FMB_XERROR_INFO_REG_SIZE / 2) ); + } + if (pri_inf_p->private_buf == NULL) { + return NG_ERR_MALLOC; + } + pri_inf_p->cmd_str.async_info.data = pri_inf_p->private_buf; + + /* call API function of retrieves the asynchronous notification information from the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.async_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Reads the register of the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] offset + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_lsi_reg(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 3) { + return NG_USAGE; + } + + /* check 1st parameter of offset */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.reg_info.offset = param_check_out.long_cnvdata; + + pri_inf_p->cmd_str.reg_info.prm_data = &pri_inf_p->private_data; + pri_inf_p->cmd_str.reg_info.reg_num = 1; + + /* call API function of reads a register of the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.reg_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Sets the register of the MB86-LSI. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] offset + * argv[3] value + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int set_lsi_reg(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + unsigned short mask_data; + unsigned short value_data; + + if (argc != 4 && argc != 5 ) { + return NG_USAGE; + } + + + /* check 1st parameter of offset */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.reg_info.offset = param_check_out.long_cnvdata; + + /* check 2nd parameter of value */ + param_check_out = param_check_unsignshort(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_data = param_check_out.short_cnvdata; + value_data = param_check_out.short_cnvdata; + + pri_inf_p->cmd_str.reg_info.prm_data = &pri_inf_p->private_data; + pri_inf_p->cmd_str.reg_info.reg_num = 1; + + /* mask_bit */ + if (argc > 4 ){ + param_check_out = param_check_unsignshort(argv[4]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + mask_data = param_check_out.short_cnvdata; + if (DrvIoctlCmd(pri_inf_p->fd, + FMB_API_GET_LSI_REG, + &pri_inf_p->cmd_str.reg_info) != OK) { + return NG_ERR_IOCTL; + } + pri_inf_p->private_data = pri_inf_p->private_data & ~mask_data; + pri_inf_p->private_data = pri_inf_p->private_data | value_data; + } + + /* call API function of writes to a register of the LSI. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.reg_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Dump the register of the MB86. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] offset + * argv[3] value + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int dump_lsi_reg(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + FILE* _fp = NULL; + struct param_check param_check_out; + struct fmb_reg_info reg_info; + unsigned short private_data; + unsigned long offset = 0x80000; + unsigned int size= 512; + unsigned long do_size; + char* err_cause; + + if (argc != 4 && argc != 5) { + return NG_USAGE; + } + /* offset */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + offset = param_check_out.long_cnvdata; + + /* dumpsize */ + param_check_out = param_check_unsignlong(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + size = param_check_out.long_cnvdata; + + if (argc > 4 ){ + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + _fp = fopen(argv[4] , "w"); + + if(_fp == NULL){ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",argv[4] ,errno, err_cause); + FMB_FUNC(FALSE); + return FALSE; + } + } + + size = param_check_out.long_cnvdata; + + reg_info.offset = offset; + reg_info.prm_data = &private_data; + reg_info.reg_num = 1; + + do_size = 0; + + printOut("[dlsi] : offset:0x%08lx size:0x%04x \n", reg_info.offset, size); + if(_fp != NULL ){ + fprintf(_fp, "[dlsi] : offset:0x%08lx size:0x%04x \n", reg_info.offset, size ); + } + + while (do_size < size) { + + if (DrvIoctlCmd(pri_inf_p->fd, FMB_API_GET_LSI_REG , ®_info) != OK) { + LogFmb("FMB_API_GET_LSI_REG NG!!"); + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + return NG_ERR_IOCTL; + } + + if ( do_size%8 ==0 ){ + if (_fp == NULL){ + printOut("\n0x%08lx : 0x%04x",reg_info.offset,private_data); + } + else if(_fp != NULL){ + fprintf(_fp, "\n0x%08lx : 0x%04x",reg_info.offset,private_data ); + } + } + else { + if (_fp == NULL){ + printOut(" 0x%04x",private_data); + } + else if(_fp != NULL){ + fprintf(_fp, " 0x%04x",private_data ); + } + } + do_size += sizeof(unsigned short); + reg_info.offset += sizeof(unsigned short); + } + if (_fp == NULL){ + fprintOut(stdout, "\n"); + } + else if( _fp != NULL ){ + fprintf(_fp, " \n"); + } + + if (argc > 4 ){ + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + } + + return OK; /* pgr0524 */ +} + +/** + * @brief Reads an PCI register of the MB86-RB. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] type + * argv[3] offset + * @return 0 Normal end + * @note None + * @attention None + */ + +int get_pci_reg(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 4) { + return NG_USAGE; + } + + /* check 1st parameter of type */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.pci_reg_info.reg_type = param_check_out.long_cnvdata; + + /* check 2nd parameter of type */ + param_check_out = param_check_unsignlong(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.pci_reg_info.offset = param_check_out.long_cnvdata; + + pri_inf_p->cmd_str.pci_reg_info.prm_data = &pri_inf_p->private_ldata; + pri_inf_p->cmd_str.pci_reg_info.reg_num = 1; + + /* call API function of reads the PCI register of MB86-RB. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.pci_reg_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Sets an PCI register of the MB86-RB. + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] type + * argv[3] offset + * argv[4] value + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int set_pci_reg(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 5 ) { + return NG_USAGE; + } + + /* check 1st parameter of offset */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.pci_reg_info.reg_type = param_check_out.long_cnvdata; + + /* check 2nd parameter of offset */ + param_check_out = param_check_unsignlong(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.pci_reg_info.offset = param_check_out.long_cnvdata; + + /* check 3rd parameter of value */ + param_check_out = param_check_unsignlong(argv[4]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->private_ldata = param_check_out.long_cnvdata; + + pri_inf_p->cmd_str.pci_reg_info.prm_data = &pri_inf_p->private_ldata; + pri_inf_p->cmd_str.pci_reg_info.reg_num = 1; + + /* call API function of writes to the PCI register of MB86-RB. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.pci_reg_info) != OK) { + return NG_ERR_IOCTL; + } + + + return OK; +} + +/** + * @brief Retrieves the internal information for driver + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] type + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_drv_internal_info(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 3) { + return NG_USAGE; + } + + /* check 1st parameter of type */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.internal_info.type = param_check_out.long_cnvdata; + + /* call API function of retrieves the internal information for driver. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.internal_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} + +/** + * @brief Sets the internal information for driver + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[2] type + * argv[3] value + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int set_drv_internal_info(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + struct param_check param_check_out; + + if (argc != 3 && argc != 4) { + return NG_USAGE; + } + + /* check 1st parameter of type */ + param_check_out = param_check_unsignlong(argv[2]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.internal_info.type = param_check_out.long_cnvdata; + + /* check 2nd parameter of value */ + if (argc == 3) { + if (pri_inf_p->cmd_str.internal_info.type != FMB_DATA_TYPE_NOTIFY) { + return NG_USAGE; + } + pri_inf_p->cmd_str.internal_info.data = FMB_DATA_NOTIFY_ALL; + } else { + param_check_out = param_check_unsignlong(argv[3]); + if (param_check_out.result != OK) { + return NG_PARAM_ERROR; + } + pri_inf_p->cmd_str.internal_info.data = param_check_out.long_cnvdata; + } + + /* call API function of sets the internal information for driver. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.internal_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} +/** + * @brief Get each version information + * 1)the MB86-LSI firmware version + * 2)PCI version + * 3)Linux driver version + * 4)Linux kernel version + * + * @param[in] fd file descriptor + * @param[in] argc input character code counter + * @param[in] argv input character code + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +int get_version_info(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + + if (argc != 2) { + return NG_USAGE; + } + + pri_inf_p->cmd_str.lib_version_info.version_info.firm_ver = pri_inf_p->cmd_str.lib_version_info.firm_ver; + pri_inf_p->cmd_str.lib_version_info.version_info.driver_ver = pri_inf_p->cmd_str.lib_version_info.driver_ver; + + /* call API function of retrieves each version information. */ + if (DrvIoctlCmd(pri_inf_p->fd, + g_internal_jump_table[pri_inf_p->cmd_id].ioctl_cmd, + &pri_inf_p->cmd_str.lib_version_info.version_info) != OK) { + return NG_ERR_IOCTL; + } + + return OK; +} +/** + * @brief Dump the data + * @param[in] max_num number of data + * @param[in] msg 16bit datas + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ + +static void data_dump(unsigned short max_num, unsigned short* msg) +{ + int i; + + for (i = 0; i < max_num; i += 8) { + printOut(" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x \n", + (msg[i+0] & 0xFF00)>>8 , (msg[i+0] & 0x00FF) , (msg[i+1] & 0xFF00)>>8 , (msg[i+1] & 0x00FF) , + (msg[i+2] & 0xFF00)>>8 , (msg[i+2] & 0x00FF) , (msg[i+3] & 0xFF00)>>8 , (msg[i+3] & 0x00FF) , + (msg[i+4] & 0xFF00)>>8 , (msg[i+4] & 0x00FF) , (msg[i+5] & 0xFF00)>>8 , (msg[i+5] & 0x00FF) , + (msg[i+6] & 0xFF00)>>8 , (msg[i+6] & 0x00FF) , (msg[i+7] & 0xFF00)>>8 , (msg[i+7] & 0x00FF) ); + } +} + +/** + * @brief main of the dirver control application. + * + * @param[in] pri_inf primitive infomations + * @param[in] argc input character code counter + * @param[in] argv input character code + * argv[1] option + * @return 0 Normal end + * @return -1 Abnormal end + * @note None + * @attention None + */ +int strm_command(struct ioctl_private_inf* pri_inf, int argc, char** argv) +{ + int index; + BOOL res; + enum FMBFileResultEnum fresult; + int errPacketCnt; + int startPos=0; + int endPos=0; + HANDLE hScet; + + + FMB_FUNC(TRUE); + hScet = gp_FmbComProperty->hEmptyScet; + if (argc < 3 || argc > 9) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + if ( strcmp("set",argv[2])==0 ) { + s_Strmmode = FMBEnmNothing; + + /* -fin */ + index = FmbgetArg("-fin", argc , argv); + if (index!=0){ + fresult = FmbFileOpen(FMBEnmInFile,argv[index],&errPacketCnt); + if (fresult != FMBEnmFileNormal){ + FmbErrPrintUsr("File Open error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_OPTION_ERROR; + } + s_Strmmode = FMBEnmSend; + } + + /* -fout */ + index = FmbgetArg("-fout", argc , argv); + if (index!=0){ + fresult = FmbFileOpen(FMBEnmOutFile,argv[index],&errPacketCnt); + if (fresult != FMBEnmFileNormal){ + FmbErrPrintUsr("File Open error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_OPTION_ERROR; + } + if (s_Strmmode == FMBEnmSend){ + s_Strmmode = FMBEnmRcvSend; + FmbErrPrintUsr("File Combination error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_OPTION_ERROR; + } + else{ + s_Strmmode = FMBEnmRcv; + } + } + + if (s_Strmmode == FMBEnmNothing){ + FMB_FUNC(FALSE); + return NG_USAGE; + } + + + startPos=0; + index = FmbgetArg("-st", argc , argv); + if (index!=0){ + + startPos = StrToUnsignedInt(argv[index]); + if ( startPos == -1 ){ + FmbErrPrintUsr("Illegal start_position." ,__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_OPTION_ERROR; + } + } + endPos=0; + index = FmbgetArg("-ed", argc , argv); + if (index!=0){ + + endPos = StrToUnsignedInt(argv[index]); + if ( endPos == -1 ){ + FmbErrPrintUsr("Illegal end_position." ,__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_OPTION_ERROR; + } + } + FmbSetStrmFilePos(FMBEnmStartPos, startPos); + FmbSetStrmFilePos(FMBEnmEndPos, endPos); + } + + else if ( strcmp("start",argv[2])==0 ) { + + res = FmbStreamBegin( s_Strmmode, hScet ); + if ( res == FALSE ){ + FmbErrPrintUsr("Cannot start.",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_OPTION_ERROR; + } + + } + + else if ( strcmp("stop",argv[2])==0 ) { + + FmbStreamRest(hScet); + + } + else{ + FMB_FUNC(FALSE); + return NG_USAGE; + } + + FMB_FUNC(FALSE); + return OK; + +} +int sleep_command(struct ioctl_private_inf* pri_inf, int argc, char** argv) +{ + int slptime=0; + + FMB_FUNC(TRUE); + if (argc != 3) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + slptime = StrToUnsignedInt(argv[2]); + if ( slptime < 0 ){ + FmbErrPrintUsr("sleep time error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_PARAM_ERROR; + } + + usleep(slptime * 1000); + + FMB_FUNC(FALSE); + return OK; + +} + +int logstart_command(struct ioctl_private_inf* pri_inf, int argc, char** argv) +{ + + FMB_FUNC(TRUE); + if (argc != 3) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + if(!StartLogFile(argv[2],"w")){ + FmbErrPrintUsr("File open error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_PARAM_ERROR; + } + + FMB_FUNC(FALSE); + return OK; + +} + +int logstop_command(struct ioctl_private_inf* pri_inf, int argc, char** argv) +{ + + FMB_FUNC(TRUE); + if (argc != 2) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + if(!StopLogFile()){ + FmbErrPrintUsr("File close error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_PARAM_ERROR; + } + + FMB_FUNC(FALSE); + return OK; + +} + +int gopstart_command(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + + FMB_FUNC(TRUE); + if (argc != 3) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + pri_inf_p->cmd_str.internal_info.type = 0x00000002; + + if (DrvIoctlCmd(pri_inf_p->fd, FMB_API_GET_INTERNAL_DATA, &pri_inf_p->cmd_str.internal_info) != OK) { + return NG_ERR_IOCTL; + } + + internal_info_data = pri_inf_p->cmd_str.internal_info.data; + pri_inf_p->cmd_str.internal_info.type = 0x00000002; + pri_inf_p->cmd_str.internal_info.data = pri_inf_p->cmd_str.internal_info.data & 0x0000000E; + + if (DrvIoctlCmd(pri_inf_p->fd, FMB_API_SET_INTERNAL_DATA, &pri_inf_p->cmd_str.internal_info) != OK) { + return NG_ERR_IOCTL; + } + + + if(!StartGopFile(argv[2],"w")){ + FmbErrPrintUsr("File open error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_PARAM_ERROR; + } + + FMB_FUNC(FALSE); + return OK; + +} + +int gopstop_command(struct ioctl_private_inf* pri_inf_p, int argc, char** argv) +{ + + FMB_FUNC(TRUE); + if (argc != 2) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + pri_inf_p->cmd_str.internal_info.type = 0x00000002; + pri_inf_p->cmd_str.internal_info.data = internal_info_data; + + if (DrvIoctlCmd(pri_inf_p->fd, FMB_API_SET_INTERNAL_DATA, &pri_inf_p->cmd_str.internal_info) != OK) { + return NG_ERR_IOCTL; + } + + if(!StopGopFile()){ + FmbErrPrintUsr("File close error",__FILE__, __LINE__); + FMB_FUNC(FALSE); + return NG_PARAM_ERROR; + } + + FMB_FUNC(FALSE); + return OK; + +} + +int boot_command(struct ioctl_private_inf* pri_inf, int argc, char** argv) +{ + char* firmPath; + enum SceResultEnum sceResult; + HANDLE hScet; + + FMB_FUNC(TRUE); + if (argc != 3) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + firmPath = argv[2]; + hScet = gp_FmbComProperty->hEmptyScet; + sceResult = DrvBootUp(hScet, firmPath, 0, 0); + if( sceResult != SceEnmResultSyncEnd){ + fprintOut(stdout,"Error:Failed in the firm boot.\n"); + return 0; + } + + FMB_FUNC(FALSE); + return OK; + +} + +int help_command(struct ioctl_private_inf* pri_inf, int argc, char** argv) +{ + + FMB_FUNC(TRUE); + if (argc != 2) { + FMB_FUNC(FALSE); + return NG_USAGE; + } + + FmbUsageMainPrint(); + + FMB_FUNC(FALSE); + return OK; + +} diff --git a/fmb_player_apl/src/cmd/FmbCmdTbl.c b/fmb_player_apl/src/cmd/FmbCmdTbl.c new file mode 100644 index 0000000..6a4ec9c --- /dev/null +++ b/fmb_player_apl/src/cmd/FmbCmdTbl.c @@ -0,0 +1,58 @@ +/** +* @brief function jump table for control API function of the MB86 Linux driver +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "CmdUtil.h" + +const struct jump_head_table g_internal_jump_table[] = { + { "gparam", get_field_param , FMB_API_GET_PARAM }, + { "sparam", set_field_param , FMB_API_SET_PARAM }, + { "scmd", send_cmd_sys , FMB_API_SEND_SYS_CMD}, + { "svparam",set_video_param , 0}, + { "vcmd", send_cmd_video , FMB_API_SEND_VIDEO_CMD}, + { "saparam",set_audio_param , 0}, + { "acmd", send_cmd_audio , FMB_API_SEND_AUDIO_CMD}, + { "sack", get_sys_cmd_ack , FMB_API_GET_SYS_CMD_ACK}, + { "rcbuf", reset_cmd_info , FMB_API_RESET_CMD_INFO}, + { "smsg", get_msg_sys , FMB_API_GET_SYS_MSG}, + { "vmsg", get_msg_video , FMB_API_GET_VIDEO_MSG}, + { "amsg", get_msg_audio , FMB_API_GET_AUDIO_MSG}, + { "gfact", get_factor , FMB_API_GET_FACTOR}, + { "rfact", reset_factor , FMB_API_RESET_FACTOR}, + { "async", get_async_info , FMB_API_GET_ASYNC_INFO}, + { "glsi", get_lsi_reg , FMB_API_GET_LSI_REG}, + { "slsi", set_lsi_reg , FMB_API_SET_LSI_REG}, + { "dlsi", dump_lsi_reg , 0}, + { "gpci", get_pci_reg , FMB_API_GET_PCI_REG }, + { "spci", set_pci_reg , FMB_API_SET_PCI_REG}, + { "gdata", get_drv_internal_info , FMB_API_GET_INTERNAL_DATA}, + { "sdata", set_drv_internal_info , FMB_API_SET_INTERNAL_DATA}, + { "ver", get_version_info , FMB_API_GET_VERSION}, + { "strm", strm_command , 0}, + { "sleep", sleep_command , 0}, + { "logstr", logstart_command , 0}, + { "logstp", logstop_command , 0}, + { "gopstr", gopstart_command , 0}, + { "gopstp", gopstop_command , 0}, + { "boot", boot_command , 0}, + { "?", help_command , 0}, + { " " , NULL , 0}, + { " " , NULL , 0}, + { " " , NULL , 0}, + { " " , NULL , 0}, + { " " , NULL , 0}, + { " " , NULL , 0}, + { " " , NULL , 0}, + { " " , NULL , 0} +}; diff --git a/fmb_player_apl/src/com/FmbComBitrate.c b/fmb_player_apl/src/com/FmbComBitrate.c new file mode 100644 index 0000000..aa01895 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComBitrate.c @@ -0,0 +1,451 @@ +/** +* @brief The scenario that sets the video bitrate is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + + +/* + Private section +*/ + +///Detailed parameter of bit rate. +struct DetailParamType{ + float frameRate; + unsigned int numFrameInGOP; + unsigned int isUseNullInterGOP; + + unsigned int numofSamplesFrame; + unsigned int sizeofPesHeader; + unsigned int samplingFrequency; + + unsigned int patCycle; + unsigned int pmtCycle; + unsigned int sitCycle; + unsigned int pcrCycle; +}; + +///Parameter for temporary calculation. +struct TempCalcDataType{ + unsigned int aauSize; + unsigned int apesSize; + unsigned int numofTsPacketInApes; + float audioEffectBitrate; + unsigned int vpesHeaderBitrate; + unsigned int vpesBitrate; + unsigned int vpesTailAdaptationFld; + unsigned int videoEffectBitrate; + + unsigned int nullInterGopBitrate; + + unsigned int patEffectBitrate; + unsigned int pmtEffectBitrate; + unsigned int sitEffectBitrate; + unsigned int pcrEffectBitrate; +}; + +//The detail-param is set. +static void setDetailParam( enum FMBVideoFrameEnum frm, + struct DetailParamType *detailParam, + enum FMBAudioFormatEnum audioFmt); + +//Necessary-system-bitrate is calculated. +static int calcNecessarySystemBitrate( int vBitrate, + const struct DetailParamType *detailParam, + enum FMBAudioFormatEnum audioFmt); + +//Necessary-video-bitrate is calculated. +static int calcNecessaryVideoBitrate( long sBitrate, + const struct DetailParamType *detailParam); + +/* + Public Section +*/ + +/** +* @brief Calculate the bitrate-parameter in the MB86. +* @param[in] p_VidoBitrateProp +* @param[in] videoFrm Video frame rate control +* @param[in] audioFmt Audio format +* @return TRUE Normal +* @return FALSE Overflow +* @note None +* @attention None +*/ +BOOL FmbCalcVideoBitrateParam(struct FMBVideoBitrateProp *p_VidoBitrateProp, + enum FMBVideoFrameEnum videoFrm, + enum FMBAudioFormatEnum audioFmt) +{ + struct DetailParamType detailParam; + struct FMBVideoBitrateParam *videoBitrateParam; + + FMB_FUNC(TRUE); + + setDetailParam(videoFrm, &detailParam, audioFmt); + + videoBitrateParam = &p_VidoBitrateProp->videoBitrateParam; + + videoBitrateParam->isValid = TRUE; + + switch(p_VidoBitrateProp->bitrateCalckind){ + case FMBEnmBitrateCalcVideobase: + switch(p_VidoBitrateProp->videoRateCtl){ + case FMBEnmVideoRateCtlCbr: + videoBitrateParam->vRateMode = 0; + videoBitrateParam->vBitrate = p_VidoBitrateProp->videoBitrateCbr; + videoBitrateParam->vAveBitrate = 0; + videoBitrateParam->vMinBitrate = 0; + videoBitrateParam->vMaxBitrate = (unsigned short)videoBitrateParam->vBitrate; + p_VidoBitrateProp->systemMuxRate = calcNecessarySystemBitrate(videoBitrateParam->vBitrate, &detailParam, audioFmt); + videoBitrateParam->muxRate = p_VidoBitrateProp->systemMuxRate + 500; + break; + case FMBEnmVideoRateCtlVbr: + videoBitrateParam->vRateMode = 1; + videoBitrateParam->vBitrate = p_VidoBitrateProp->videoBitrateVbrPeak; + videoBitrateParam->vAveBitrate = (unsigned short)p_VidoBitrateProp->videoBitrateVbrAverage; + videoBitrateParam->vMinBitrate = 0; + videoBitrateParam->vMaxBitrate = (unsigned short)videoBitrateParam->vBitrate; + p_VidoBitrateProp->systemMuxRate = calcNecessarySystemBitrate(videoBitrateParam->vBitrate, &detailParam, audioFmt); + videoBitrateParam->muxRate = p_VidoBitrateProp->systemMuxRate + 1500; + break; + default: + ASSERT_USR(FALSE, "Invalid rate control."); + break; + } + break; + case FMBEnmBitrateCalcSystembase: + switch(p_VidoBitrateProp->videoRateCtl){ + case FMBEnmVideoRateCtlCbr: + videoBitrateParam->vRateMode = 0; + videoBitrateParam->vAveBitrate = 0; + videoBitrateParam->vMinBitrate = 0; + videoBitrateParam->muxRate = p_VidoBitrateProp->systemMuxRate; + videoBitrateParam->vBitrate = calcNecessaryVideoBitrate(videoBitrateParam->muxRate, &detailParam); + videoBitrateParam->muxRate += 500; + videoBitrateParam->vMaxBitrate = (unsigned short)videoBitrateParam->vBitrate; + p_VidoBitrateProp->videoBitrateCbr = videoBitrateParam->vBitrate; + break; + case FMBEnmVideoRateCtlVbr: + videoBitrateParam->vRateMode = 1; + videoBitrateParam->vMinBitrate = 0; + videoBitrateParam->muxRate = p_VidoBitrateProp->systemMuxRate; + videoBitrateParam->vBitrate = calcNecessaryVideoBitrate(videoBitrateParam->muxRate, &detailParam); + videoBitrateParam->muxRate += 1500; + videoBitrateParam->vMaxBitrate = (unsigned short)videoBitrateParam->vBitrate; + videoBitrateParam->vAveBitrate = (unsigned short)(videoBitrateParam->vMaxBitrate / 1.5); + p_VidoBitrateProp->videoBitrateVbrPeak = videoBitrateParam->vBitrate; + p_VidoBitrateProp->videoBitrateVbrAverage = videoBitrateParam->vAveBitrate; + break; + default: + ASSERT_USR(FALSE, "Invalid rate control."); + break; + } + break; + default: + ASSERT_USR(FALSE, "Invalid bitrateCalckind."); + break; + } + + + if((p_VidoBitrateProp->videoBitrateParam.muxRate & 0xFFFF0000) != 0){ + videoBitrateParam->isValid = FALSE; + } + if((p_VidoBitrateProp->videoBitrateParam.vBitrate & 0xFFFF0000) != 0){ + videoBitrateParam->isValid = FALSE; + } + + FMB_FUNC(FALSE); + return videoBitrateParam->isValid; +} + +/* + Private Section +*/ + +/** +* @brief Set the detail-param. +* @param[in] fmt Video format. +* @param[out] detailParam Detail parameter. +* @param[in] audioFmt Audio Format +* @return None +* @note None +* @attention None +*/ +static void setDetailParam( enum FMBVideoFrameEnum frm, + struct DetailParamType *detailParam, + enum FMBAudioFormatEnum audioFmt) +{ + FMB_FUNC(TRUE); + switch(frm){ + case FMBEnmVideoFrm_60i: + detailParam->frameRate = (float)30; + break; + case FMBEnmVideoFrm_5994i: + detailParam->frameRate = (float)(30000.0 / 1001); + break; + case FMBEnmVideoFrm_50i: + detailParam->frameRate = (float)25; + break; + case FMBEnmVideoFrm_60p: + detailParam->frameRate = (float)60; + break; + case FMBEnmVideoFrm_5994p: + detailParam->frameRate = (float)(60000.0 / 1001); + break; + case FMBEnmVideoFrm_50p: + detailParam->frameRate = (float)50; + break; + default: + ASSERT_USR(FALSE, "Invalid VideoFormat."); + } + + switch(frm){ + case FMBEnmVideoFrm_60p: + case FMBEnmVideoFrm_60i: + case FMBEnmVideoFrm_5994p: + case FMBEnmVideoFrm_5994i: + detailParam->numFrameInGOP = 15; + break; + case FMBEnmVideoFrm_50p: + case FMBEnmVideoFrm_50i: + detailParam->numFrameInGOP = 12; + break; + default: + ASSERT_USR(FALSE, "Invalid VideoFormat."); + } + + detailParam->isUseNullInterGOP = 1; + + switch(audioFmt){ + case FMBEnmAudioFmtMpeg1l2: + detailParam->numofSamplesFrame = 1152; + detailParam->sizeofPesHeader = 14; + break; + case FMBEnmAudioFmtAc3: + detailParam->numofSamplesFrame = 1536; + detailParam->sizeofPesHeader = 17; + break; + case FMBEnmAudioFmtLpcm: + detailParam->numofSamplesFrame = 240; + detailParam->sizeofPesHeader = 18; + break; + case FMBEnmAudioFmtAac: + detailParam->numofSamplesFrame = 1024; + detailParam->sizeofPesHeader = 14; + break; + default: + ASSERT_USR(FALSE, "Invalid AudioFormat."); + } + detailParam->samplingFrequency = 48000; + + detailParam->patCycle = 90; + detailParam->pmtCycle = 90; + detailParam->sitCycle = 900; + detailParam->pcrCycle = 30; + + FMB_FUNC(FALSE); +} + +/** +* @brief Calculated the necessary-system-bitrate. +* @param[in] vBitrate Video bitrate. +* @param[in] detailParam Audio Format +* @param[in] audioFmt Detail parameter. +* @return Necessary system bitrate. +* @note None +* @attention None +*/ +static int calcNecessarySystemBitrate( int vBitrate, + const struct DetailParamType *detailParam, + enum FMBAudioFormatEnum audioFmt) +{ + struct TempCalcDataType temp; + + int audioBitrate=0; + int necessarySystemBitrate; + + switch(audioFmt){ + case FMBEnmAudioFmtMpeg1l2: + case FMBEnmAudioFmtAc3: + case FMBEnmAudioFmtLpcm: + audioBitrate = gp_FmbProperty[gp_FmbComProperty->setMode].audioBitrateCbr[audioFmt]; + break; + case FMBEnmAudioFmtAac: + audioBitrate = gp_FmbProperty[gp_FmbComProperty->setMode].audioBitrateVbrPeak; + break; + default: + ASSERT_USR(FALSE, "Invalid AudioFormat."); + } + + FMB_FUNC(TRUE); + + temp.aauSize = RoundUpDouble( audioBitrate * 1000.0 * detailParam->numofSamplesFrame / detailParam->samplingFrequency / 8); + temp.apesSize = temp.aauSize + detailParam->sizeofPesHeader; + temp.numofTsPacketInApes = RoundUpDouble(temp.apesSize / 184.0); + temp.audioEffectBitrate = 188 * 8 * temp.numofTsPacketInApes / ((float)detailParam->numofSamplesFrame / detailParam->samplingFrequency); + + temp.vpesHeaderBitrate = RoundUpDouble(19 * 8 * detailParam->frameRate); + temp.vpesBitrate = vBitrate * 1000 + temp.vpesHeaderBitrate; + temp.vpesTailAdaptationFld = RoundUpDouble(183.0 * 8 * detailParam->frameRate); + temp.videoEffectBitrate = RoundUpDouble((temp.vpesBitrate + temp.vpesTailAdaptationFld)*188.0/184); + + temp.nullInterGopBitrate = RoundUpDouble(188.0 * 8 * 32 / (detailParam->numFrameInGOP / detailParam->frameRate)) * detailParam->isUseNullInterGOP; + + temp.patEffectBitrate = RoundUpDouble(188*8/(detailParam->patCycle / 1000.0)); + temp.pmtEffectBitrate = RoundUpDouble(188*8/(detailParam->pmtCycle / 1000.0)); + temp.sitEffectBitrate = RoundUpDouble(188*8/(detailParam->sitCycle / 1000.0)); + temp.pcrEffectBitrate = RoundUpDouble(188*8/(detailParam->pcrCycle / 1000.0)); + + necessarySystemBitrate = RoundUpDouble( + ( + temp.audioEffectBitrate + + temp.videoEffectBitrate + + temp.nullInterGopBitrate + + temp.patEffectBitrate + + temp.pmtEffectBitrate + + temp.sitEffectBitrate + + temp.pcrEffectBitrate + ) + / 1000.0 + ); + + LogFmb("aauSize\t%d\t" + "apesSize\t%d\t" + "numofTsPacketInApes\t%d\t" + "audioEffectBitrate\t%f\t" + "vpesHeaderBitrate\t%d\t" + "vpesBitrate\t%d\t" + "vpesTailAdaptationFld\t%d\t" + "videoEffectBitrate\t%d\t" + "nullInterGopBitrate\t%d\t" + "patEffectBitrate\t%d\t" + "pmtEffectBitrate\t%d\t" + "sitEffectBitrate\t%d\t" + "pcrEffectBitrate\t%d", + temp.aauSize, + temp.apesSize, + temp.numofTsPacketInApes, + temp.audioEffectBitrate, + temp.vpesHeaderBitrate, + temp.vpesBitrate, + temp.vpesTailAdaptationFld, + temp.videoEffectBitrate, + temp.nullInterGopBitrate, + temp.patEffectBitrate, + temp.pmtEffectBitrate, + temp.sitEffectBitrate, + temp.pcrEffectBitrate); + + FMB_FUNC(FALSE); + return necessarySystemBitrate; +} +/** +* @brief Calculate the necessary-video-bitrate. +* @param[in] sBitrate System bitrate. +* @param[in] detailParam Detail parameter. +* @return Necessary video bitrate. +* @note None +* @attention None +*/ +static int calcNecessaryVideoBitrate( long sBitrate, + const struct DetailParamType *detailParam) +{ + struct TempCalcDataType temp; + + int audioBitrate=0; + int tmpCalcrate; + int necessaryVideoBitrate; + enum FMBAudioFormatEnum audioFmt; + + FMB_FUNC(TRUE); + + audioFmt = gp_FmbProperty[gp_FmbComProperty->setMode].audioFmt; + switch(audioFmt){ + case FMBEnmAudioFmtMpeg1l2: + case FMBEnmAudioFmtAc3: + case FMBEnmAudioFmtLpcm: + audioBitrate = gp_FmbProperty[gp_FmbComProperty->setMode].audioBitrateCbr[audioFmt]; + break; + case FMBEnmAudioFmtAac: + audioBitrate = gp_FmbProperty[gp_FmbComProperty->setMode].audioBitrateVbrPeak; + break; + default: + ASSERT_USR(FALSE, "Invalid AudioFormat."); + } + + + temp.aauSize = RoundUpDouble( audioBitrate * 1000.0 * detailParam->numofSamplesFrame / detailParam->samplingFrequency / 8); + temp.apesSize = temp.aauSize + detailParam->sizeofPesHeader; + temp.numofTsPacketInApes = RoundUpDouble(temp.apesSize / 184.0); + temp.audioEffectBitrate = 188 * 8 * temp.numofTsPacketInApes / ((float)detailParam->numofSamplesFrame / detailParam->samplingFrequency); + + temp.vpesHeaderBitrate = RoundUpDouble(19 * 8 * detailParam->frameRate); + //temp.vpesBitrate = sBitrate * 1000 + temp.vpesHeaderBitrate; + temp.vpesTailAdaptationFld = RoundUpDouble(183.0 * 8 * detailParam->frameRate); + //temp.videoEffectBitrate = RoundUpDouble((temp.vpesBitrate + temp.vpesTailAdaptationFld)*188.0/184); + + temp.nullInterGopBitrate = RoundUpDouble(188.0 * 8 * 32 / (detailParam->numFrameInGOP / detailParam->frameRate)) * detailParam->isUseNullInterGOP; + + temp.patEffectBitrate = RoundUpDouble(188*8/(detailParam->patCycle / 1000.0)); + temp.pmtEffectBitrate = RoundUpDouble(188*8/(detailParam->pmtCycle / 1000.0)); + temp.sitEffectBitrate = RoundUpDouble(188*8/(detailParam->sitCycle / 1000.0)); + temp.pcrEffectBitrate = RoundUpDouble(188*8/(detailParam->pcrCycle / 1000.0)); + + + tmpCalcrate = (int)(( (sBitrate * 1000 + - temp.audioEffectBitrate + - temp.nullInterGopBitrate + - temp.patEffectBitrate + - temp.pmtEffectBitrate + - temp.sitEffectBitrate + - temp.pcrEffectBitrate) * 184 + ) / 188.0) ; + + necessaryVideoBitrate = (int) ((tmpCalcrate + - temp.vpesHeaderBitrate + - temp.vpesTailAdaptationFld ) / 1000.0); + + temp.vpesBitrate = necessaryVideoBitrate * 1000 + temp.vpesHeaderBitrate; + temp.videoEffectBitrate = RoundUpDouble((temp.vpesBitrate + temp.vpesTailAdaptationFld)*188.0/184); + + LogFmb("aauSize\t%d\t" + "apesSize\t%d\t" + "numofTsPacketInApes\t%d\t" + "audioEffectBitrate\t%f\t" + "vpesHeaderBitrate\t%d\t" + "vpesBitrate\t%d\t" + "vpesTailAdaptationFld\t%d\t" + "videoEffectBitrate\t%d\t" + "nullInterGopBitrate\t%d\t" + "patEffectBitrate\t%d\t" + "pmtEffectBitrate\t%d\t" + "sitEffectBitrate\t%d\t" + "pcrEffectBitrate\t%d", + temp.aauSize, + temp.apesSize, + temp.numofTsPacketInApes, + temp.audioEffectBitrate, + temp.vpesHeaderBitrate, + temp.vpesBitrate, + temp.vpesTailAdaptationFld, + temp.videoEffectBitrate, + temp.nullInterGopBitrate, + temp.patEffectBitrate, + temp.pmtEffectBitrate, + temp.sitEffectBitrate, + temp.pcrEffectBitrate); + + FMB_FUNC(FALSE); + return necessaryVideoBitrate; +} diff --git a/fmb_player_apl/src/com/FmbComCore.c b/fmb_player_apl/src/com/FmbComCore.c new file mode 100644 index 0000000..899a94c --- /dev/null +++ b/fmb_player_apl/src/com/FmbComCore.c @@ -0,0 +1,312 @@ +/** +* @brief The function of command/message layer of MB86/51 is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + + +#include <string.h> +#include <sys/ioctl.h> +#include "FmbCmn.h" + +/** +* @brief Set parameter for the MB86 Linux driver::ioctl(FMB_API_SET_PARAM) +* @param[in] sceHandle Scenario handle +* @param[in] id Parameter identification +* @param[in] value Written value +* @param[in] dummy +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreParamSet(HANDLE sceHandle, unsigned long id, unsigned long value, unsigned long dummy) +{ + unsigned long prm_id; + unsigned short prm_data; + struct fmb_param_info param_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + prm_id = id; + prm_data = (unsigned short)value; + + memset(¶m_info, 0, sizeof(struct fmb_param_info)); + + param_info.prm_id = &prm_id; + param_info.prm_data = &prm_data; + + param_info.prm_num = 1; + + LogFmb("[param_set]\tid\t0x%08x\tvalue\t0x%08x", + *param_info.prm_id, *param_info.prm_data); + + DrvIoctl(deviceFd, FMB_API_SET_PARAM, ¶m_info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Send System Command for the MB86 Linux driver::ioctl(FMB_API_SEND_SYS_CMD) +* @param[in] sceHandle Scenario handle +* @param[in] cmd Written command. +* @param[in] subCmd Written sub command. +* @param[in] body Written body. +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreCmdSendSys(HANDLE sceHandle, unsigned long cmd, unsigned long subCmd, unsigned long body) +{ + struct fmb_cmd_sys_info cmd_sys_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(&cmd_sys_info, 0, sizeof(cmd_sys_info)); + + cmd_sys_info.sync = FMB_MODE_ASYNC; + + cmd_sys_info.id = (unsigned short)cmd; + cmd_sys_info.sub_id = (unsigned short)subCmd; + cmd_sys_info.body = (unsigned short)body; + + LogFmbCmd("[cmd_send_sys]\tcmd\t0x%04x\tsub_cmd\t0x%04x\tbody\t0x%04x", + cmd_sys_info.id, cmd_sys_info.sub_id, cmd_sys_info.body); + + DrvIoctl(deviceFd, FMB_API_SEND_SYS_CMD, &cmd_sys_info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Send Video Command for the MB86 Linux driver::ioctl(FMB_API_SEND_SYS_CMD) +* @param[in] sceHandle Scenario handle +* @param[in] mode Written mode +* @param[in] subMode Written sub mode +* @param[in] vDispTime Written vDisptime +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreCmdSendVideo(HANDLE sceHandle, unsigned long mode, unsigned long subMode, unsigned long vDispTime) +{ + unsigned short databuf[5]; + unsigned long idbuf[5]; + struct fmb_cmd_video_info cmd_video_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(&cmd_video_info, 0, sizeof(cmd_video_info)); + + idbuf[0] = 0x00060001; /* MODE */ + databuf[0] = (unsigned short)mode; + idbuf[1] = 0x00060004; /* TFRFF */ + databuf[1] = 0x02; + idbuf[2] = 0x00060006; /* VDISPTIME */ + if(subMode == 1){ //If slow, + databuf[2] = (unsigned short)vDispTime; + } + else{ //else + databuf[2] = 0x0A; + } + idbuf[3] = 0x00060008; /* SUB_MODE */ + databuf[3] = (unsigned short)subMode; + idbuf[4] = 0x00060009; /* VUDATA_LENGTH */ + databuf[4] = 0; + + cmd_video_info.cprm_num = 5; + + cmd_video_info.cprm_id = idbuf; + cmd_video_info.cprm_data = databuf; + + + LogFmbCmd("[cmd_send_video]\tmode\t0x%04x\tsub_mode\t0x%04x\tvDispTime\t0x%04x", mode, subMode, databuf[2]); + DrvIoctl(deviceFd, FMB_API_SEND_VIDEO_CMD, &cmd_video_info); + + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} + +/** +* @brief Send audio Command for the MB86 Linux driver::ioctl(FMB_API_SEND_AUDIO_CMD) +* @param[in] sceHandle Scenario handle +* @param[in] mute Written mute +* @param[in] ch Written ch +* @param[in] dummy +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreCmdSendAudio(HANDLE sceHandle, unsigned long mute, unsigned long ch, unsigned long dummy) +{ + unsigned short databuf[7]; + unsigned long idbuf[7]; + struct fmb_cmd_audio_info cmd_audio_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(&cmd_audio_info, 0, sizeof(cmd_audio_info)); + + idbuf[0] = 0x00070001; /* A_MUTE */ + databuf[0] = (unsigned short)mute; + + idbuf[1] = 0x00070002; /* A_CH */ + databuf[1] = (unsigned short)ch; + + idbuf[2] = 0x00070003; /* LCH_SCALE */ + databuf[2] = 0x7FFF; + + idbuf[3] = 0x00070004; /* RCH_SCALE */ + databuf[3] = 0x7FFF; + + idbuf[4] = 0x00070005; /* D_MP2_COMPRESSION */ + databuf[4] = 0x02; + + idbuf[5] = 0x00070006; /* D_MP2_DYNRNG_BOOST */ + databuf[5] = 0x80; + + idbuf[6] = 0x00070007; /* D_MP2_DYNRNG_CUT */ + databuf[6] = 0x80; + + cmd_audio_info.cprm_num = 7; + + cmd_audio_info.cprm_id = idbuf; + cmd_audio_info.cprm_data = databuf; + + LogFmbCmd("[cmd_send_audio]\ta_mode\t0x%04x\ta_ch\t0x%04x", mute, ch); + DrvIoctl(deviceFd, FMB_API_SEND_AUDIO_CMD, &cmd_audio_info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} +/** +* @brief Set parameter for the MB86 Linux driver::ioctl(FMB_API_SET_PARAM) +* @param[in] sceHandle Scenario handle +* @param[in] id Parameter identification +* @param[in] valuep Written value (pointer) +* @param[in] dummy +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreParamSetPtr(HANDLE sceHandle, unsigned long id, unsigned long valuep, unsigned long dummy) +{ + unsigned long prm_id; + unsigned short prm_data; + struct fmb_param_info param_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + prm_id = id; + prm_data = (unsigned short)*(unsigned long*)valuep; + + memset(¶m_info, 0, sizeof(struct fmb_param_info)); + + param_info.prm_id = &prm_id; + param_info.prm_data = &prm_data; + + param_info.prm_num = 1; + + LogFmb("[param_set]\tid\t0x%08x\tvalue\t0x%08x", + *param_info.prm_id, *param_info.prm_data); + + DrvIoctl(deviceFd, FMB_API_SET_PARAM, ¶m_info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Send System Command for the MB86 Linux driver::ioctl(FMB_API_SEND_SYS_CMD) +* @param[in] sceHandle Scenario handle +* @param[in] cmd Written command. +* @param[in] subCmd Written sub command. +* @param[in] bodyp Written body. (pointer) +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreCmdSendSysPtr(HANDLE sceHandle, unsigned long cmd, unsigned long subCmd, unsigned long bodyp) +{ + struct fmb_cmd_sys_info cmd_sys_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(&cmd_sys_info, 0, sizeof(cmd_sys_info)); + + cmd_sys_info.sync = FMB_MODE_ASYNC; + + cmd_sys_info.id = (unsigned short)cmd; + cmd_sys_info.sub_id = (unsigned short)subCmd; + cmd_sys_info.body = (unsigned short)*(unsigned long*)bodyp; + + LogFmbCmd("[cmd_send_sys]\tcmd\t0x%04x\tsub_cmd\t0x%04x\tbody\t0x%04x", + cmd_sys_info.id, cmd_sys_info.sub_id, cmd_sys_info.body); + + DrvIoctl(deviceFd, FMB_API_SEND_SYS_CMD, &cmd_sys_info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Set parameter for the MB86 Linux driver::ioctl(FMB_API_SET_PARAM) +* @param[in] sceHandle Scenario handle +* @param[in] id Parameter identification +* @param[in] valuepp Written value (a pointer to a pointer to a short) +* @param[in] dummy +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum CoreParamSetPtrPtr(HANDLE sceHandle, unsigned long id, unsigned long valuepp, unsigned long dummy) +{ + unsigned long prm_id; + unsigned short prm_data; + struct fmb_param_info param_info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + prm_id = id; + prm_data = (unsigned short)**(unsigned long**)valuepp; + + memset(¶m_info, 0, sizeof(struct fmb_param_info)); + + param_info.prm_id = &prm_id; + param_info.prm_data = &prm_data; + + param_info.prm_num = 1; + + LogFmb("[param_set]\tid\t0x%08x\tvalue\t0x%08x", + *param_info.prm_id, *param_info.prm_data); + + DrvIoctl(deviceFd, FMB_API_SET_PARAM, ¶m_info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} diff --git a/fmb_player_apl/src/com/FmbComDevice.c b/fmb_player_apl/src/com/FmbComDevice.c new file mode 100644 index 0000000..c2f5c2e --- /dev/null +++ b/fmb_player_apl/src/com/FmbComDevice.c @@ -0,0 +1,602 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright ICP Electronics (C) 2010 * + *===============================================*/ +/*-----------------------------------------------* + $Author: Kenneth $ + $Date: $ + $Revision: $ + *-----------------------------------------------*/ +/* + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include "FmbCmn.h" + + +static int FmbSetFirmPath(struct FMBInfo *p_Info); + + +int FmbInitInfo(void) +{ +#ifdef USE_MMUX // [ USE_MMUX + int i; +#endif // USE_MMUX ] + + FMB_FUNC(TRUE); + + gp_FmbInfo->isDeviceSelecting = FALSE; + gp_FmbInfo->currentDeviceNum = FMBEnmDevice_0; + gp_FmbInfo->countCodecChip = 0; + gp_FmbInfo->totalCodecChip = MmuxCalcCodecChipTotal(); + ASSERT_USR(gp_FmbInfo->totalCodecChip != 0, "Device not find!"); + memset(gp_FmbInfo->pt_deviceInfo_A, 0, sizeof(gp_FmbInfo->pt_deviceInfo_A)); + +#ifdef USE_MMUX // [ USE_MMUX + gp_FmbInfo->totalBorad = MmuxCalcBoardTotal(); + ASSERT_USR(0 < gp_FmbInfo->totalBorad \ + && gp_FmbInfo->totalBorad <= MMUXDeviceMax, + "Error:?"); + for (i=0; i<gp_FmbInfo->totalBorad; i++) { + struct MmuxInfo *p_MmuxInfo = NULL; + + p_MmuxInfo = MmuxInit(i); + ASSERT_USR(p_MmuxInfo != NULL, "Failed: Mmux init!"); + gp_FmbInfo->hdMmux_A[i] = p_MmuxInfo; + } + FmbSetCurMmuxDevNum(MMUXDevice_0); +#else // USE_MMUX ] [ !USE_MMUX + gp_FmbInfo->totalBorad = 0; +#endif // !USE_MMUX ] + + FmbSetFirmPath(gp_FmbInfo); + + FMB_FUNC(FALSE); + + return TRUE; +} + +void FmbReleaseInfo(void) +{ +#ifdef USE_MMUX // [ USE_MMUX + int i; +#endif // USE_MMUX ] + + FMB_FUNC(TRUE); + +#ifdef USE_MMUX // [ USE_MMUX + for (i=0; i<gp_FmbInfo->totalBorad; i++) { + if (gp_FmbInfo->hdMmux_A[i]) { + MmuxRelease(gp_FmbInfo->hdMmux_A[i]); + } + } +#endif // USE_MMUX ] + + FMB_FUNC(FALSE); +} + +int FmbCreatDevInfoAll(void) +{ + char devicePath[FMB_DEVNAME_MAX_CHAR]; + char cDevcienumA[3]; + enum FMBDeviceNumEnum deviceNum; + int result; + + + FMB_FUNC(TRUE); + + for (deviceNum=FMBEnmDevice_0; deviceNum<gp_FmbInfo->totalCodecChip; deviceNum++) { + int lenDevicePath; + + sprintf(cDevcienumA, "%d", deviceNum); + + lenDevicePath = strlen(DEFAULT_FMB_PATH); + lenDevicePath += strlen(cDevcienumA); + ASSERT_USR(lenDevicePath < FMB_DEVNAME_MAX_CHAR , "?"); + + strcpy(devicePath, DEFAULT_FMB_PATH); + strcat(devicePath, cDevcienumA); + + result = FmbCreatDevInfo(devicePath); + if (result < 0) { + FMB_FUNC(FALSE); + return FALSE; + } + } + FmbEnableDevUseAll(); + + FMB_FUNC(FALSE); + + return TRUE; +} + +void FmbDellDevInfoAll(void) +{ + enum FMBDeviceNumEnum deviceNum; + + FMB_FUNC(TRUE); + + + for (deviceNum=FMBEnmDevice_0; deviceNum<FMBEnmDeviceMax; deviceNum++) { + FmbDelDevInfo(deviceNum); + } + + FMB_FUNC(FALSE); +} + +int FmbCreatDevInfo(char *p_devicePath) +{ + struct FMBDeviceInfo *p_DevInfo; + enum FMBDeviceNumEnum deviceNum; + + + FMB_FUNC(TRUE); + + ASSERT_USR(p_devicePath != NULL, "p_devicePath == NULL"); + ASSERT_USR(gp_FmbInfo->countCodecChip <= FMBEnmDeviceMax , "?"); + + p_DevInfo = malloc(sizeof(struct FMBDeviceInfo)); + if (p_DevInfo == NULL) { + FMB_FUNC(FALSE); + return -1; + } + + deviceNum = gp_FmbInfo->countCodecChip; + gp_FmbInfo->pt_deviceInfo_A[deviceNum] = p_DevInfo; + FmbSetCurDeviceNum(deviceNum); + + strcpy(gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_ComProperty.devicePath, p_devicePath); + + FmbInit(p_DevInfo, deviceNum); + + gp_FmbInfo->countCodecChip++; + + FMB_FUNC(FALSE); + + return deviceNum; +} + +void FmbDelDevInfo(enum FMBDeviceNumEnum deviceNum) +{ + struct FMBDeviceInfo *pt_deviceInfo_A; + + FMB_FUNC(TRUE); + + pt_deviceInfo_A = gp_FmbInfo->pt_deviceInfo_A[deviceNum]; + + if (pt_deviceInfo_A != NULL) { + FmbTerminate(pt_deviceInfo_A); + + free(pt_deviceInfo_A); + gp_FmbInfo->pt_deviceInfo_A[deviceNum] = NULL; + gp_FmbInfo->countCodecChip--; + } + + FMB_FUNC(FALSE); +} + + + +/** +* @brief . +* @param[in] None +* @return . +* @note None +* @attention None +*/ +inline int FmbGetDeviceTotal(void) +{ + return gp_FmbInfo->totalCodecChip; +} + +inline int FmbGetBoardTotal(void) +{ + return gp_FmbInfo->totalBorad; +} + + +/** +* @brief . +* @param[in] None +* @return None +* @note None +* @attention None +*/ +inline void FmbEnableDeviceSel(void) +{ + gp_FmbInfo->isDeviceSelecting = TRUE; +} + +/** +* @brief . +* @param[in] None +* @return None +* @note None +* @attention None +*/ +inline void FmbDisableDeviceSel(void) +{ + gp_FmbInfo->isDeviceSelecting = FALSE; +} + +/** +* @brief . +* @param[in] None +* @return TRUE . +* @return FALSE . +* @note None +* @attention None +*/ +inline BOOL FmbIsNotDeviceSelecting(void) +{ + return !gp_FmbInfo->isDeviceSelecting; +} + + +/** +* @brief . +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbSetCurDeviceNum(enum FMBDeviceNumEnum deviceNum) +{ + + FMB_FUNC(TRUE); + + ASSERT_USR((FMBEnmDevice_0 <= deviceNum) && (deviceNum < FMBEnmDeviceMax), + "Invalid device numbers."); + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, + "gp_FmbInfo->pt_deviceInfo_A[deviceNum] == NULL"); + + gp_FmbInfo->currentDeviceNum = deviceNum; + + gp_FmbDevInfo = gp_FmbInfo->pt_deviceInfo_A[deviceNum]; + gp_FmbProperty = gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_Property_A; + gp_FmbComProperty = &gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_ComProperty; + + FMB_FUNC(FALSE); +} + +inline enum FMBDeviceNumEnum FmbGetCurDeviceNum(void) +{ + return gp_FmbInfo->currentDeviceNum; +} + +inline enum FMBDeviceNumEnum FmbGetCurDevNumOnBoard(void) +{ + enum FMBDeviceNumEnum currentDeviceNum; + int codecNumPerBorad; + + currentDeviceNum = gp_FmbInfo->currentDeviceNum; + codecNumPerBorad = gp_FmbInfo->totalCodecChip/gp_FmbInfo->totalBorad; + + return (currentDeviceNum%codecNumPerBorad); +} + + +struct FMBDeviceInfo *FmbGetCurDevInfo(void) +{ + struct FMBDeviceInfo *p_deviceInfo; + + FMB_FUNC(TRUE); + + p_deviceInfo = gp_FmbInfo->pt_deviceInfo_A[gp_FmbInfo->currentDeviceNum]; + + FMB_FUNC(FALSE); + + return p_deviceInfo; +} + +struct FMBDeviceInfo *FmbGetDevInfo(enum FMBDeviceNumEnum deviceNum) +{ + struct FMBDeviceInfo *p_deviceInfo; + + FMB_FUNC(TRUE); + + ASSERT_USR(deviceNum < FMBEnmDeviceMax, "Error: deviceNum?"); + + p_deviceInfo = gp_FmbInfo->pt_deviceInfo_A[deviceNum]; + + FMB_FUNC(FALSE); + + return p_deviceInfo; +} + +struct FMBProperty *FmbGetProperty(enum FMBDeviceNumEnum deviceNum) +{ + struct FMBProperty *p_Property; + + FMB_FUNC(TRUE); + + ASSERT_USR(deviceNum < FMBEnmDeviceMax, "Error: deviceNum?"); + + p_Property = gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_Property_A; + + FMB_FUNC(FALSE); + + return p_Property; +} + +struct FMBComProperty *FmbGetComProperty(enum FMBDeviceNumEnum deviceNum) +{ + struct FMBComProperty *p_ComProperty; + + FMB_FUNC(TRUE); + + ASSERT_USR(deviceNum < FMBEnmDeviceMax, "Error: deviceNum?"); + + p_ComProperty = &gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_ComProperty; + + FMB_FUNC(FALSE); + + return p_ComProperty; +} + + +int FmbGetRecvWtireHd(enum FMBDeviceNumEnum deviceNum) +{ + int hd = -1; + + FMB_FUNC(TRUE); + + ASSERT_USR(deviceNum < FMBEnmDeviceMax, "Error: deviceNum?"); + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, + "gp_FmbInfo->pt_deviceInfo_A[deviceNum] == NULL"); + + hd = gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_ComProperty.fdPipeWrite; + + FMB_FUNC(FALSE); + + return hd; +} + +int FmbGetRecvReadHd(enum FMBDeviceNumEnum deviceNum) +{ + int hd = -1; + + FMB_FUNC(TRUE); + + ASSERT_USR(deviceNum < FMBEnmDeviceMax, "Error: deviceNum?"); + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, + "gp_FmbInfo->pt_deviceInfo_A[deviceNum] == NULL"); + + hd = gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_ComProperty.fdPipeRead; + + FMB_FUNC(FALSE); + + return hd; +} + +int FmbGetDeviceHd(enum FMBDeviceNumEnum deviceNum) +{ + int hd = -1; + + FMB_FUNC(TRUE); + + ASSERT_USR(deviceNum < FMBEnmDeviceMax, "Error: deviceNum?"); + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, + "gp_FmbInfo->pt_deviceInfo_A[deviceNum] == NULL"); + + hd = gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_ComProperty.deviceFd; + + FMB_FUNC(FALSE); + + return hd; +} + +inline HANDLE FmbGetHandSceCurrent(void) +{ + return gp_FmbDevInfo->hSceCurrent; +} + +inline void FmbSetHandSceCurrent(HANDLE hSceCurrent) +{ + gp_FmbDevInfo->hSceCurrent = hSceCurrent; +} + + +inline enum MMUXDeviceNumEnum FmbGetCurMmuxDevNum(void) +{ + return gp_FmbInfo->currentMmxuDevNum; +} + +inline void FmbSetCurMmuxDevNum(enum MMUXDeviceNumEnum deviceNum) +{ + ASSERT_USR( (MMUXDevice_0 <= deviceNum) && (deviceNum < MMUXDeviceMax), + "Error: deviceNum?"); + gp_FmbInfo->currentMmxuDevNum = deviceNum; +} + +inline MmuxHandle FmbGetCurMmuxHd(void) +{ + return gp_FmbInfo->hdMmux_A[gp_FmbInfo->currentMmxuDevNum]; +} + +inline MmuxHandle FmbGetMmuxHd(enum MMUXDeviceNumEnum deviceNum) +{ + ASSERT_USR( (MMUXDevice_0 <= deviceNum) && (deviceNum < MMUXDeviceMax), + "Error: deviceNum?"); + return gp_FmbInfo->hdMmux_A[deviceNum]; +} + + +enum FMBDeviceNumEnum FmbSetFirstDev(void) +{ + enum FMBDeviceNumEnum deviceNum; + + FMB_FUNC(TRUE); + + for (deviceNum=FMBEnmDevice_0; deviceNum<gp_FmbInfo->countCodecChip; deviceNum++) { + if (gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL) { + if (gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used) { + FmbSetCurDeviceNum(deviceNum); + break; + } + } + } + + if (deviceNum == gp_FmbInfo->countCodecChip) { + deviceNum = FMBEnmDevice_NONE; + } + + FMB_FUNC(FALSE); + + return deviceNum; +} + +enum FMBDeviceNumEnum FmbSetNextDev(void) +{ + enum FMBDeviceNumEnum deviceNum; + + FMB_FUNC(TRUE); + + deviceNum = gp_FmbInfo->currentDeviceNum; + ASSERT_USR(0 <= deviceNum, "deviceNum < 0"); + + for (deviceNum++; deviceNum<gp_FmbInfo->countCodecChip; deviceNum++) { + if (gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL) { + if (gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used) { + FmbSetCurDeviceNum(deviceNum); + break; + } + } + } + + if (deviceNum == gp_FmbInfo->countCodecChip) { + deviceNum = FMBEnmDevice_NONE; + } + + FMB_FUNC(FALSE); + + return deviceNum; +} + +void FmbMultiCall(void (*fun)(void)) +{ + enum FMBDeviceNumEnum devNum, devNum_old; + + FMB_FUNC(TRUE); + + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + fun(); + } + FmbSetCurDeviceNum(devNum_old); + + + FMB_FUNC(FALSE); +} + + +void FmbEnableDevUse(enum FMBDeviceNumEnum deviceNum) +{ + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, "Error: deviceNum?"); + + gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used = TRUE; + + FMB_FUNC(FALSE); +} + +void FmbDisableDevUse(enum FMBDeviceNumEnum deviceNum) +{ + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, "Error: deviceNum?"); + + gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used = FALSE; + + FMB_FUNC(FALSE); +} + +void FmbEnableDevUseAll(void) +{ + enum FMBDeviceNumEnum deviceNum; + + FMB_FUNC(TRUE); + + for (deviceNum = FMBEnmDevice_0; deviceNum<gp_FmbInfo->totalCodecChip; deviceNum++) { + gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used = TRUE; + } + + FMB_FUNC(FALSE); +} + +void FmbDisableDevUseAll(void) +{ + enum FMBDeviceNumEnum deviceNum; + + FMB_FUNC(TRUE); + + for (deviceNum = FMBEnmDevice_0; deviceNum<gp_FmbInfo->totalCodecChip; deviceNum++) { + gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used = FALSE; + } + + FMB_FUNC(FALSE); +} + +int FmbIsDevUse(enum FMBDeviceNumEnum deviceNum) +{ + int ret; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbInfo->pt_deviceInfo_A[deviceNum] != NULL, "Error: deviceNum?"); + + ret = gp_FmbInfo->pt_deviceInfo_A[deviceNum]->used; + + FMB_FUNC(FALSE); + + return ret; +} + + +static int FmbSetFirmPath(struct FMBInfo *p_Info) +{ + FILE *fp; + + FMB_FUNC(TRUE); + + fp = fopen(DEFAULT_FMB_FIRMPATH , "rb"); + if ( fp == NULL ){ + fp = fopen(DEFAULT_FMB_SECONDARY_FIRMPATH , "rb"); + if ( fp == NULL){ + ASSERT_USR(FALSE , "fopen() error"); + FMB_FUNC(FALSE); + return FALSE; + }else{ + strcpy(p_Info->firmPath_A, DEFAULT_FMB_SECONDARY_FIRMPATH); + } + }else{ + strcpy(p_Info->firmPath_A, DEFAULT_FMB_FIRMPATH); + } + fclose(fp); + + FMB_FUNC(FALSE); + + return TRUE; +} diff --git a/fmb_player_apl/src/com/FmbComDriver.c b/fmb_player_apl/src/com/FmbComDriver.c new file mode 100644 index 0000000..060a8c3 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComDriver.c @@ -0,0 +1,458 @@ +/** +* @brief The function that conceals the MB86 driver's API (ioctl etc.) is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <pthread.h> +#include <sys/types.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <err.h> +#include <unistd.h> +#include <string.h> +#include "FmbCmn.h" + +/** +* @brief The MB86 device driver is opened. +* @param[in] argDriverPath Driver's path name +* @return None File descriptor of opened driver. +* @note None +* @attention None +*/ +int DrvOpen(char *argDriverPath) +{ + int fd; + + FMB_FUNC(TRUE); + + fd = open(argDriverPath ,O_RDWR); //The driver is opened. + ASSERT_SYS(fd >= 0, "open()"); + + LogFmb("fd\t%d", fd); + + FMB_FUNC(FALSE); + return fd; +} + + +/** +* @brief The ioctl wrapper +* @param[in] req request +* @param[in] pvArg argument +* @return None +* @note None +* @attention None +*/ +int DrvIoctl(int fd, int req, void *pvArg) +{ + int rc; + + FMB_FUNC(TRUE); + + rc = ioctl(fd, req, pvArg); + ASSERT_SYS(rc != -1, "ioctl()"); + + FMB_FUNC(FALSE); + return rc; +} + +/** +* @brief The ioctl wrapper +* @param[in] req request +* @param[in] pvArg argument +* @return None +* @note None +* @attention None +*/ +int DrvIoctlCmd(int fd, int req, void *pvArg) +{ + int rc; + + FMB_FUNC(TRUE); + + rc = ioctl(fd, req, pvArg); + + FMB_FUNC(FALSE); + return rc; +} + +/** +* @brief The MB86 device driver is closed. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void DrvClose(int fd) +{ + FMB_FUNC(TRUE); + close(fd); + FMB_FUNC(FALSE); +} + +/** +* @brief The MB86 device driver cmd-info is reseted. +* @param[in] sceHandle Scenario handle +* @param[in] type reset type +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum DrvResetCmdInfo(HANDLE sceHandle, unsigned long type, unsigned long dummy1, unsigned long dummy2) +{ + struct fmb_cmd_info_reset info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(&info, 0, sizeof(info)); + info.type = type; + + DrvIoctl(deviceFd, FMB_API_RESET_CMD_INFO, &info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief The MB86 device driver factor is reseted. +* @param[in] sceHandle Scenario handle +* @param[in] factor reset factor +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum DrvResetFactor(HANDLE sceHandle, unsigned long factor, unsigned long dummy1, unsigned long dummy2) +{ + struct fmb_factor_reset param; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(¶m, 0, sizeof(param)); + + param.factor = factor; + + DrvIoctl(deviceFd, FMB_API_RESET_FACTOR, ¶m); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief The MB86 device driver video-format is reseted. +* @param[in] sceHandle Scenario handle +* @param[in] format Video-fromat ( FMB_DATA_FORMAT_MODE_1:1920x1080(60i) + FMB_DATA_FORMAT_MODE_2:1920x1080(50i) + FMB_DATA_FORMAT_MODE_3:1280x720(60p) + FMB_DATA_FORMAT_MODE_4:1280x720(50p) + FMB_DATA_FORMAT_MODE_5:720x480(60i) + FMB_DATA_FORMAT_MODE_6:720x576(50i) + ) +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum DrvSetInternal(HANDLE sceHandle, unsigned long type, unsigned long data, unsigned long dummy2) +{ + struct fmb_internal_info info; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + memset(&info, 0, sizeof(info)); + + info.type = type; + info.data = data; + + DrvIoctl(deviceFd, FMB_API_SET_INTERNAL_DATA, &info); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + + +/** +* @brief Notify mode is set. +* @param[in] sceHandle Scenario handle +* @param[in] isNotify When the change is detected, TRUE is specified. +* @return None +* @note None +* @attention None +*/ +void DrvSetIsNotify(HANDLE sceHandle, BOOL isNotify) +{ + struct fmb_internal_info innerInfo; + int deviceFd; + + FMB_FUNC(TRUE); + deviceFd = SceGetDevHandle(sceHandle); + + innerInfo.type = FMB_DATA_TYPE_NOTIFY; + + DrvIoctl(deviceFd, FMB_API_GET_INTERNAL_DATA, &innerInfo); + + LogFmb("AsyncMask\t0x%x", innerInfo.data); + if(isNotify){ + innerInfo.data = FMB_DATA_NOTIFY_ALL; //Notify msg for all + } + else{ + innerInfo.data = FMB_DATA_NOTIFY_NONE; + } + + DrvIoctl(deviceFd, FMB_API_SET_INTERNAL_DATA, &innerInfo); + FMB_FUNC(FALSE); +} + +/** +* @brief To read a file specified and write a firmware to MB86, +* and send the instruction to boot up the firmware to MB86. +* +* @param[in] sceHandle +* @param[in] firmPath +* @return 0 Normal end +* @return -1 Abnormal end +* @note None +* @attension None +*/ + + +enum SceResultEnum DrvBootUp(HANDLE sceHandle, char *firmPath, unsigned long dummy2,unsigned long dummy3) +{ + FILE* fp = NULL; + int rc; + char* my_firm; + unsigned long file_length; + unsigned long split_size; + unsigned long write_size; + struct fmb_firm_info firm_info; + struct fmb_factor_info factor_info; + struct fmb_msg_sys_info msg_sys_info; + struct fmb_bootup_firm_info bootup_firm_info; + int deviceFd; + + FMB_FUNC(TRUE); + + deviceFd = SceGetDevHandle(sceHandle); + + firm_info.firm_data = NULL; + factor_info.factor = 0; + factor_info.timeout = 100; + msg_sys_info.id = 0; + msg_sys_info.sub_id = 0; + msg_sys_info.timeout = 0; + bootup_firm_info.timeout = FMB_FIRM_TIMEOUT; + split_size = FIRM_WRITE_SIZE; + + + my_firm = firmPath; + memset(&firm_info, 0, sizeof(struct fmb_firm_info)); + + fp = fopen(my_firm , "rb"); + + if(fp == NULL){ + ASSERT_USR(FALSE , "fopen() error"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + + + fseek(fp, 0, SEEK_END); + file_length = ftell(fp); + rewind(fp); + + if (file_length == 0) { + fclose(fp); + ASSERT_USR(FALSE , "open() error"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + + if (split_size > file_length) { + split_size = file_length; + } + + firm_info.firm_data = malloc((sizeof(unsigned char) * split_size)); + + if (firm_info.firm_data == NULL) { + fclose(fp); /*pgr0522*/ + ASSERT_USR(FALSE , "malloc() error"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + + /** check bootroader boot-up */ + rc = DrvIoctl(deviceFd, FMB_API_INIT_PREPARE_FIRM,0); + + if (rc != 0) { + fclose(fp); /*pgr0522*/ + ASSERT_USR(FALSE , "ioctl()"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + + write_size = 0; + + while (write_size < file_length) { + firm_info.firm_size = fread(firm_info.firm_data, sizeof(unsigned char), + split_size, fp); /*pgr0522*/ + if (firm_info.firm_size < split_size) { + if (ferror(fp) != 0 ) { + fclose(fp); + ASSERT_USR(FALSE , "fread() error"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + if (feof(fp) == 0 ) { /*pgr0522*/ + fclose(fp); /*pgr0522*/ + ASSERT_USR(FALSE , "fread() error"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + } + + /** transfer firmware to codec lsi */ + rc = DrvIoctl(deviceFd, FMB_API_WRITE_FIRM, &firm_info); + + if (rc != 0) { + fclose(fp); /*pgr0522*/ + ASSERT_USR(FALSE , "ioctl()"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + write_size += firm_info.firm_size; + } + + /** check firmware boot-up */ + rc = DrvIoctl(deviceFd, FMB_API_BOOT_UP_FIRM, &bootup_firm_info); + + if (rc != 0) { + fclose(fp); /*pgr0522*/ + ASSERT_USR(FALSE , "ioctl()"); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + + } + + fclose(fp); /*pgr0522*/ + free(firm_info.firm_data); + + DrvSetIsNotify(sceHandle, TRUE); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + +} + +int DrvBootAll(void) +{ + struct FMBDeviceInfo *pt_deviceInfo; + struct BootEnv *p_env; + enum FMBDeviceNumEnum devNum,devNumOld; + int ret = 0; + + FMB_FUNC(TRUE); + + devNumOld = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + enum SceResultEnum sceResult; + struct RecvEventArgType evnt; + int rc; + + pt_deviceInfo = FmbGetCurDevInfo(); + p_env = &pt_deviceInfo->t_BootThread.t_env; + + fprintOut(stdout, "[dev-%d] Boot ...\n", devNum); + + sceResult = DrvBootUp(*p_env->p_sceHandle, p_env->p_firmPath , 0, 0); + if( sceResult != SceEnmResultSyncEnd){ + fprintOut(stdout,"Error:[dev-%d] Failed in the firm boot.\n", devNum ); + ret = -1; + break; + } + + while(FmbRecvGetEventInfo(&evnt, *p_env->p_fdPipeRead)){ + if( evnt.dev != FMBEnmCoreDeviceSystem || + evnt.evnt != FMBEnmCoreFromMsg || + evnt.WaitDetail.SysMsg.id != 0x01 || + evnt.WaitDetail.SysMsg.sub_id != 0x00 ){ + continue; + } + } + + p_env->p_version_info->driver_ver = p_env->driver_ver; + p_env->p_version_info->firm_ver = p_env->firm_ver; + rc = DrvIoctl(*p_env->p_deviceFd, FMB_API_GET_VERSION, p_env->p_version_info); + if (rc != OK) { + fprintOut(stdout,"Error:Failed in reading the version.\n"); + FMB_FUNC(TRUE); + ret = -1; + } + + *p_env->p_firmLSIVer = p_env->p_version_info->firm_ver[2] & 0x00FF; + + *p_env->p_subSystemId = PciGetReg(*p_env->p_sceHandle, 0, 0xc8); + } + + FmbSetCurDeviceNum(devNumOld); + + FMB_FUNC(FALSE); + + return ret; +} + +int CheckVersionInfo(void) +{ + struct FMBDeviceInfo *pt_deviceInfo; + enum FMBDeviceNumEnum devNum, devNumOld; + int ret = TRUE; + char driver_ver[FMB_DRIVER_VERSION_LENGTH]; + unsigned short firm_ver[FMB_VERSION_REG_SIZE / 2]; + + FMB_FUNC(TRUE); + + devNumOld = FmbGetCurDeviceNum(); + devNum = FmbSetFirstDev(); + pt_deviceInfo = FmbGetCurDevInfo(); + memcpy(driver_ver, pt_deviceInfo->version_info.driver_ver, sizeof(driver_ver)); + memcpy(firm_ver, pt_deviceInfo->version_info.firm_ver, sizeof(firm_ver)); + for (; devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + char *p_driver_ver; + unsigned short *p_firm_ver; + + pt_deviceInfo = FmbGetCurDevInfo(); + p_driver_ver = pt_deviceInfo->version_info.driver_ver; + p_firm_ver = pt_deviceInfo->version_info.firm_ver; + + if (memcmp(driver_ver, p_driver_ver, sizeof(driver_ver)) != 0) { + ret = FALSE; + } + if (memcmp(firm_ver, p_firm_ver, sizeof(firm_ver)) != 0) { + ret = FALSE; + } + } + FmbSetCurDeviceNum(devNumOld); + + FMB_FUNC(FALSE); + + return ret; +} diff --git a/fmb_player_apl/src/com/FmbComFile.c b/fmb_player_apl/src/com/FmbComFile.c new file mode 100644 index 0000000..d8c36c0 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComFile.c @@ -0,0 +1,361 @@ +/** +* @brief Operate the file. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <unistd.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/stat.h> + +#include "FmbCmn.h" + + +static FILE* _fp = NULL; +static const char *_configString={ +"\ +[com]\n\ +tsFormatInput=%d\n\ +tsFormatOutput=%d\n\ +PidValueInputVideoPid=0x%x\n\ +PidValueInputAudioPid=0x%x\n\ +PidValueInputPmtPid=0x%x\n\ +PidValueInputSitPid=0x%x\n\ +PidValueInputPcrPid=0x%x\n\ +PidValueOutputVideoPid=0x%x\n\ +PidValueOutputAudioPid=0x%x\n\ +PidValueOutputPmtPid=0x%x\n\ +PidValueOutputSitPid=0x%x\n\ +PidValueOutputPcrPid=0x%x\n\ +firmPath=%s\n\ +[enc]\n\ +inputPort=%d\n\ +outputPort=%d\n\ +outputfile=%s\n\ +videoFmt=%d\n\ +videoFrm=%d\n\ +videoScr=%d\n\ +audioFmt=%d\n\ +bitrateCalckind=%d\n\ +videoRateCtl=%d\n\ +videoBitrateCbr=%d\n\ +videoBitrateVbrAverage=%d\n\ +videoBitrateVbrPeak=%d\n\ +audioBitrateCbrMpeg1l2=%d\n\ +audioBitrateCbrAc3=%d\n\ +audioBitrateCbrLpcm=%d\n\ +audioBitrateCbrAac=%d\n\ +audioBitrateVbrAverage=%d\n\ +audioBitrateVbrPeak=%d\n\ +systemMuxRate=%d\n\ +audioLpcm=%d\n\ +[dec]\n\ +inputPort=%d\n\ +outputPort=%d\n\ +inputfile=%s\n\ +videoFmt=%d\n\ +videoFrm=%d\n\ +audioFmt=%d\n\ +" +}; + +extern const int g_ReloadAudio[FMB_AUDIO_FORMAT_KIND]; + +/** +* @brief Open a Config file. +* @param[in] filepth file path name +* @return TRUE Normal end +* @return FALSE Not Save +* @note None +* @attention None +*/ +BOOL FmbConfigFileOpen(char* filepath ,char* att) +{ + + char* err_cause; + + FMB_FUNC(TRUE); + + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + + _fp = fopen(filepath , att); + + if(_fp == NULL){ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",filepath ,errno, err_cause); + FMB_FUNC(FALSE); + return FALSE; + } + + FMB_FUNC(FALSE); + return TRUE; +} +/** +* @brief Close a Config file. +* @param[in] none. +* @return TRUE Normal end +* @return FALSE Abnormal end +* @note None +* @attention None +*/ +BOOL FmbConfigFileClose(void) +{ + + + FMB_FUNC(TRUE); + + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Save a Config file. +* @param[in] none. +* @return TRUE Normal end +* @return FALSE Abnormal end +* @note None +* @attention None +*/ +BOOL FmbConfigFileSave(void) +{ + + + FMB_FUNC(TRUE); + + fprintf (_fp,_configString , + gp_FmbComProperty->tsFormat[FMBEnmInputTsPacket], + gp_FmbComProperty->tsFormat[FMBEnmOutputTsPacket], + gp_FmbComProperty->PidValue[FMBEnmInputVideoPid], + gp_FmbComProperty->PidValue[FMBEnmInputAudioPid], + gp_FmbComProperty->PidValue[FMBEnmInputPmtPid], + gp_FmbComProperty->PidValue[FMBEnmInputSitPid], + gp_FmbComProperty->PidValue[FMBEnmInputPcrPid], + gp_FmbComProperty->PidValue[FMBEnmOutputVideoPid], + gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid], + gp_FmbComProperty->PidValue[FMBEnmOutputPmtPid], + gp_FmbComProperty->PidValue[FMBEnmOutputSitPid], + gp_FmbComProperty->PidValue[FMBEnmOutputPcrPid], + gp_FmbInfo->firmPath_A, + gp_FmbProperty[FMBEnmFuncModeEnc].inputPort, + gp_FmbProperty[FMBEnmFuncModeEnc].outputPort, + gp_FmbProperty[FMBEnmFuncModeEnc].outputfile, + gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt, + gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm, + gp_FmbProperty[FMBEnmFuncModeEnc].videoScalerEnc, + gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt, + gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.bitrateCalckind, + gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoRateCtl, + gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoBitrateCbr, + gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoBitrateVbrAverage, + gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoBitrateVbrPeak, + gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtMpeg1l2], + gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtAc3], + gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtLpcm], + gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtAac], + gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateVbrAverage, + gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateVbrPeak, + gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.systemMuxRate, + gp_FmbProperty[FMBEnmFuncModeEnc].audioLpcm, + gp_FmbProperty[FMBEnmFuncModeDec].inputPort, + gp_FmbProperty[FMBEnmFuncModeDec].outputPort, + gp_FmbProperty[FMBEnmFuncModeDec].inputfile, + gp_FmbProperty[FMBEnmFuncModeDec].videoFmt, + gp_FmbProperty[FMBEnmFuncModeDec].videoFrm, + gp_FmbProperty[FMBEnmFuncModeDec].audioFmt + ); + + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Load a Config file. +* @param[in] none. +* @return TRUE Normal end +* @return FALSE Abnormal end +* @note None +* @attention None +*/ +BOOL FmbConfigFileLoad(void) +{ + + FMB_FUNC(TRUE); + + fscanf (_fp,_configString , + &gp_FmbComProperty->tsFormat[FMBEnmInputTsPacket], + &gp_FmbComProperty->tsFormat[FMBEnmOutputTsPacket], + &gp_FmbComProperty->PidValue[FMBEnmInputVideoPid], + &gp_FmbComProperty->PidValue[FMBEnmInputAudioPid], + &gp_FmbComProperty->PidValue[FMBEnmInputPmtPid], + &gp_FmbComProperty->PidValue[FMBEnmInputSitPid], + &gp_FmbComProperty->PidValue[FMBEnmInputPcrPid], + &gp_FmbComProperty->PidValue[FMBEnmOutputVideoPid], + &gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid], + &gp_FmbComProperty->PidValue[FMBEnmOutputPmtPid], + &gp_FmbComProperty->PidValue[FMBEnmOutputSitPid], + &gp_FmbComProperty->PidValue[FMBEnmOutputPcrPid], + &gp_FmbInfo->firmPath_A, + &gp_FmbProperty[FMBEnmFuncModeEnc].inputPort, + &gp_FmbProperty[FMBEnmFuncModeEnc].outputPort, + &gp_FmbProperty[FMBEnmFuncModeEnc].outputfile, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoScalerEnc, + &gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.bitrateCalckind, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoRateCtl, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoBitrateCbr, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoBitrateVbrAverage, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.videoBitrateVbrPeak, + &gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtMpeg1l2], + &gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtAc3], + &gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtLpcm], + &gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtAac], + &gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateVbrAverage, + &gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateVbrPeak, + &gp_FmbProperty[FMBEnmFuncModeEnc].videoBitrateProp.systemMuxRate, + &gp_FmbProperty[FMBEnmFuncModeEnc].audioLpcm, + &gp_FmbProperty[FMBEnmFuncModeDec].inputPort, + &gp_FmbProperty[FMBEnmFuncModeDec].outputPort, + &gp_FmbProperty[FMBEnmFuncModeDec].inputfile, + &gp_FmbProperty[FMBEnmFuncModeDec].videoFmt, + &gp_FmbProperty[FMBEnmFuncModeDec].videoFrm, + &gp_FmbProperty[FMBEnmFuncModeDec].audioFmt + ); + + gp_FmbProperty[FMBEnmFuncModeEnc].audioFmtReload = g_ReloadAudio[gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt]; + gp_FmbProperty[FMBEnmFuncModeDec].audioFmtReload = g_ReloadAudio[gp_FmbProperty[FMBEnmFuncModeDec].audioFmt]; + + FMB_FUNC(FALSE); + return TRUE; +} +/** +* @brief Get the stream file size. +* @param[in] FmbFileTypeEnum file kind(input file : FmbEnmInFile / output file : FmbEnmOutFile) +* @return size +* @note None +* @attention None +*/ +__off64_t FmbGetFileSize(char* filepath ) +{ + int rc; + struct stat64 st; + char* err_cause; + + FMB_FUNC(TRUE); + + rc = stat64(filepath,&st); + if ( rc != 0){ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",filepath ,errno, err_cause); + FMB_FUNC(FALSE); + return 0; + } + + FMB_FUNC(FALSE); + return st.st_size; +} + +/** +* @brief Check the file. +* @param[in] filepth file path name +* @return TRUE Normal end +* @return FALSE No file +* @note None +* @attention None +*/ +BOOL FmbIsExistenceFile(char* filepath ) +{ + int rc; + struct stat64 st; + ino_t inode=0; + char* err_cause; + + FMB_FUNC(TRUE); + + rc = stat64(filepath,&st); + if ( rc == 0){ + inode = st.st_ino; + LogFmb("%s stat info:inode (%d)",filepath,inode); + } + else{ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",filepath ,errno, err_cause); + FMB_FUNC(FALSE); + return FALSE; + } + + FMB_FUNC(FALSE); + return TRUE; +} + + +/** +* @brief Check the diffarent file. +* @param[in] in_filepath input file path name +* @param[in] out_filepath output file path name +* @return TRUE Normal end +* @return FALSE Same file +* @note None +* @attention None +*/ +BOOL FmbIsDifferentFile(char* in_filepath , char* out_filepath) +{ + int rc; + struct stat64 st; + ino_t in_inode=0; + ino_t out_inode=0; + char* err_cause; + + FMB_FUNC(TRUE); + + rc = stat64(in_filepath,&st); + if ( rc == 0){ + in_inode = st.st_ino; + LogFmb("%s stat info:inode (%d)",in_filepath,in_inode); + } + else{ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",in_filepath ,errno, err_cause); + } + + rc = stat64(out_filepath,&st); + if ( rc == 0){ + out_inode = st.st_ino; + LogFmb("%s stat info:inode (%d)",out_filepath,out_inode); + } + else{ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",out_filepath ,errno, err_cause); + } + + if (in_inode!=0 && out_inode!=0){ + if ( in_inode == out_inode ){ + FMB_FUNC(FALSE); + return FALSE; + } + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/com/FmbComPci.c b/fmb_player_apl/src/com/FmbComPci.c new file mode 100644 index 0000000..92f9e2e --- /dev/null +++ b/fmb_player_apl/src/com/FmbComPci.c @@ -0,0 +1,220 @@ +/** +* @brief The function accessed PCI is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> +#include <sys/ioctl.h> +#include "FmbCmn.h" +/** +* @brief Get the register value on the MB86-RB. +* @param[in] sceHandle Scenario handle +* @param[in] offset register's offset +* @return Value of register +* @note None +* @attention None +*/ +unsigned long LsiGetReg( HANDLE sceHandle, + unsigned long offset) +{ + struct fmb_reg_info reg; + unsigned long prm_data = 1; + int deviceFd; + + FMB_FUNC(TRUE); + ASSERT_USR(sceHandle != NULL, "It is closed handle!"); + + + memset(®, 0, sizeof(reg)); + + reg.offset = offset; + reg.reg_num = 1; + reg.prm_data = (unsigned short*)&prm_data; + + + deviceFd = SceGetDevHandle(sceHandle); + DrvIoctl(deviceFd, + FMB_API_GET_LSI_REG , + ®); + + LogFmb("[reg_get_pci]\t0x%08x\toffset\t0x%08x\tvalue\t0x%08x", + reg.offset, *reg.prm_data); + + FMB_FUNC(FALSE); + return prm_data; +} + + +/** +* @brief Set the register value on the MB86-RB +* @param[in] sceHandle Scenario handle +* @param[in] offset register's offset +* @param[in] value written value +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum LsiSetReg( HANDLE sceHandle, + unsigned long offset, + unsigned long value, + unsigned long dummy) +{ + struct fmb_reg_info reg; + unsigned short prm_data = (unsigned short)value; + int deviceFd; + + FMB_FUNC(TRUE); + ASSERT_USR(sceHandle != NULL, "It is closed handle!"); + + + memset(®, 0, sizeof(reg)); + + reg.offset = offset; + reg.reg_num = 1; + reg.prm_data = &prm_data; + + LogFmb("[reg_set]\toffset\t0x%08x\tvalue\t0x%08x", + reg.offset, *reg.prm_data); + + deviceFd = SceGetDevHandle(sceHandle); + DrvIoctl(deviceFd, + FMB_API_SET_LSI_REG, + ®); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} +/** +* @brief Set the register value on the MB86-RB +* @param[in] sceHandle Scenario handle +* @param[in] offset register's offset +* @param[in] value written value +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum LsiSetRegPtr( HANDLE sceHandle, + unsigned long offset, + unsigned long valuep, + unsigned long dummy) +{ + struct fmb_reg_info reg; + unsigned short prm_data; + int deviceFd; + + FMB_FUNC(TRUE); + ASSERT_USR(sceHandle != NULL, "It is closed handle!"); + + memset(®, 0, sizeof(reg)); + + prm_data = (unsigned short)*(unsigned long*)valuep; + reg.offset = offset; + reg.reg_num = 1; + reg.prm_data = &prm_data; + + LogFmb("[reg_set]\toffset\t0x%08x\tvalue\t0x%04x", + reg.offset, *reg.prm_data); + + deviceFd = SceGetDevHandle(sceHandle); + DrvIoctl(deviceFd, + FMB_API_SET_LSI_REG, + ®); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Get the register value from PCI on the MB86-RB. +* @param[in] sceHandle Scenario handle +* @param[in] reg_type PCI register's type +* @param[in] offset PCI register's offset +* @return Value of register +* @note None +* @attention None +*/ +unsigned long PciGetReg( HANDLE sceHandle, + unsigned long reg_type, + unsigned long offset) +{ + struct fmb_pci_reg_info reg; + unsigned long prm_data = 1; + int deviceFd; + + FMB_FUNC(TRUE); + ASSERT_USR(sceHandle != NULL, "It is closed handle!"); + + + memset(®, 0, sizeof(reg)); + + reg.reg_type = reg_type; + reg.offset = offset; + reg.reg_num = 1; + reg.prm_data = &prm_data; + + + deviceFd = SceGetDevHandle(sceHandle); + DrvIoctl(deviceFd, + FMB_API_GET_PCI_REG, + ®); + + LogFmb("[reg_get_pci]\ttype\t0x%08x\toffset\t0x%08x\tvalue\t0x%08x", + reg.reg_type, reg.offset, *reg.prm_data); + + FMB_FUNC(FALSE); + return prm_data; +} + +/** +* @brief Set the register value to PCI on the MB86-RB +* @param[in] sceHandle Scenario handle +* @param[in] reg_type PCI register's type +* @param[in] offset PCI register's offset +* @param[in] value written value +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum PciSetReg( HANDLE sceHandle, + unsigned long reg_type, + unsigned long offset, + unsigned long value) +{ + struct fmb_pci_reg_info reg; + unsigned long prm_data = value; + int deviceFd; + + FMB_FUNC(TRUE); + ASSERT_USR(sceHandle != NULL, "It is closed handle!"); + + + memset(®, 0, sizeof(reg)); + + reg.reg_type = reg_type; + reg.offset = offset; + reg.reg_num = 1; + reg.prm_data = &prm_data; + + LogFmb("[reg_set_pci]\ttype\t0x%08x\toffset\t0x%08x\tvalue\t0x%08x", + reg.reg_type, reg.offset, *reg.prm_data); + + deviceFd = SceGetDevHandle(sceHandle); + DrvIoctl(deviceFd, + FMB_API_SET_PCI_REG, + ®); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + + diff --git a/fmb_player_apl/src/com/FmbComRecv.c b/fmb_player_apl/src/com/FmbComRecv.c new file mode 100644 index 0000000..0200580 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComRecv.c @@ -0,0 +1,709 @@ +/** +* @brief The function of "The command response and the message from FmbLSI are received" + straightening is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <pthread.h> +#include <unistd.h> +#include <sys/select.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> + +#include "FmbCmn.h" + +#ifndef FMB_BIG_ENDIAN + + +///Video Message Format For little endian +struct VideoMsgType{ + //0 + unsigned Dummy1:15; + unsigned VALID:1; + + //1 + unsigned MODE:8; + unsigned Dummy3:6; + unsigned CMD_INVALID:1; + unsigned Dummy2:1; + + //2 + unsigned TFRFF:2; + unsigned SEQ_END:1; + unsigned Dummy4:13; + + //3 + unsigned FRAME_UPDATE_FLAG:1; + unsigned Dummy6:7; + unsigned V_PTS_VALID_FLAG:1; + unsigned Dummy5:7; + + //4 + unsigned short V_ERROR_LEVEL_H; + + //5 + unsigned short V_ERROR_LEVEL_L; + + //6 + unsigned short Dummy7; + + //7 + unsigned short FRAME_COUNT_GOP; + + //8 + unsigned short VSYNC_COUNT_H; + + //9 + unsigned short VSYNC_COUNT_L; + + //A + unsigned short Dummy8[0x16]; + + //20 + unsigned short V_PTS_H; + + //21 + unsigned short V_PTS_L; + + //22 + unsigned DummyB:2; + unsigned PIC_TYPE:2; + unsigned DummyA:4; + unsigned V_EOS:2; + unsigned Dummy9:6; + + //23 + unsigned VSEQ_NUM:16; + + //24 + unsigned short DummyC; + + //25 + unsigned short V_FRAME_RATE_CODE; + + //26 + unsigned short V_ASPECT_RATIO_IDC; + + //27 + unsigned short V_PIC_WIDTH_IN_MBS; + + //28 + unsigned V_PIC_HEIGHT_IN_MBS:16; + + //29 + unsigned SUBMODE:2; + unsigned DummyD:14; + + //2A + unsigned short VUDATA_LENGTH; + + //2B + unsigned short V_BITRATE_H; + + //2C + unsigned short V_BITRATE_L; + + //2D + unsigned short DummyE[0x33]; + + //60 + unsigned short VUDATA[0x7F]; +}; + +///Audio message format for little endian +struct AudioMsgType{ + //0 + unsigned Dummy1:15; + unsigned VALID:1; + + //1 + unsigned A_CH:2; + unsigned Dummy2:14; + + //2 + unsigned A_MUTE:1; + unsigned Dummy3:14; + unsigned A_MUTE_ST:1; + + //3 + unsigned AV_SYNC:2; + unsigned AFRAME_UPDATE_FLAG:1; + unsigned Dummy5:5; + unsigned A_PTS_VALID_FLAG:1; + unsigned Dummy4:7; + + //4 + unsigned short AERROR_H; + + //5 + unsigned short AERROR_L; + + //6 + unsigned short Dummy6[0xA]; + + //10 + unsigned short A_PTS_H; + + //11 + unsigned short A_PTS_L; + + //12 + unsigned short Dummy7[0x6]; + + //18 + unsigned short A_BITSTREAM_INFO[0x4]; +}; + +#else +///Video message format for big endian +struct VideoMsgType{ + //0 + unsigned VALID:1; + unsigned Dummy1:15; + + //1 + unsigned Dummy2:1; + unsigned CMD_INVALID:1; + unsigned Dummy3:6; + unsigned MODE:8; + + //2 + unsigned Dummy4:13; + unsigned SEQ_END:1; + unsigned TFRFF:2; + + //3 + unsigned Dummy5:7; + unsigned V_PTS_VALID_FLAG:1; + unsigned Dummy6:7; + unsigned FRAME_UPDATE_FLAG:1; + + //4 + unsigned short V_ERROR_LEVEL_H; + + //5 + unsigned short V_ERROR_LEVEL_L; + + //6 + unsigned short Dummy7; + + //7 + unsigned short FRAME_COUNT_GOP; + + //8 + unsigned short VSYNC_COUNT_H; + + //9 + unsigned short VSYNC_COUNT_L; + + //A + unsigned short Dummy8[0x16]; + + //20 + unsigned short V_PTS_H; + + //21 + unsigned short V_PTS_L; + + //22 + unsigned Dummy9:6; + unsigned V_EOS:2; + unsigned DummyA:4; + unsigned PIC_TYPE:2; + unsigned DummyB:2; + + //23 + unsigned VSEQ_NUM:16; + + //24 + unsigned short DummyC; + + //25 + unsigned short V_FRAME_RATE_CODE; + + //26 + unsigned short V_ASPECT_RATIO_IDC; + + //27 + unsigned short V_PIC_WIDTH_IN_MBS; + + //28 + unsigned V_PIC_HEIGHT_IN_MBS:16; + + //29 + unsigned DummyD:14; + unsigned SUBMODE:2; + + //2A + unsigned short VUDATA_LENGTH; + + //2B + unsigned short V_BITRATE_H; + + //2C + unsigned short V_BITRATE_L; + + //2D + unsigned short DummyE[0x33]; + + //60 + unsigned short VUDATA[0x7F]; +}; + +///Audio message format for big endian +struct AudioMsgType{ + //0 + unsigned VALID:1; + unsigned Dummy1:15; + + //1 + unsigned Dummy2:14; + unsigned A_CH:2; + + //2 + unsigned A_MUTE_ST:1; + unsigned Dummy3:14; + unsigned A_MUTE:1; + + //3 + unsigned Dummy4:7; + unsigned A_PTS_VALID_FLAG:1; + unsigned Dummy5:5; + unsigned AFRAME_UPDATE_FLAG:1; + unsigned AV_SYNC:2; + + //4 + unsigned short AERROR_H; + + //5 + unsigned short AERROR_L; + + //6 + unsigned short Dummy6[0xA]; + + //10 + unsigned short A_PTS_H; + + //11 + unsigned short A_PTS_L; + + //12 + unsigned short Dummy7[0x6]; + + //18 + unsigned short A_BITSTREAM_INFO[0x4]; +}; + +#endif + +///XERROR format +struct XerrorMsgType{ + unsigned short M_ERROR_INFO_H; + unsigned short M_ERROR_INFO_L; + unsigned short V_ERROR_INFO_H; + unsigned short V_ERROR_INFO_L; + unsigned short A_ERROR_INFO_H; + unsigned short A_ERROR_INFO_L; +}; + +void *fmbRecvThread(void *arg); +static void sendEventToMainThread(int fmbfd, const struct fmb_factor_info *factor_info, struct RecvEnv *p_RecvEnv); +static void fmbRecvDrvIoctl(int fd, int req, void *pvArg); + + +/** +* @brief Receive thread is begun. +* @param[in] t_RecvEnv +* @return File descriptor on reading side of pipe for event notification. +* @note None +* @attention None +*/ +int FmbRecvBegin(struct RecvThread *p_RecvThread) +{ + int fdPipeForEventSend[2]; + int rc; + int flg; + pthread_t *p_thread; + struct RecvEnv *p_env; + + + FMB_FUNC(TRUE); + + p_thread = &p_RecvThread->thread; + p_env = &p_RecvThread->t_env; + + rc = pipe(fdPipeForEventSend); + ASSERT_SYS(rc == 0, "pipe"); + + *p_env->p_fdPipeRead = fdPipeForEventSend[0]; + *p_env->p_fdPipeWrite = fdPipeForEventSend[1]; + + flg = fcntl(*p_env->p_fdPipeRead, F_GETFL); + ASSERT_SYS(flg != -1, "fcntl"); + + rc = fcntl(*p_env->p_fdPipeRead, F_SETFL, flg | O_NONBLOCK); + ASSERT_SYS(rc != -1, "fcntl"); + + rc = pthread_create( p_thread, NULL, fmbRecvThread, p_env); + ASSERT_USR(rc == 0, "pthread_create"); + + FMB_FUNC(FALSE); + return *p_env->p_fdPipeRead; +} + +/** +* @brief Information on the generated event is acquired. +* @param[out] evnt generated event +* @param[in] fdPipeRead +* @return TRUE Event is exist. +* @return FALSE Event is not exist. +* @note None +* @attention None +* @attention None +*/ +BOOL FmbRecvGetEventInfo(struct RecvEventArgType *evnt, int fdPipeRead) +{ + ssize_t size; + + FMB_FUNC(TRUE); + + size = read(fdPipeRead, evnt, sizeof(struct RecvEventArgType)); + if(size == 0){ + FMB_FUNC(FALSE); + return FALSE; + } + + if((size == -1) && (errno == EAGAIN)){ + FMB_FUNC(FALSE); + return FALSE; + } + + ASSERT_SYS(size != -1, "read"); + + LogFmbEvent((int *)evnt, sizeof(struct RecvEventArgType) / sizeof(int)); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The ioctl wrapper +* @param[in] req request +* @param[in] pvArg argument +* @return None +* @note None +* @attention None +*/ +void fmbRecvDrvIoctl(int fd, int req, void *pvArg) +{ + int rc; + + FMB_FUNC(TRUE); + + LogFmb("ioctl request\t0x%08x", req); + rc = ioctl(fd, req, pvArg); + ASSERT_SYS(rc != -1, "ioctl()"); + + FMB_FUNC(FALSE); +} + + +/** +* @brief Thread that receives event from FmbLSI. +* @param[in] arg Ignored +* @return NULL +* @note None +* @attention None +*/ +void *fmbRecvThread(void *arg) +{ + struct fmb_factor_info factor_info; + int fmbfd; + fd_set efds, exceptfds; + int rc; + struct RecvEnv *envp = (struct RecvEnv*) arg; + char *driverPath = envp->p_devicePath; + + InitFuncTraceRecv(envp->deviceNum); + + FMB_FUNC(TRUE); + + fmbfd = open(driverPath,O_RDWR); //The driver is opened. + ASSERT_SYS(fmbfd >= 0, "open()"); + LogFmb("fmbfd\t%d", fmbfd); + + FD_ZERO(&exceptfds); + FD_SET(fmbfd, &exceptfds); + + while(TRUE){ + memcpy(&efds, &exceptfds, sizeof(fd_set)); + LogFmb("select\tbefore"); + rc = select(fmbfd + 1, NULL, NULL, &efds, NULL); + LogFmb("select\treturned"); + ASSERT_SYS(rc != -1, "select()"); + ASSERT_USR(rc != 0, "select() returned 0"); + + if(g_dbg.isNotRecMessages == FALSE) { + if(FD_ISSET(fmbfd, &efds)){ + memset(&factor_info, 0, sizeof(factor_info)); + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_FACTOR, &factor_info); + ASSERT_USR(factor_info.factor != FMB_FACTOR_NONE, "Factor is nothing"); + + sendEventToMainThread(fmbfd, &factor_info, envp); + } + } + } + close(fmbfd); + FMB_FUNC(TRUE); + return NULL; +} + +/** +* @brief The generated event is notified to the main thread. +* @param[in] fmbfd +* @param[in] factor_info Generated event factor. +* @param[in] p_RecvEnv +* @return None +* @note None +* @attention None +*/ +static void sendEventToMainThread(int fmbfd, + const struct fmb_factor_info *factor_info, + struct RecvEnv *p_RecvEnv) +{ + struct fmb_cmd_ack_sys_info cmd_ack_info; + struct fmb_msg_sys_info msg_sys_info; + struct fmb_msg_video_info msg_video_info; + struct fmb_msg_audio_info msg_audio_info; + struct fmb_async_info async_info; + struct VideoMsgType *vMsg; + struct AudioMsgType *aMsg; + struct XerrorMsgType *xMsg; + char vMsgBuff[FMB_VIDEO_MSG_REG_SIZE]; + char aMsgBuff[FMB_AUDIO_MSG_REG_SIZE]; + char xMsgBuff[FMB_XERROR_INFO_REG_SIZE]; + struct RecvEventArgType evnt; + unsigned long prm_id[9]; + unsigned short prm_data[9]; + struct fmb_param_info param_info; + unsigned long strem_size; + int fdPipeWrite; + struct FMBDeviceInfo *p_deviceInfo; + struct StreamThread *p_StreamThread; + + FMB_FUNC(TRUE); + + fdPipeWrite = *p_RecvEnv->p_fdPipeWrite; + evnt.devNum = p_RecvEnv->deviceNum; + p_deviceInfo = FmbGetDevInfo(p_RecvEnv->deviceNum); + + if((factor_info->factor & FMB_FACTOR_XERROR) != 0){ //XERROR + memset(&async_info, 0, sizeof(async_info)); + async_info.type = FMB_TYPE_ASYNC_XERROR; + async_info.data = (unsigned short*)xMsgBuff; + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_ASYNC_INFO, &async_info); + xMsg = (struct XerrorMsgType *)async_info.data; + fprintOut(stdout, "\x1b[31mERROR: In MB86(dev-%d), a fatal error occurred. (0x%04x%04x, 0x%04x%04x, 0x%04x%04x)\x1b[m\n", + p_RecvEnv->deviceNum, + xMsg->M_ERROR_INFO_H, xMsg->M_ERROR_INFO_L, + xMsg->V_ERROR_INFO_H, xMsg->V_ERROR_INFO_L, + xMsg->A_ERROR_INFO_H, xMsg->A_ERROR_INFO_L); + LogFmb("ERROR: In MB86(dev-%d), a fatal error occurred. (0x%04x%04x, 0x%04x%04x, 0x%04x%04x)", + p_RecvEnv->deviceNum, + xMsg->M_ERROR_INFO_H, xMsg->M_ERROR_INFO_L, + xMsg->V_ERROR_INFO_H, xMsg->V_ERROR_INFO_L, + xMsg->A_ERROR_INFO_H, xMsg->A_ERROR_INFO_L); + exit(2); + } + + if((factor_info->factor & FMB_FACTOR_CACK_SYS) != 0){ //System Cmd Ack + memset(&cmd_ack_info, 0, sizeof(cmd_ack_info)); + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_SYS_CMD_ACK, &cmd_ack_info); + if(cmd_ack_info.sub_id != 0){ + fprintOut(stdout, "\x1b[31mERROR: The system command terminated abnormally. (cack_ID=0x%04x, sub_cack_ID=0x%04x)\x1b[m\n", + cmd_ack_info.id, cmd_ack_info.sub_id); + LogFmb("ERROR: The system command terminated abnormally. (cack_ID=0x%04x, sub_cack_ID=0x%04x)", + cmd_ack_info.id, cmd_ack_info.sub_id); + exit(2); + } + TraceRecv(evnt.devNum, "RCV_SYSACK\tid=0x%x\tsub_id=0x%x", cmd_ack_info.id, cmd_ack_info.sub_id); + evnt.dev = FMBEnmCoreDeviceSystem; + evnt.evnt = FMBEnmCoreFromAck; + evnt.WaitDetail.SysAck.id = cmd_ack_info.id; + evnt.WaitDetail.SysAck.sub_id = cmd_ack_info.sub_id; + if ( cmd_ack_info.id == 0x0a ){ + p_StreamThread = &p_deviceInfo->t_StreamThread_A[FMBEnmStreamSend]; + FmbSetSystemCmdAck(FMBEnmStreamSend, p_StreamThread); + } + FmbRecvSendEvent(&evnt, fdPipeWrite); + } + + if((factor_info->factor & FMB_FACTOR_MSG_SYS) != 0){ //System Msg + memset(&msg_sys_info, 0, sizeof(msg_sys_info)); + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_SYS_MSG, &msg_sys_info); + TraceRecv(evnt.devNum, "RCV_SYSMSG\tid=0x%x\tsub_id=0x%x\tbody=%x", msg_sys_info.id, msg_sys_info.sub_id, msg_sys_info.body); + + evnt.dev = FMBEnmCoreDeviceSystem; + evnt.evnt = FMBEnmCoreFromMsg; + evnt.WaitDetail.SysMsg.id = msg_sys_info.id; + evnt.WaitDetail.SysMsg.sub_id = msg_sys_info.sub_id; + evnt.WaitDetail.SysMsg.body = msg_sys_info.body; + if ( msg_sys_info.id == 0x02 && msg_sys_info.sub_id == 0x01 + && msg_sys_info.body == 0x1000 ){ + + param_info.prm_num = 2; + prm_id[0] = 0x0000000b; //M STREAM_SIZE_H + prm_id[1] = 0x0000000c; //M STREAM_SIZE_L + param_info.prm_id = prm_id; + param_info.prm_data = prm_data; + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_PARAM, ¶m_info); + strem_size = prm_data[0]<<16 | prm_data[1]; + p_StreamThread = &p_deviceInfo->t_StreamThread_A[FMBEnmStreamRcv]; + FmbSetStreamSize(FMBEnmStreamRcv,strem_size,p_StreamThread); + } + if ( msg_sys_info.id == 0x02 && msg_sys_info.sub_id == 0x01 + && msg_sys_info.body == 0x0001 ){ + param_info.prm_num = 9; + prm_id[0] = 0x00010003; //V IPIC_PAKET_NUM + prm_id[1] = 0x00010004; //V GOP_PTS_H + prm_id[2] = 0x00010005; //V GOP_PTS_L + prm_id[3] = 0x00010006; //V GOP_SPN_H + prm_id[4] = 0x00010007; //V GOP_SPN_L + prm_id[5] = 0x00010008; //V IPIC_PTS_H + prm_id[6] = 0x00010009; //V IPIC_PTS_L + prm_id[7] = 0x0001000a; //V PIC_NUM_H + prm_id[8] = 0x0001000b; //V PIC_NUM_L + param_info.prm_id = prm_id; + param_info.prm_data = prm_data; + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_PARAM, ¶m_info); + gprintOut(" IPIC_PACKET_NUM:0x%04x, GOP_PTS_H:0x%04x, GOP_PTS_L:0x%04x \n" + " GOP_SPN_H:0x%04x GOP_SPN_L:0x%04x IPIC_PTS_H:0x%04x, IPCI_PTS_L:0x%04x \n" + " PIC_NUM_H:0x%04x PIC_NUM_L:0x%04x \n" , param_info.prm_data[0], param_info.prm_data[1], + param_info.prm_data[2], param_info.prm_data[3], param_info.prm_data[4], param_info.prm_data[5], + param_info.prm_data[6], param_info.prm_data[7], param_info.prm_data[8]); + } + FmbRecvSendEvent(&evnt, fdPipeWrite); + } + + if((factor_info->factor & FMB_FACTOR_MSG_VIDEO) != 0){ //Video Msg + memset(&msg_video_info, 0, sizeof(msg_video_info)); + msg_video_info.msg = (unsigned short*)vMsgBuff; + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_VIDEO_MSG, &msg_video_info); + vMsg = (struct VideoMsgType *)msg_video_info.msg; + if (vMsg->FRAME_UPDATE_FLAG == 1){ + p_StreamThread = &p_deviceInfo->t_StreamThread_A[FMBEnmStreamSend]; + FmbSetStreamFrameUpdate(FMBEnmStreamSend, p_StreamThread); + } + TraceRecvDump(evnt.devNum, "RCV_VIDEOMSG_DUMP", msg_video_info.msg, sizeof(vMsgBuff)); + + TraceRecv(evnt.devNum, "\ +RCV_VIDEOMSG\tVALID=%x\tCMD_INVALID=%x\tMODE=%x\tSUBMODE=%x\tSEQ_END=%x\tTFRFF=%x\tV_PTS_VALID_FLAG=%x\t\ +FRAME_UPDATE_FLAG=%x\tV_ERROR_LEVEL_H=%x\tV_ERROR_LEVEL_L=%x\tFRAME_COUNT_GOP=%x\tVSYNC_COUNT_H=%x\tVSYNC_COUNT_L=%x\tV_PTS_H=%x\t\ +V_PTS_L=%x\tV_EOS=%x\tPIC_TYPE=%x\tVSEQ_NUM=%x\tV_FRAME_RATE_CODE=%x\tV_ASPECT_RATIO_IDC=%x\tV_PIC_WIDTH_IN_MBS=%x\t\ +V_PIC_HEIGHT_IN_MBS=%x\tVUDATA_LENGTH=%x\tV_BITRATE_H=%x\tV_BITRATE_L=%x", + vMsg->VALID, vMsg->CMD_INVALID,vMsg->MODE, vMsg->SUBMODE, vMsg->SEQ_END, vMsg->TFRFF, vMsg->V_PTS_VALID_FLAG, + vMsg->FRAME_UPDATE_FLAG, vMsg->V_ERROR_LEVEL_H, vMsg->V_ERROR_LEVEL_L, vMsg->FRAME_COUNT_GOP, vMsg->VSYNC_COUNT_H, + vMsg->VSYNC_COUNT_L,vMsg->V_PTS_H, vMsg->V_PTS_L,vMsg->V_EOS, vMsg->PIC_TYPE, vMsg->VSEQ_NUM, + vMsg->V_FRAME_RATE_CODE, vMsg->V_ASPECT_RATIO_IDC,vMsg->V_PIC_WIDTH_IN_MBS,vMsg->V_PIC_HEIGHT_IN_MBS, + vMsg->VUDATA_LENGTH,vMsg->V_BITRATE_H,vMsg->V_BITRATE_L); + + if(vMsg->CMD_INVALID == 1){ + fprintOut(stdout, "\x1b[31mERROR: Invalid Video Command. (CMD_INVALID=1)\x1b[m\n"); + LogFmb("ERROR: Invalid Video Command. (CMD_INVALID=1)"); + exit(2); + } + + if(vMsg->MODE == 0xF0){ + fprintOut(stdout, "\x1b[31mERROR: Invalid Video parametaer. (MODE=0xF0)\x1b[m\n"); + LogFmb("ERROR: Invalid Video parametaer. (MODE=0xF0)"); + exit(2); + } + + if((vMsg->V_ERROR_LEVEL_H != 0) || (vMsg->V_ERROR_LEVEL_L != 0)){ + fprintOut(stdout, "\x1b[31mERROR: Decode error occurred. (0x%04x%04x) Please check the input stream.\x1b[m\n", + vMsg->V_ERROR_LEVEL_H, vMsg->V_ERROR_LEVEL_L); + LogFmb("ERROR: Decode error occurred. (0x%04x%04x) Please check the input stream.", + vMsg->V_ERROR_LEVEL_H, vMsg->V_ERROR_LEVEL_L); + } + + evnt.dev = FMBEnmCoreDeviceVideo; + evnt.evnt = FMBEnmCoreFromMsg; + evnt.WaitDetail.VideoMsg.mode = vMsg->MODE; + evnt.WaitDetail.VideoMsg.submode = vMsg->SUBMODE; + evnt.WaitDetail.VideoMsg.seq_end = vMsg->SEQ_END; + + FmbRecvSendEvent(&evnt, fdPipeWrite); + } + + if((factor_info->factor & FMB_FACTOR_MSG_AUDIO) != 0){ //Audio Msg + memset(&msg_audio_info, 0, sizeof(msg_audio_info)); + msg_audio_info.msg = (unsigned short*)aMsgBuff; + fmbRecvDrvIoctl(fmbfd, FMB_API_GET_AUDIO_MSG, &msg_audio_info); + TraceRecvDump(evnt.devNum, "RCV_AUDIOMSG_DUMP", (unsigned short *)aMsgBuff, sizeof(vMsgBuff)); + aMsg = (struct AudioMsgType *)msg_audio_info.msg; + TraceRecv(evnt.devNum, "\ +RCV_AUDIOMSG\tVALID=0x%x\tA_CH=0x%x\tA_MUTE_ST=0x%x\tA_MUTE=0x%x\t\ +A_PTS_VALID_FLAG=0x%x\tAFRAME_UPDATE_FLAG=0x%x\tAV_SYNC=0x%x\tAERROR_H=0x%x\tAERROR_L=0x%x\t\ +A_PTS_H=0x%x\tA_PTS_L=0x%x\tA_BITSTREAM_INFO[0]=0x%x\tA_BITSTREAM_INFO[1]=0x%x\t\ +A_BITSTREAM_INFO[2]=0x%x\tA_BITSTREAM_INFO[3]=0x%x", + aMsg->VALID, aMsg->A_CH, aMsg->A_MUTE_ST, aMsg->A_MUTE, aMsg->A_PTS_VALID_FLAG, + aMsg->AFRAME_UPDATE_FLAG, aMsg->AV_SYNC, aMsg->AERROR_H, aMsg->AERROR_L, + aMsg->A_PTS_H, aMsg->A_PTS_L, aMsg->A_BITSTREAM_INFO[0], aMsg->A_BITSTREAM_INFO[1], + aMsg->A_BITSTREAM_INFO[2], aMsg->A_BITSTREAM_INFO[3]); + if(g_dbg.isAV_SYNC_Exit){ + ASSERT_USR(aMsg->AV_SYNC == 0, "AV_SYNC != 0"); + } + + evnt.dev = FMBEnmCoreDeviceAudio; + evnt.evnt = FMBEnmCoreFromMsg; + evnt.WaitDetail.AduioMsg.mute = aMsg->A_MUTE_ST; + evnt.WaitDetail.AduioMsg.ch = aMsg->A_CH; + + FmbRecvSendEvent(&evnt, fdPipeWrite); + } + if((factor_info->factor & FMB_FACTOR_EDERR) != 0){ //EDERR + fprintOut(stdout, "\x1b[31mERROR: Failed in receiving the DMA.\x1b[m\n"); + LogFmb("ERROR: Failed in receiving the DMA."); + } + if((factor_info->factor & FMB_FACTOR_DDERR) != 0){ //DDERR + fprintOut(stdout, "\x1b[31mERROR: Failed in sending the DMA.\x1b[m\n"); + LogFmb("ERROR: Failed in sending the DMA."); + } + + FMB_FUNC(FALSE); + return; +} + +/** +* @brief The event is transmitted. +* @param[in] evnt Event information +* @param[in] fdPipeWrite +* @return None +* @note None +* @attention None +*/ +void FmbRecvSendEvent(const struct RecvEventArgType *evnt, int fdPipeWrite) +{ + int writtenSize; + + FMB_FUNC(TRUE); + + writtenSize = write(fdPipeWrite, evnt, sizeof(struct RecvEventArgType)); + ASSERT_SYS(writtenSize == sizeof(struct RecvEventArgType), "write()"); + + FMB_FUNC(FALSE); + return; +} + diff --git a/fmb_player_apl/src/com/FmbComResolution.c b/fmb_player_apl/src/com/FmbComResolution.c new file mode 100644 index 0000000..db40830 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComResolution.c @@ -0,0 +1,196 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h"
+
+ +static const enum FMBVideoResolutionEnum rsltnMapping[] = { + FMBEnmVideoRsltn_1920_1080_60p, // MMUX_RESOLUTION_1080P_60, + FMBEnmVideoRsltn_1920_1080_59p, // MMUX_RESOLUTION_1080P_59, + FMBEnmVideoRsltn_1920_1080_50p, // MMUX_RESOLUTION_1080P_50, + FMBEnmVideoRsltn_1920_1080_60i, // MMUX_RESOLUTION_1080I_60, + FMBEnmVideoRsltn_1920_1080_59i, // MMUX_RESOLUTION_1080I_59, + FMBEnmVideoRsltn_1920_1080_50i, // MMUX_RESOLUTION_1080I_50, + FMBEnmVideoRsltn_NONE, // MMUX_RESOLUTION_1080P_24, + FMBEnmVideoRsltn_NONE, // MMUX_RESOLUTION_1080P_23, + FMBEnmVideoRsltn_1280_720_60p, // MMUX_RESOLUTION_720P_60, + FMBEnmVideoRsltn_1280_720_59p, // MMUX_RESOLUTION_720P_59, + FMBEnmVideoRsltn_1280_720_50p, // MMUX_RESOLUTION_720P_50, + FMBEnmVideoRsltn_NONE, // MMUX_RESOLUTION_720P_24, + FMBEnmVideoRsltn_NONE, // MMUX_RESOLUTION_720P_23, + FMBEnmVideoRsltn_720_480_60i, // MMUX_RESOLUTION_480i, + FMBEnmVideoRsltn_720_576_50i, // MMUX_RESOLUTION_576i_50, + FMBEnmVideoRsltn_NONE, // 0x0f + FMBEnmVideoRsltn_NONE, // 0x10 + FMBEnmVideoRsltn_NONE, // 0x11 + FMBEnmVideoRsltn_NONE, // 0x12 + FMBEnmVideoRsltn_NONE, // 0x13 + FMBEnmVideoRsltn_NONE, // 0x14 + FMBEnmVideoRsltn_NONE, // 0x15 + FMBEnmVideoRsltn_NONE, // 0x16 + FMBEnmVideoRsltn_NONE, // 0x17 + FMBEnmVideoRsltn_NONE, // 0x18 + FMBEnmVideoRsltn_NONE, // 0x19 + FMBEnmVideoRsltn_NONE, // 0x1a + FMBEnmVideoRsltn_NONE, // 0x1b + FMBEnmVideoRsltn_NONE, // 0x1c + FMBEnmVideoRsltn_NONE, // 0x1d + FMBEnmVideoRsltn_NONE, // 0x1e + FMBEnmVideoRsltn_NONE, // MMUX_RESOLUTION_UNKNOWN, +};
+
+inline enum FMBVideoResolutionEnum FmbRsltnMmux2Fmb(enum MMUX_RESOLUTION resolution_Mmux)
+{
+ return rsltnMapping[resolution_Mmux];
+}
+ +void FmbSetVideoFormat(enum FMBVideoResolutionEnum resolution_Fmb, enum FMBFuncModeEnum setmode)
+{
+ FMB_FUNC(TRUE); + + switch (resolution_Fmb) {
+ case FMBEnmVideoRsltn_1920_1080_60p:
+ gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_60p; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60p; + break;
+ case FMBEnmVideoRsltn_1920_1080_59p: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_59p; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994p; + break; + case FMBEnmVideoRsltn_1920_1080_50p: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_50p; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_50p; + break; + case FMBEnmVideoRsltn_1920_1080_60i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_60i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60i; + break; + case FMBEnmVideoRsltn_1920_1080_59i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_59i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i; + break; + case FMBEnmVideoRsltn_1920_1080_50i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_50i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_50i; + break; + case FMBEnmVideoRsltn_1440_1080_60i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1440_1080_60i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1440x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60i; + break; + case FMBEnmVideoRsltn_1440_1080_59i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1440_1080_59i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1440x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i; + break; + case FMBEnmVideoRsltn_1440_1080_50i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1440_1080_50i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1440x1080; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_50i; + break; + case FMBEnmVideoRsltn_1280_720_60p: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1280_720_60p; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1280x720; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60p; + break; + case FMBEnmVideoRsltn_1280_720_59p: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1280_720_59p; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1280x720; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994p; + break; + case FMBEnmVideoRsltn_1280_720_50p: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1280_720_50p; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1280x720; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_50p; + break; + case FMBEnmVideoRsltn_720_480_60i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_720_480_60i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt720x480; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_60i; + break; + case FMBEnmVideoRsltn_720_480_59i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_720_480_59i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt720x480; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i; + break; + case FMBEnmVideoRsltn_720_576_50i: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_720_576_50i; + gp_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt720x576; + gp_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_50i; + break; + case FMBEnmVideoRsltn_NONE: + gp_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_NONE; + break; + default: + break; + }
+
+ FMB_FUNC(FALSE);
+}
+
+int FmbAutoSetCurVideoFormat(void)
+{
+ enum MMUXDeviceNumEnum mmuxDevNum_Old; + int codecNumPerBorad; + int codecNum; + struct CodecIO codecIOInfo; + int ret = 0; + + + FMB_FUNC(TRUE); + mmuxDevNum_Old = FmbGetCurMmuxDevNum(); + + codecNumPerBorad = FmbGetDeviceTotal()/FmbGetBoardTotal(); + codecNum = FmbGetCurDeviceNum(); + FmbSetCurMmuxDevNum(codecNum/codecNumPerBorad); + + MmuxGetCodecStatus(FmbGetCurMmuxHd(), codecNum%codecNumPerBorad, &codecIOInfo); + if (codecIOInfo.fgInputConncet) { + FmbSetVideoFormat(FmbRsltnMmux2Fmb(codecIOInfo.inResolution), FMBEnmFuncModeEnc); + } + else { + ret = -1; + } + + FmbSetCurMmuxDevNum(mmuxDevNum_Old); + FMB_FUNC(FALSE);
+
+ return ret;
+}
diff --git a/fmb_player_apl/src/com/FmbComStream.c b/fmb_player_apl/src/com/FmbComStream.c new file mode 100644 index 0000000..74fb7b2 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComStream.c @@ -0,0 +1,957 @@ +/** +* @brief Send the stream data to the MB86-LSI and recive the stream data from the MB86-LSI. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <pthread.h> +#include <unistd.h> +#include <sys/select.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include "FmbCmn.h" + +static void fmbStreamClose(enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread); +static void fmbStreamEnd(enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread); +inline BOOL fmbChkPacketSize(unsigned char* stream_buf , int buf_size , int packet_size , int* offset); + +static void *fmbRecvStreamThread(void *arg); +static void *fmbSendStreamThread(void *arg); + +/** +* @brief Start to the thread of stream. +* @return TRUE +* @return FALSE +* @note None +* @attention None +*/ +BOOL FmbStreamBegin( enum FMBStremThreadEnum threadKind, HANDLE sceHandle ) +{ + int rc; + pthread_attr_t threadAtt; + struct sched_param threadParam; + pthread_t thread; + int max_priority, min_priority, priority; + struct StreamThread *p_StreamThread; + struct FMBComProperty *p_ComProperty; + struct FMBDeviceInfo *p_deviceInfo; + + FMB_FUNC(TRUE); + + p_deviceInfo = FmbGetDevInfo(SceGetDevNum(sceHandle)); + p_StreamThread = &p_deviceInfo->t_StreamThread_A[threadKind]; + p_ComProperty = FmbGetComProperty(SceGetDevNum(sceHandle)); + if (p_StreamThread->fd < 0){ + FMB_FUNC(FALSE); + return FALSE; + } + + if ( p_StreamThread->isThread == TRUE){ + FMB_FUNC(FALSE); + return FALSE; + } + + p_StreamThread->fmbfd = open(p_ComProperty->devicePath , O_RDWR); + ASSERT_SYS(p_StreamThread->fmbfd >= 0, "open()"); + + p_StreamThread->fBuf = malloc(p_StreamThread->fSize); + if ( p_StreamThread->fBuf == NULL ){ + fmbStreamClose(threadKind, p_StreamThread); + FMB_FUNC(FALSE); + return FALSE; + } + + p_StreamThread->isThread = FALSE; + p_StreamThread->isStop = FALSE; + p_StreamThread->isForceStop = FALSE; + p_StreamThread->streamSize = 0; + p_StreamThread->isFrameUpdate = FALSE; + p_StreamThread->isSeqEnd = FALSE; + p_StreamThread->isSystemCmdAck = FALSE; + + rc = pthread_attr_init(&threadAtt); + ASSERT_USR(rc == 0, "pthread_attr_init"); + + rc = pthread_attr_getschedparam (&threadAtt, &threadParam); + ASSERT_USR(rc == 0, "pthread_attr_getschedparam"); + + max_priority = sched_get_priority_max(SCHED_OTHER); + min_priority = sched_get_priority_min(SCHED_OTHER); + priority = p_StreamThread->priority; + + if (priority < min_priority) { + priority = min_priority; + } + else if (max_priority < priority) { + priority = max_priority; + } + + threadParam.__sched_priority = priority; + + rc = pthread_attr_setschedparam(&threadAtt, &threadParam); + ASSERT_USR(rc == 0, "pthread_attr_setschedparam"); + + rc = pthread_attr_setdetachstate(&threadAtt , PTHREAD_CREATE_DETACHED); + ASSERT_USR(rc == 0, "pthread_attr_setdetachstate"); + + if (threadKind == FMBEnmStreamRcv) { + p_StreamThread->start_routine = fmbRecvStreamThread; + } + else { + p_StreamThread->start_routine = fmbSendStreamThread; + } + + rc = pthread_create( &thread, + &threadAtt, + p_StreamThread->start_routine, + p_StreamThread); + ASSERT_USR(rc == 0, "pthread_create"); + pthread_attr_destroy(&threadAtt); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Thread that receives stream from the MB86 LSI. +* @param[in] arg Ignored +* @return NULL +* @note None +* @attention None +*/ +static void *fmbRecvStreamThread(void *arg) +{ + int r_len; + int w_len; + int totalLen; + int ps_size=0; + int stream_size=0; + char* err_cause; + BOOL stream_size_wait=TRUE; + int pChk_offset=0; + BOOL pChk; + int pChkCnt=0; + BOOL filewrite=TRUE; + int pre_stream_size=0; + int diff_stream_size=0; + int diff_last_size=0; + __off64_t truncate_length; + enum FMBDeviceNumEnum deviceNum; + struct StreamThread *p_StreamThread; + struct FMBComProperty *p_ComProperty; + + p_StreamThread = (struct StreamThread *) arg; + + InitFuncTraceRecvStream(p_StreamThread->deviceNum); + + FMB_FUNC(TRUE); + + p_StreamThread->isThread = TRUE; + deviceNum = p_StreamThread->deviceNum; + p_ComProperty = FmbGetComProperty(deviceNum); + + LogFmb("fmbfd\t%d", p_StreamThread->fmbfd); + + ftruncate64(p_StreamThread->fd,0); + lseek64(p_StreamThread->fd,0,SEEK_SET); + + if ( p_ComProperty->tsFormat[FMBEnmOutputTsPacket] == FMBEnmTsFormat188 ){ + ps_size = 188; + } + else{ + ps_size = 192; + } + + totalLen = 0; + + while(TRUE){ + if ( (p_StreamThread->isForceStop ==TRUE ) || + + (p_StreamThread->isStop ==TRUE && + stream_size_wait == TRUE && + p_StreamThread->streamSize <= stream_size) || + + (p_StreamThread->isStop ==TRUE && + stream_size_wait == FALSE) ) { + + LogFmb("[fmbRecvStreamThread]Stream(from LSI) read end.........."); + LogFmb("[fmbRecvStreamThread]Stream Size = %d",stream_size); + + if (stream_size_wait == FALSE ) { + LogFmb("[fmbRecvStreamThread]Stream size no wait........."); + break; + } + + r_len = read(p_StreamThread->fmbfd, + p_StreamThread->fBuf, + 0); + if (r_len < 0) { + if (p_StreamThread->isForceStop ==TRUE) { + LogFmb("[fmbRecvStreamThread]Stream read error skip (Force Stop)........."); + break; + } + fprintOut(stdout, "\x1b[31mERROR: [dev-%d]Failed in receiving the stream.\x1b[m\n", deviceNum); + LogFmb("ERROR: Failed in receiving the stream."); + } + //end.. + break; + } + if (stream_size_wait == FALSE ) { + usleep(300000); + continue; + } + + r_len = read(p_StreamThread->fmbfd, + p_StreamThread->fBuf, + p_StreamThread->fSize); + if (r_len < 0) { + if (p_StreamThread->isForceStop ==TRUE) { + LogFmb("[fmbRecvStreamThread]Stream read error skip (Force Stop)........."); + continue; + } + fprintOut(stdout, "\x1b[31mERROR: [dev-%d]Failed in receiving the stream.\x1b[m\n", deviceNum); + LogFmb("ERROR: Failed in receiving the stream."); + stream_size_wait = FALSE; + continue; + } + + pre_stream_size = stream_size; + totalLen += r_len; + stream_size += totalLen/ps_size; + totalLen = totalLen%ps_size; + + if( filewrite ){ + if( (p_StreamThread->streamSize !=0 ) && + (p_StreamThread->streamSize < stream_size) ){ + LogFmb("[fmbRecvStreamThread]pre_stream_size = %d",pre_stream_size); + LogFmb("[fmbRecvStreamThread]r_len = %d",r_len); + diff_stream_size = stream_size - pre_stream_size; + diff_last_size = stream_size - p_StreamThread->streamSize ; + r_len = (diff_stream_size - diff_last_size) * ps_size; + LogFmb("[fmbRecvStreamThread]diff_stream_size = %d",diff_stream_size); + LogFmb("[fmbRecvStreamThread]diff_last_size = %d",diff_last_size); + LogFmb("[fmbRecvStreamThread]stream_size = %d",stream_size); + LogFmb("[fmbRecvStreamThread]Stream Size = %d",p_StreamThread->streamSize); + LogFmb("[fmbRecvStreamThread]r_len = %d",r_len); + + filewrite=FALSE; + } + + if ( r_len > 0 ){ + pChk = fmbChkPacketSize(p_StreamThread->fBuf, + r_len,ps_size,&pChk_offset); + if( pChk == FALSE ){ + pChkCnt++; + fprintOut(stdout, "\x1b[31mERROR(dev-%d): Output packet size unmatch occurred.(the %dth packet) Please check settings for packet size and output file.\x1b[m\n" , deviceNum, (stream_size + ( (r_len - pChk_offset)/ps_size )) ); + LogFmb("ERROR: Output packet size unmatch occurred.(the %dth packet) Please check settings for packet size and output file." , (stream_size + ( (r_len - pChk_offset)/ps_size ))); + if(g_dbg.isTS_PSIZE_Exit){ + ASSERT_USR(FALSE, "Output packet size unmatch occurred."); + } + while (pChk_offset > ps_size){ + pChk = fmbChkPacketSize(p_StreamThread->fBuf, + r_len,ps_size,&pChk_offset); + if( pChk == FALSE ){ + pChkCnt++; + fprintOut(stdout, "\x1b[31mERROR(dev-%d): Output packet size unmatch occurred.(the %dth packet) Please check settings for packet size and output file.\x1b[m\n" , deviceNum, (stream_size + ( (r_len - pChk_offset)/ps_size )) ); + LogFmb("ERROR: Output packet size unmatch occurred.(the %dth packet) Please check settings for packet size and output file." , (stream_size + ( (r_len - pChk_offset)/ps_size ))); + } + } + } + ASSERT_USR(pChkCnt < FMB_STREAM_PACKET_CHK_TH, "Too many packet size unmatch occurred."); + + w_len = write(p_StreamThread->fd, + p_StreamThread->fBuf, + r_len); + if (w_len < 0) { + err_cause = strerror(errno); + LogFmb("write error(%d):%s",errno, err_cause); + ASSERT_USR(FALSE, "write"); + break; + } + + }else{ + truncate_length = (__off64_t)p_StreamThread->streamSize * (__off64_t)ps_size; + LogFmb("[fmbRecvStreamThread] truncate_length = %llu",truncate_length); + w_len = ftruncate(p_StreamThread->fd, + truncate_length); + if (w_len < 0) { + err_cause = strerror(errno); + LogFmb("ftruncate error(%d):%s",errno, err_cause); + ASSERT_USR(FALSE, "ftruncate"); + break; + } + } + } + } + + fmbStreamEnd(FMBEnmStreamRcv, p_StreamThread); + FMB_FUNC(FALSE); + return NULL; +} + +/** +* @brief Thread that sends stream from the MB86 LSI. +* @param[in] arg Ignored +* @return NULL +* @note None +* @attention None +*/ +static void *fmbSendStreamThread(void *arg) +{ + int r_len; + int w_len; + int totalLen; + int ps_size=0; + int stream_size=0; + char* err_cause; + int pChk_offset=0; + BOOL pChk; + int pChkCnt=0; + BOOL normal_write = TRUE; + int endstreamLen; + enum FMBDeviceNumEnum deviceNum; + struct StreamThread *p_StreamThread; + struct FMBComProperty *p_ComProperty; + + p_StreamThread = (struct StreamThread *) arg; + + InitFuncTraceSendStream(p_StreamThread->deviceNum); + + FMB_FUNC(TRUE); + + p_StreamThread->isThread = TRUE; + deviceNum = p_StreamThread->deviceNum; + p_ComProperty = FmbGetComProperty(deviceNum); + + LogFmb("fmbfd\t%d", p_StreamThread->fmbfd); + + if ( p_ComProperty->tsFormat[FMBEnmInputTsPacket] == FMBEnmTsFormat188 ){ + ps_size = 188; + } + else{ + ps_size = 192; + } + + totalLen = 0; + endstreamLen =0; + + //start_position + if (p_StreamThread->fileStartPos!=0){ + lseek64(p_StreamThread->fd, + p_StreamThread->fileStartPos, + SEEK_SET); + } + //end_position + if (p_StreamThread->fileEndPos!=0){ + endstreamLen = p_StreamThread->fileEndPos /ps_size; + } + + while(TRUE){ + + if ( (p_StreamThread->isForceStop ==TRUE ) || + (p_StreamThread->isStop ==TRUE ) ) { + + LogFmb("[fmbSendStreamThread]Stream(from LSI) write end.........."); + LogFmb("[fmbSendStreamThread]Stream Size = %d",stream_size); + + if ( normal_write == FALSE ) { + LogFmb("[fmbSendStreamThread] write ng end........."); + break; + } + + w_len = write(p_StreamThread->fmbfd, + p_StreamThread->fBuf, + 0); + if (w_len < 0) { + if( p_StreamThread->isForceStop ==TRUE ){ + LogFmb("[fmbSendStreamThread]Stream write error skip (Force Stop)........."); + break; + } + switch (p_ComProperty->currentRequest){ + case FMBEnmReqStop : + LogFmb("[fmbSendStreamThread]Stream write error skip (Stop)........."); + break; + default: + ASSERT_USR(FALSE, "write0"); + break; + } + break; + } + + //end.. + break; + } + + if (normal_write == FALSE ) { + usleep(300000); + continue; + } + + r_len = read(p_StreamThread->fd, + p_StreamThread->fBuf, + p_StreamThread->fSize); + if (r_len < 0) { + err_cause = strerror(errno); + LogFmb("read error(%d):%s",errno, err_cause); + ASSERT_USR(FALSE, "read"); + break; + } + if (r_len == 0) { + LogFmb("[fmbSendStreamThread]File read end.........."); + FmbSetStreamStop(FMBEnmStreamSend, p_StreamThread); + continue; + } + + + w_len = write(p_StreamThread->fmbfd, + p_StreamThread->fBuf, + r_len); + + if (w_len < 0) { + if( p_StreamThread->isForceStop ==TRUE ){ + LogFmb("[fmbSendStreamThread]Stream write error skip (Force Stop)........."); + continue; + } + switch (p_ComProperty->currentRequest){ + case FMBEnmReqStop : + LogFmb("[fmbSendStreamThread]Stream write error skip (Stop)........."); + continue; + break; + default: + break; + } + fprintOut(stdout, "\x1b[31mERROR: Failed in sending the stream.\x1b[m\n"); + LogFmb("ERROR: Failed in sending the stream."); + normal_write = FALSE; + continue; + } + + pChk = fmbChkPacketSize(p_StreamThread->fBuf, + w_len,ps_size,&pChk_offset); + if( pChk == FALSE ){ + pChkCnt++; + fprintOut(stdout, "\x1b[31mERROR: Input packet size unmatch occurred.(the %dth packet) Please check settings for packet size and input file.\x1b[m\n" , (stream_size + ( (w_len - pChk_offset)/ps_size ))); + LogFmb("ERROR: Input packet size unmatch occurred.(the %dth packet) Please check settings for packet size and input file." , (stream_size + ( (w_len - pChk_offset)/ps_size ))); + if(g_dbg.isTS_PSIZE_Exit){ + ASSERT_USR(FALSE, "Input packet size unmatch occurred."); + } + while (pChk_offset > ps_size){ + pChk = fmbChkPacketSize(p_StreamThread->fBuf, + w_len,ps_size,&pChk_offset); + if( pChk == FALSE ){ + pChkCnt++; + fprintOut(stdout, "\x1b[31mERROR: Input packet size unmatch occurred.(the %dth packet) Please check settings for packet size and input file.\x1b[m\n" , (stream_size + ( (w_len - pChk_offset)/ps_size ))); + LogFmb("ERROR: Input packet size unmatch occurred.(the %dth packet) Please check settings for packet size and input file." , (stream_size + ( (w_len - pChk_offset)/ps_size ))); + } + } + } + ASSERT_USR(pChkCnt < FMB_STREAM_PACKET_CHK_TH, "Too many packet size unmatch occurred."); + + totalLen += r_len; + stream_size += totalLen/ps_size; + + switch (p_ComProperty->setMode){ + case FMBEnmFuncModeDec : + if ( (p_ComProperty->isInternalDecodeStatus != TRUE) && + (p_StreamThread->isFrameUpdate == TRUE ) ) { + LogFmb("[fmbSendStreamThread]Dec 1pic end.........."); + FmbSetStreamStop(FMBEnmStreamSend, p_StreamThread); + continue; + } + break; + default: + break; + } + totalLen = totalLen%ps_size; + if ( (endstreamLen != 0) && (stream_size > endstreamLen) ) { + LogFmb("[fmbSendStreamThread]Reached fileEndPos .........."); + FmbSetStreamStop(FMBEnmStreamSend, p_StreamThread); + continue; + } + + } + + + while(TRUE){ + if (p_ComProperty->currentRequest == FMBEnmReqPause || + p_ComProperty->currentRequest == FMBEnmReqStartDecFrameAdvance){ + LogFmb("[fmbSendStreamThread] currentRequest=%d",p_ComProperty->currentRequest); + usleep(300000); + continue; + } + break; + } + + fmbStreamEnd(FMBEnmStreamSend, p_StreamThread); + FMB_FUNC(FALSE); + + pthread_exit(EXIT_SUCCESS); +} + +/** +* @brief ReSet the stream. +* @param hScet Scenario handle +* @return None +* @note None +* @attention None +*/ +void FmbStreamRest( HANDLE hScet ) +{ + struct FMBDeviceInfo *p_deviceInfo; + + FMB_FUNC(TRUE); + + + p_deviceInfo = FmbGetDevInfo(SceGetDevNum(hScet)); + + if (p_deviceInfo->t_StreamThread_A[FMBEnmStreamRcv].isThread == TRUE ){ + p_deviceInfo->t_StreamThread_A[FMBEnmStreamRcv].isForceStop = TRUE; + DrvSetInternal(hScet, FMB_DATA_TYPE_RDMAFLAG , FMB_DATA_DMAFLAG_ON , 0); + LogFmb("[FmbStreamRest] FMBEnmStreamRcv isForceStop is true."); + } + + if (p_deviceInfo->t_StreamThread_A[FMBEnmStreamSend].isThread == TRUE ){ + p_deviceInfo->t_StreamThread_A[FMBEnmStreamSend].isForceStop = TRUE; + DrvSetInternal(hScet, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0); + LogFmb("[FmbStreamRest] FMBEnmStreamSend isForceStop is true."); + } + + + FMB_FUNC(FALSE); + return; +} + +/** +* @brief Set the stop flag for recive stream. +* @param None +* @return None +* @note None +* @attention None +*/ +void FmbSetStreamStop(enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread) +{ + FMB_FUNC(TRUE); + + if ( threadKind >= FMBEnmStreamMAX ){ + FMB_FUNC(FALSE); + return; + } + + if (p_StreamThread->isThread == TRUE ){ + if ( p_StreamThread->isStop != TRUE){ + p_StreamThread->isStop = TRUE; + LogFmb("[FmbSetStreamStop] id=%d isStop is true.",threadKind); + }else{ + p_StreamThread->isForceStop = TRUE; + LogFmb("[FmbSetStreamStop] id=%d isForceStop is true.",threadKind); + } + } + + FMB_FUNC(FALSE); + return; +} + +/** +* @brief Set the stream size. +* @param[in] strm_size stream size. +* @return None +* @note None +* @attention None +*/ +void FmbSetStreamSize(enum FMBStremThreadEnum threadKind,int strm_size, struct StreamThread *p_StreamThread) +{ + + FMB_FUNC(TRUE); + + if ( threadKind != FMBEnmStreamRcv ){ + FMB_FUNC(FALSE); + return; + } + + if (p_StreamThread->isThread == TRUE ){ + p_StreamThread->streamSize = strm_size; + LogFmb("[FmbSetStreamSize] id=%d Stream Size =%d",threadKind,p_StreamThread->streamSize); + if ( strm_size == 0 ){ + p_StreamThread->isStop = TRUE; + LogFmb("[FmbSetStreamSize] id=%d isStop is true.",threadKind); + } + } + + FMB_FUNC(FALSE); + return; +} +/** +* @brief Set the frame update flag. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbSetStreamFrameUpdate( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread ) +{ + FMB_FUNC(TRUE); + + if ( threadKind != FMBEnmStreamSend ){ + FMB_FUNC(FALSE); + return; + } + + if (p_StreamThread->isThread == TRUE ){ + p_StreamThread->isFrameUpdate = TRUE; + LogFmb("[FmbSetStreamFrameUpdate] id=%d FrameUpdate is true.",threadKind); + } + + + FMB_FUNC(FALSE); + return; +} +/** +* @brief Set the sequence end flag. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbSetStreamSeqEnd( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread ) +{ + FMB_FUNC(TRUE); + + if ( threadKind != FMBEnmStreamSend ){ + FMB_FUNC(FALSE); + return; + } + + if (p_StreamThread->isThread == TRUE ){ + p_StreamThread->isSeqEnd = TRUE; + LogFmb("[FmbSetStreamSeqEnd] id=%d Sequence End is true.",threadKind); + } + + FMB_FUNC(FALSE); + return; +} +/** +* @brief Set the sequence end flag. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbSetSystemCmdAck( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread ) +{ + FMB_FUNC(TRUE); + + if ( threadKind != FMBEnmStreamSend ){ + FMB_FUNC(FALSE); + return; + } + + if (p_StreamThread->isThread == TRUE ){ + p_StreamThread->isSystemCmdAck = TRUE; + LogFmb("[FmbSetSystemCmdAck] id=%d System Command Ack.",threadKind); + } + + FMB_FUNC(FALSE); + return; +} + +/** +* @brief Close the stream thread descriptor. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +static void fmbStreamClose( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread) +{ + FMB_FUNC(TRUE); + + if ( threadKind >= FMBEnmStreamMAX ){ + return; + } + + close(p_StreamThread->fmbfd ); + close(p_StreamThread->fd ); + + p_StreamThread->fmbfd = -1; + p_StreamThread->fd = -1; + + LogFmb("[fmbStreamClose] id=%d Close.",threadKind); + + FMB_FUNC(FALSE); + + return; +} +/** +* @brief Finished the stream thread. +* @param[in] threadKind +* @param[in] deviceNum +* @return None +* @note None +* @attention None +*/ +static void fmbStreamEnd( enum FMBStremThreadEnum threadKind, struct StreamThread *p_StreamThread) +{ + struct RecvEventArgType event; + + if ( threadKind >= FMBEnmStreamMAX ){ + return; + } + FMB_FUNC(TRUE); + + fmbStreamClose(threadKind, p_StreamThread); + free(p_StreamThread->fBuf); + + event.devNum = p_StreamThread->deviceNum; + event.dev = FMBEnmCoreDeviceStream; + event.evnt = FMBEnmCoreFromSteamEndMsg; + event.WaitDetail.StreamMsg.id = threadKind; + + p_StreamThread->isThread = FALSE; + LogFmb("[fmbStreamEnd] id=%d isThread is false.",threadKind); + + FmbRecvSendEvent(&event, *p_StreamThread->p_fdPipeWrite); + LogFmb("[fmbStreamEnd]FmbRecvSendEvent dev=%d evnt=%d id=%d",event.dev,event.evnt,event.WaitDetail.StreamMsg.id); + + + FMB_FUNC(FALSE); + + + return; +} +/** +* @brief Open the stream file. +* @param[in] FmbFileTypeEnum file kind(input file : FmbEnmInFile / output file : FmbEnmOutFile) +* @param[in] filepath file path name +* @return FmbEnmFileNormal Normal end +* @return FmbEnmFileAccesFail File access fail +* @return FMBEnmFilePacketSizeFail File Packet size fail +* @return FmbEnmFileOtherFail File Open fail +* @note None +* @attention None +*/ +enum FMBFileResultEnum FmbFileOpen(enum FMBFileEnum fileenum , char* filepath , int* errPacketCnt) +{ + unsigned char* fBuf; + int r_len,chk_len=0,ps_size; + BOOL chkPsize; + + FMB_FUNC(TRUE); + + if (gp_FmbDevInfo->t_StreamThread_A[fileenum].isThread == TRUE){ + FMB_FUNC(FALSE); + return FMBEnmFileExecutionFail; + } + + switch (fileenum){ + case FMBEnmInFile: + //FMB_STREAM_THREAD_SEND + if (gp_FmbDevInfo->t_StreamThread_A[fileenum].fd >= 0){ + close(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd ); + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = -1; + } + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = open(filepath,O_RDONLY|O_LARGEFILE); + break; + case FMBEnmOutFile: + //FMB_STREAM_THREAD_RCV + if (gp_FmbDevInfo->t_StreamThread_A[fileenum].fd >= 0){ + close(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd ); + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = -1; + } + if(FmbIsExistenceFile(filepath)){ + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = open(filepath,O_WRONLY|O_APPEND|O_LARGEFILE,S_IRWXU ); + }else{ + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = open(filepath,O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE,S_IRWXU ); + } + break; + default: + ASSERT_USR(FALSE, "Invalid file kind."); + FMB_FUNC(FALSE); + return FMBEnmFileOtherFail; + } + if (gp_FmbDevInfo->t_StreamThread_A[fileenum].fd < 0){ + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = -1; + switch (errno) { + case EACCES : + FMB_FUNC(FALSE); + return FMBEnmFileAccesFail; + default: + FMB_FUNC(FALSE); + return FMBEnmFileOtherFail; + } + } + + + switch (fileenum){ + case FMBEnmInFile: + fBuf = malloc(FMB_STREAM_THREAD_SEND_FSIZE); + if ( fBuf == NULL ){ + ASSERT_USR(FALSE, "malloc NG."); + close(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd ); + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = -1; + FMB_FUNC(FALSE); + return FMBEnmFileOtherFail; + } + r_len = read(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd, + fBuf, + FMB_STREAM_THREAD_SEND_FSIZE); + if (r_len < 0) { + free(fBuf); + close(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd ); + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = -1; + ASSERT_USR(FALSE, "read"); + FMB_FUNC(FALSE); + return FMBEnmFileOtherFail; + } + + if ( gp_FmbComProperty->tsFormat[FMBEnmInputTsPacket] == FMBEnmTsFormat188 ){ + ps_size = 188; + } + else{ + ps_size = 192; + } + + chkPsize = fmbChkPacketSize(fBuf,r_len,ps_size,&chk_len); + if( chkPsize == FALSE ){ + *errPacketCnt = (r_len - chk_len)/ps_size ; + if (*errPacketCnt ==0 ){ + *errPacketCnt = 1; + } + free(fBuf); + close(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd ); + gp_FmbDevInfo->t_StreamThread_A[fileenum].fd = -1; + FMB_FUNC(FALSE); + return FMBEnmFilePacketSizeFail; + } + lseek(gp_FmbDevInfo->t_StreamThread_A[fileenum].fd,0,SEEK_SET); + free(fBuf); + break; + default: + break; + } + + FMB_FUNC(FALSE); + return FMBEnmFileNormal; +} + +/** +* @brief Get the stream file position. +* @param[in] FMBFilePosEnum file position kind(start : FMBEnmStartPos / end : FMBEnmEndPos) +* @return position +* @note None +* @attention None +*/ +__off64_t FmbGetStrmFilePos(enum FMBFilePosEnum filPoseenum ) +{ + __off64_t position=0; + + FMB_FUNC(TRUE); + + switch(filPoseenum){ + case FMBEnmStartPos: + position = gp_FmbDevInfo->t_StreamThread_A[FMBEnmInFile].fileStartPos; + break; + case FMBEnmEndPos: + position = gp_FmbDevInfo->t_StreamThread_A[FMBEnmInFile].fileEndPos; + break; + default: + break; + } + + FMB_FUNC(FALSE); + return (position); +} + + +/** +* @brief Set the stream file position. +* @param[in] FMBFilePosEnum file position kind(start : FMBEnmStartPos / end : FMBEnmEndPos) +* @return position +* @note None +* @attention None +*/ +void FmbSetStrmFilePos(enum FMBFilePosEnum filPoseenum , __off64_t position) +{ + + FMB_FUNC(TRUE); + + switch(filPoseenum){ + case FMBEnmStartPos: + gp_FmbDevInfo->t_StreamThread_A[FMBEnmInFile].fileStartPos = position ; + break; + case FMBEnmEndPos: + gp_FmbDevInfo->t_StreamThread_A[FMBEnmInFile].fileEndPos = position; + break; + default: + break; + } + + FMB_FUNC(FALSE); + return; +} + + +/** +* @brief Checked the stream of packet size. +* @param[in] stream buffer +* @param[in] stream buffer size +* @param[in] packet size +* @param[in] packet size offset +* @return 0- remain size +* @note None +* @attention None +*/ +inline BOOL fmbChkPacketSize( unsigned char* stream_buf , int buf_size , int packet_size , int* offset) +{ + BOOL hitF; + int remain_size; + + remain_size = buf_size; + + if ( *offset == 0 ){ + hitF = FALSE; + } + else if( *offset < packet_size ){ + hitF = TRUE; + stream_buf+=(packet_size-*offset); + remain_size-=(packet_size-*offset); + } + else{ /* *offset >= packet_size */ + hitF = FALSE; + stream_buf+=(remain_size-*offset); + remain_size=*offset; + } + + while( remain_size >= packet_size ){ + if(*stream_buf==0x47){ + hitF = TRUE; + stream_buf+=packet_size; + remain_size-=packet_size; + } + else{ + if (hitF == TRUE){ + *offset=remain_size; + return FALSE ; + } + stream_buf++; + remain_size--; + } + } + + *offset=remain_size; + return hitF ; +} + diff --git a/fmb_player_apl/src/com/FmbComplayer.c b/fmb_player_apl/src/com/FmbComplayer.c new file mode 100644 index 0000000..2032f95 --- /dev/null +++ b/fmb_player_apl/src/com/FmbComplayer.c @@ -0,0 +1,443 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright ICP Electronics (C) 2010 * + *===============================================*/ + +/** +* @brief +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <signal.h> +#include <sys/select.h> +#include <string.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <sys/utsname.h> + +#include "FmbCmn.h" +#include "FmbAp.h" +#include "Screen.h" + +//Prototype declaration of function + +#ifndef VERSION +#define VERSION "?.?.?.?" +#endif + +#ifdef USE_MMUX // [ USE_MMUX +static char *_ApInfo = "\ + ________________________________________________________\n\ +/_______________________________________________________/|\n\ +| ||\n\ +| HDCapture SDK for HDC series ||\n\ +| firm : %04x-%04x-%04x-%04x ||\n\ +| cpld : %08lx ||\n\ +| fpga : %08lx ||\n\ +| mcu : %08lx ||\n\ +| mmux-driver: %-40s||\n\ +| fmb-driver : %-40s||\n\ +| apl : %-40s||\n\ +| kernel : %-40s||\n\ +|_______________________________________________________|/\n\ +\n\ +"; +#else // USE_MMUX ] [ !USE_MMUX +static char *_ApInfo = "\ + ________________________________________________________\n\ +/_______________________________________________________/|\n\ +| ||\n\ +| HDCapture SDK for HDC series ||\n\ +| firm : %04x-%04x-%04x-%04x ||\n\ +| fmb-driver : %-40s||\n\ +| apl : %-40s||\n\ +| kernel : %-40s||\n\ +|_______________________________________________________|/\n\ +\n\ +"; +#endif // !USE_MMUX ] + +static void FmbCheckAudioFormat(struct fmb_version_info *p_version_info, + enum FMBCheckAudioFormatEnum *p_AudioFormatCheck, + enum FMBAudioFormatEnum *p_encAudioFmt, + enum FMBAudioFormatEnum *p_decAudioFmt); +static void FmbCheckAudioFormatAll(void); +static int FmbIsRequestComplete(void); +static enum FMBRequestEnum ClrCurrentRequest(void); + +//Signal handler +void sigint_handler(int sig); +void OnExit(void); + +/** +* @brief main function +* @param[in] argc Number of command line arguments +* @param[in] argv[] command line arguments +* @return 1:Abnormal end. 0:Normal end. +* @note None +* @attention None +*/ +int main(int argc, char *argv[]) +{ + fd_set rfds, readfds; + int fmbfd = -1; + int rc; + BOOL isContinue; + enum FMBResultEnum fmbRc; + struct sigaction sa; + int index; + struct timeval timeout; + int opt_cnt=0; + struct utsname system_info; + enum FMBDeviceNumEnum deviceNum, deviceNumOld; +#ifdef USE_MMUX // USE_MMUX [ + struct MmuxVer mmuxVer; +#endif // USE_MMUX ] + + + FMB_FUNC(TRUE); + + atexit(OnExit); + + /* -dbg */ + index = FmbgetArg("-dbg", argc , argv); + if (index!=0){ + InitDbg(argv[index]); + opt_cnt++; + } + else{ + InitDbg("0"); + } + + FmbInitInfo(); + + FmbCreatDevInfoAll(); + FmbSetCurDeviceNum(FMBEnmDevice_0); + + + /* oprtion check */ + if ( opt_cnt*2 != argc-1){ + fprintOut(stdout,"Error:The specified argument is abnormal.\n"); + return 0; + } + + + rc = DrvBootAll(); + if (rc != 0) { + fprintOut(stdout,"Error:Failed in the firm boot.\n"); + return 0; + } + + rc = CheckVersionInfo(); + if (rc == FALSE) { + fprintOut(stdout,"Error:Version different.\n"); + return 0; + } + + uname(&system_info); +#ifdef USE_MMUX // [ USE_MMUX + MmuxGetVer(FmbGetCurMmuxHd(), &mmuxVer ); + fprintOut(stdout, _ApInfo, + gp_FmbDevInfo->version_info.firm_ver[0], + gp_FmbDevInfo->version_info.firm_ver[1], + gp_FmbDevInfo->version_info.firm_ver[2], + gp_FmbDevInfo->version_info.firm_ver[3], + mmuxVer.CPLD, + mmuxVer.FPGA, + mmuxVer.MCU, + mmuxVer.driver, + gp_FmbDevInfo->version_info.driver_ver, + VERSION, + system_info.release); +#else // USE_MMUX ] [ !USE_MMUX + fprintOut(stdout, _ApInfo, + gp_FmbDevInfo->version_info.firm_ver[0], + gp_FmbDevInfo->version_info.firm_ver[1], + gp_FmbDevInfo->version_info.firm_ver[2], + gp_FmbDevInfo->version_info.firm_ver[3], + gp_FmbDevInfo->version_info.driver_ver, + VERSION, + system_info.release); +#endif // !USE_MMUX ] + + FmbCheckAudioFormatAll(); + + InitScreens(); //The screen is initialized. + + //signal handler is set. + sa.sa_handler = sigint_handler; + sigemptyset(&sa.sa_mask); + + rc = sigaction(SIGINT, &sa, NULL); + ASSERT_SYS(rc == 0, "sigaction"); + + rc = sigaction(SIGQUIT, &sa, NULL); + ASSERT_SYS(rc == 0, "sigaction"); + + rc = sigaction(SIGILL, &sa, NULL); + ASSERT_SYS(rc == 0, "sigaction"); + + rc = sigaction(SIGABRT, &sa, NULL); + ASSERT_SYS(rc == 0, "sigaction"); + + rc = sigaction(SIGFPE, &sa, NULL); + ASSERT_SYS(rc == 0, "sigaction"); + + rc = sigaction(SIGSEGV, &sa, NULL); + ASSERT_SYS(rc == 0, "sigaction"); + + FD_ZERO(&readfds); + FD_SET(STDIN_FILENO, &readfds); + deviceNumOld = FmbGetCurDeviceNum(); + for (deviceNum = FmbSetFirstDev(); deviceNum != FMBEnmDevice_NONE; deviceNum = FmbSetNextDev()) { + fmbfd = FmbGetRecvReadHd(deviceNum); + FD_SET(fmbfd, &readfds); + } + FmbSetCurDeviceNum(deviceNumOld); + + timeout.tv_sec = 0; + timeout.tv_usec = 100000; + isContinue = TRUE; + while(isContinue){ + memcpy(&rfds, &readfds, sizeof(fd_set)); + rc = select(fmbfd + 1, &rfds, NULL, NULL, &timeout); + ASSERT_SYS(rc != -1, "select()"); + if (timeout.tv_usec == 0) { //timeout + timeout.tv_sec = 0; + timeout.tv_usec = 100000; + } + + if (rc == 0) { + continue; + } + + if(FD_ISSET(STDIN_FILENO, &rfds)){ //If it is a screen input, + isContinue &= OnStdinInput(); + } + + deviceNumOld = FmbGetCurDeviceNum(); + for (deviceNum = FmbSetFirstDev(); deviceNum != FMBEnmDevice_NONE; deviceNum = FmbSetNextDev()) { + fmbfd = FmbGetRecvReadHd(deviceNum); + if(FD_ISSET(fmbfd, &rfds)){ + fmbRc = OnFmbMessage(fmbfd); + if(gp_FmbComProperty->currentRequest != FMBEnmReqNothing){ + gp_FmbComProperty->fmbRc = fmbRc; + switch(fmbRc){ + case FMBEnmResultContinue: + break; + case FMBEnmResultRequestComplete: + ClrCurrentRequest(); + if (FmbIsRequestComplete() == TRUE) { + FmbSetCurDeviceNum(deviceNumOld); + isContinue &= OnFmbRequestResponse(); + } + break; + default: + ASSERT_USR(FALSE, "Invalid return value from OnFmbMessage()."); + break; + } + } + } + } + FmbSetCurDeviceNum(deviceNumOld); + } + + FmbDellDevInfoAll(); + FmbReleaseInfo(); + + SetScreenMode(ScrEnmModeOriginal); + fprintOut(stdout, "Bye.\n"); + + FMB_FUNC(FALSE); + return 0; +} + +/** +* @brief Signal handler +* @param[in] sig Signal +* @return None +* @note None +* @attention None +*/ +void sigint_handler(int sig) +{ + FMB_FUNC(TRUE); + exit(0); + FMB_FUNC(FALSE); +} + +/** +* @brief Handler of exit() function. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void OnExit(void) +{ + FMB_FUNC(TRUE); + SetScreenMode(ScrEnmModeOriginal); + FMB_FUNC(FALSE); +} + +static void FmbCheckAudioFormat(struct fmb_version_info *p_version_info, + enum FMBCheckAudioFormatEnum *p_AudioFormatCheck, + enum FMBAudioFormatEnum *p_encAudioFmt, + enum FMBAudioFormatEnum *p_decAudioFmt) +{ + int index; + enum FMBCheckAudioFormatEnum audioAc3Check; + + + FMB_FUNC(TRUE); + + + for( index=0 ; index<FMBEnmAudioFmtMax ; index++ ){ + p_AudioFormatCheck[index]=FMBEnmAFmtNG; + } + + if ( (p_version_info->firm_ver[3]&0x8000) == 0x0000 ){ + audioAc3Check=FMBEnmAFmtBD; + }else{ + audioAc3Check=FMBEnmAFmtDVB; + } + + switch( (p_version_info->firm_ver[3]&0x00F0)>>4 ){ + case 0x0: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + break; + case 0x1: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtAc3] = audioAc3Check; + break; + case 0x3: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtAac] = FMBEnmAFmtDVB; + break; + case 0x4: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtAc3] = audioAc3Check; + p_AudioFormatCheck[FMBEnmAudioFmtAac] = FMBEnmAFmtDVB; + break; + case 0x5: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtLpcm] = FMBEnmAFmtBD; + break; + case 0x6: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtAc3] = audioAc3Check; + p_AudioFormatCheck[FMBEnmAudioFmtLpcm] = FMBEnmAFmtBD; + break; + case 0x7: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtAac] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtLpcm] = FMBEnmAFmtBD; + break; + case 0x8: + p_AudioFormatCheck[FMBEnmAudioFmtMpeg1l2] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtAc3] = audioAc3Check; + p_AudioFormatCheck[FMBEnmAudioFmtAac] = FMBEnmAFmtDVB; + p_AudioFormatCheck[FMBEnmAudioFmtLpcm] = FMBEnmAFmtBD; + break; + + } + + if (p_AudioFormatCheck[*p_encAudioFmt]==FMBEnmAFmtNG){ + *p_encAudioFmt = FMBEnmAudioFmtMpeg1l2; + } + if (p_AudioFormatCheck[*p_decAudioFmt]==FMBEnmAFmtNG){ + *p_decAudioFmt = FMBEnmAudioFmtMpeg1l2; + } + + FMB_FUNC(FALSE); +} + +static void FmbCheckAudioFormatAll(void) +{ + enum FMBDeviceNumEnum devNum, devNum_old; + struct FMBDeviceInfo *p_deviceInfo; + + FMB_FUNC(TRUE); + + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + p_deviceInfo = FmbGetCurDevInfo(); + + FmbCheckAudioFormat(&p_deviceInfo->version_info, + g_AudioFormatCheck, + &p_deviceInfo->t_Property_A[FMBEnmFuncModeEnc].audioFmt, + &p_deviceInfo->t_Property_A[FMBEnmFuncModeDec].audioFmt); + } + + FmbSetCurDeviceNum(devNum_old); + + FMB_FUNC(FALSE); + +} + +static int FmbIsRequestComplete(void) +{ + enum FMBDeviceNumEnum devNum, devNum_old; + struct FMBComProperty *p_ComProperty; + int ret = TRUE; + + FMB_FUNC(TRUE); + + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + p_ComProperty = FmbGetComProperty( devNum ); + if ( p_ComProperty->currentRequest != FMBEnmReqNothing \ + && p_ComProperty->fmbRc != FMBEnmResultRequestComplete) { + ret = FALSE; + break; + } + } + if (ret == TRUE) { + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + p_ComProperty = FmbGetComProperty( devNum ); + p_ComProperty->fmbRc = FMBEnmResultContinue; + } + } + FmbSetCurDeviceNum(devNum_old); + + FMB_FUNC(FALSE); + + return ret; +} + +static enum FMBRequestEnum ClrCurrentRequest(void) +{ + enum FMBRequestEnum req = FMBEnmReqNothing; + + FMB_FUNC(TRUE); + + req = gp_FmbComProperty->currentRequest; + ASSERT_USR(req != FMBEnmReqNothing, "Request is nothing."); + gp_FmbComProperty->lastRequest = req; + gp_FmbComProperty->currentRequest = FMBEnmReqNothing; + + FMB_FUNC(FALSE); + + return req; +} diff --git a/fmb_player_apl/src/sce/FmbAp.c b/fmb_player_apl/src/sce/FmbAp.c new file mode 100644 index 0000000..db1f626 --- /dev/null +++ b/fmb_player_apl/src/sce/FmbAp.c @@ -0,0 +1,1652 @@ +/** +* @brief The function that becomes API of the MB86 device module is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> +#include "FmbCmn.h" +#include "Screen.h" +#include "SceCmn.h" + +/* + Scenario Tables +*/ +extern struct SceTableType m_sceSytemIdle[]; +extern struct SceTableType m_sceBootUp[]; + + +//< Initialize Enc +extern struct SceTableType *m_sceCoreFmtEnc[]; +extern struct SceTableType m_sceEncParam[]; +extern struct SceTableType **m_sceCoreFmtEncExtsync[]; +extern struct SceTableType m_sceEncParamExtsync[]; +extern struct SceTableType m_sceAudioBitrate[]; +extern struct SceTableType m_sceVideoBitrate[]; +extern struct SceTableType *m_sceEncReload[]; + +//< Start Enc +extern struct SceTableType m_sceEncStartFile[]; +extern struct SceTableType m_sceEncStartOtherPort[]; +extern struct SceTableType *m_sceCoreAudioFmtEnc[]; + + +//< Stop +extern struct SceTableType m_sceEncStopFile[]; +extern struct SceTableType m_sceEncStopOtherPort[]; +extern struct SceTableType m_sceDecStopFile[]; +extern struct SceTableType m_sceDecStopOtherPort[]; +extern struct SceTableType m_sceDecStop1picFile[]; +extern struct SceTableType m_sceDecStop1picOtherPort[]; +//< Auto stop +extern struct SceTableType m_sceDecAutoStopFile[]; +extern struct SceTableType m_sceDecAutoStop1picFile[]; +extern struct SceTableType m_sceDecStopCore[]; + +//< Initialize Dec +extern struct SceTableType *m_sceCoreFmtDec[]; +extern struct SceTableType m_sceDecParam[]; +extern struct SceTableType **m_sceCoreFmtDecExtsync[]; +extern struct SceTableType m_sceDecParamExtsync[]; +extern struct SceTableType m_sceDecParamOtherPort[]; +extern struct SceTableType *m_sceCoreAudioFmtDec[]; +extern struct SceTableType *m_sceDecReload[]; + +//< Initialize Enc 1pic +extern struct SceTableType m_sceEnc1PicInterlace[]; +extern struct SceTableType m_sceEnc1PicProgressive[]; +extern struct SceTableType *m_sceEncReload1Pic[]; + + +//< Start Dec Normal +extern struct SceTableType m_sceDecStartFile[]; +extern struct SceTableType m_sceDecStartOtherPort[]; +extern struct SceTableType m_sceDecNormal[]; + +//< Pause +extern struct SceTableType m_sceDecPause[]; + +//< Start Pause +extern struct SceTableType m_sceDecStartPause[]; + +//< Start Dec Slow +extern struct SceTableType m_sceDecSlow[]; +extern struct SceTableType m_sceDecSlowToSlow[]; + +//< Start Dec FrameAdvance +extern struct SceTableType m_sceDecFrameAdvance[]; + +//< Start Enc1 pic +extern struct SceTableType m_sceEnc1PicStartFile[]; +extern struct SceTableType m_sceEnc1PicStartOtherPort[]; + + +//< Start Dec 1pic +extern struct SceTableType m_sceDecStart1picFile[]; +extern struct SceTableType m_sceDecStart1picOtherPort[]; + + +//< SetMuteMode +extern struct SceTableType *m_sceDecMute[]; + +//< SetMuteMode +struct SceTableType m_sceStartCommand[] = { + {FmbCommandSend, 0, 0, 0}, + {NULL, 0, 0, 0} +}; + + +//< Appilcation control struct data +struct FMBInfo g_FmbInfo; +struct FMBInfo* const gp_FmbInfo = &g_FmbInfo; +struct FMBDeviceInfo *gp_FmbDevInfo = NULL; +struct FMBProperty *gp_FmbProperty = NULL; +struct FMBComProperty *gp_FmbComProperty = NULL; + +//< construct character + +//< Input & Output Port name +const char *g_FmbNamePort[] = {"File", "Stream Port" }; + +//< Video rate control name +const char *g_FmbNameVideoRateCtls[] = {"CBR", "VBR"}; + +//< Video format name +const char *g_FmbNameVideoFmts[] = { + "1920x1080", "1440x1080","1280x720", + "720x480", "720x576" +}; + +//< Video frame rate +const char *g_FmbNameVideoFrms[] = { + "60p", "59.94p", "50p", + "60i", "59.94i", "50i", + "30p", "29.97p", "25p", + "24p", "23.98p" +}; + +//< Video resolution +const char *g_FmbNameVideoRsltn[] = { + "Unknown", + "1920x1080_60p", "1920x1080_59.94p", "1920x1080_50p", + "1920x1080_60i", "1920x1080_59.94i", "1920x1080_50i", + "1440x1080_60i", "1440x1080_59.94i", "1440x1080_50i", + "1280x720_60p", "1280x720_59.94p", "1280x720_50p", + "720x480_60i", "720x480_59.94i", "720x576_50i" +}; + +//< Video Scaler Encode +const char *g_FmbNameVideoSclEncs[] = { + "Not Use" +}; + + +//< Audio format name +const char *g_FmbNameAudioFmts[] = {"MPEG1L2", "AC3", "AAC" , "LPCM"}; + +//< audio format table for reload. +const int g_ReloadAudio[FMB_AUDIO_FORMAT_KIND] = +{ + 0x0031, //< FMBEnmAudioFmtMpeg1l2 + 0x0001, //< FMBEnmAudioFmtAc3 + 0x0021, //< FMBEnmAudioFmtAac + 0x0011, //< FMBEnmAudioFmtLpcm +}; + + +//< TS packet size name +const char *g_FmbNamePacketSize[] = {"188bytes", "192bytes (ATS of DLNA mode added)", + "192bytes (ATS of BD mode added)"}; + +//< TS format name +const char *g_FmbNameTSFormat[] = { + "Nothing" , "DVB" , "BD" +}; + + +//< Video Format GPIO setting +const unsigned short g_FmbGpioVideoFormat[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = +{ + { + 0x0600 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + 0x0600 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + 0x0700 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + 0x0C00 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + 0x0C00 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + 0x0D00 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + 0x0C00 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + 0x0C00 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + 0x0D00 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + 0x0400 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + 0x0400 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + 0x0500 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + 0x0200 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + 0x0200 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + 0x0300 , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +//< V_FORMAT setting +const unsigned short g_FmbInitVideoFormat[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = +{ + { + 0x001E , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + 0x001E , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + 0x001F , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + 0x0000 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + 0x0000 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + 0x0001 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + 0x0000 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + 0x0000 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + 0x0001 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + 0x0002 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + 0x0002 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + 0x0003 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + 0x0004 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + 0x0004 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + 0x0005 , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +//< V_IP_FORMAT setting +const unsigned short g_FmbInitVideoIpFormat[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = +{ + { + 0x0005 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + 0x0005 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + 0x0005 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + 0x0000 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + 0x0000 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + 0x0000 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + 0x0000 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + 0x0000 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + 0x0000 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + 0x0005 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + 0x0005 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + 0x0005 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + 0x0000 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + 0x0000 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + 0x0000 , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +//< V_STRM_FORMAT setting +const unsigned short g_FmbInitVideoSclEnc[FMBEnmVideoFmtMax][FMBEnmVideoSclEncMax] = +{ + { + 0x0002 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoSclEnc_NotUse + }, + { + 0x0000 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoSclEnc_NotUse + }, + { + 0x0000 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoSclEnc_NotUse + }, + { + 0x0000 , //< FMBEnmVideoFmt720x480 FMBEnmVideoSclEnc_NotUse + }, + { + 0x0000 , //< FMBEnmVideoFmt720x576 FMBEnmVideoSclEnc_NotUse + } +}; + +//< ES_INFO_06(DVB) setting +const unsigned short g_FmbVideoEsInfoFormatDVB06[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = +{ + { + 0x0142 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + 0x013a , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + 0x0132 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + 0x012a , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + 0x0122 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + 0x011a , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + 0x012a , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + 0x0122 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + 0x011a , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + 0x0142 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + 0x013a , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + 0x0132 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + 0x012a , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + 0x0122 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + 0x011a , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +const unsigned short g_FmbVideoEsInfoFormatBD0C[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = +{ + { + 0xFFFF , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + 0x1b67 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + 0x1b66 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + 0x1b44 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + 0x1b43 , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + 0x1b44 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + 0x1b43 , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + 0x1b57 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + 0x1b56 , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + 0x1b14 , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + 0xFFFF , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + 0xFFFF , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + 0x1b23 , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + + +inline HANDLE FmbGetHandSceCurrent(void); +inline void FmbSetHandSceCurrent(HANDLE hSceCurrent); + + +//static HANDLE _hSceCurrent; //Scenario executing it now. + +//static BOOL s_AutoStopState = FALSE; + +/** +* @brief The MB86 module is initialized. +* @param[in] *argDriverPath Driver path pointer +* @return fd File descriptor +* @note None +* @attention None +*/ +int FmbInit(struct FMBDeviceInfo *p_DevInfo, enum FMBDeviceNumEnum deviceNum) +{ + int fd; + int drv_fd; + enum FMBFuncModeEnum setmode; + HANDLE hScet; + struct FMBProperty *p_FmbProperty; + struct FMBComProperty *p_FmbComProperty; + struct RecvThread *p_RecvThread; + struct BootThread *p_BootThread; + struct StreamThread *p_StreamThread; + char cDevcienumA[4]; + + + FMB_FUNC(TRUE); + + ASSERT_USR(p_DevInfo != NULL, "p_DevInfo == NULL"); + + + p_FmbProperty = p_DevInfo->t_Property_A; + p_FmbComProperty = &p_DevInfo->t_ComProperty; + p_RecvThread = &p_DevInfo->t_RecvThread; + p_BootThread = &p_DevInfo->t_BootThread; + p_StreamThread = p_DevInfo->t_StreamThread_A; + + + p_DevInfo->stateAutoStop = FALSE; + p_DevInfo->used = FALSE; + sprintf(cDevcienumA, "-%d", deviceNum); + + //The device driver is opened. + drv_fd = DrvOpen(p_FmbComProperty->devicePath); + p_FmbComProperty->deviceFd = drv_fd; + + hScet = SceCreate(NULL, NULL, deviceNum); + p_FmbComProperty->hEmptyScet = hScet; + DrvResetCmdInfo(hScet, FMB_CMD_INFO_ALL,0,0); //reset cmd info all + DrvResetFactor(hScet,FMB_FACTOR_ASYNC_ALL,0,0); //reset factor info all + + DrvSetIsNotify(hScet, TRUE); + + //Initialize property + memset(p_FmbProperty, 0, sizeof(struct FMBProperty) ); + + //< Initialize Encode setting + setmode = FMBEnmFuncModeEnc; + p_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtMpeg1l2; + p_FmbProperty[setmode].audioFmtReload = g_ReloadAudio[p_FmbProperty[setmode].audioFmt]; + + p_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtMpeg1l2] = FMB_DEFUALT_BITRATE_AUDIO; + p_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtAc3] = FMB_DEFUALT_BITRATE_AUDIO; + p_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtLpcm] = FMB_DEFUALT_BITRATE_AUDIO_LPCM; + p_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtAac] = FMB_DEFUALT_BITRATE_AUDIO; + p_FmbProperty[setmode].audioBitrateVbrAverage = FMB_DEFUALT_BITRATE_AUDIO; + p_FmbProperty[setmode].audioBitrateVbrPeak = FMB_DEFUALT_BITRATE_AUDIO; + p_FmbProperty[setmode].audioLpcm = FMBEnmAudioLpcm16stereo; + + p_FmbProperty[setmode].outputPort = FMBEnmPortFile; + //strcpy(p_FmbProperty[setmode].outputfile , FMB_DEFUALT_FILEPATH_OUT_ENC); + strcpy(p_FmbProperty[setmode].outputfile, FMB_DEFUALT_FILENAME); + strcat(p_FmbProperty[setmode].outputfile, cDevcienumA); + strcat(p_FmbProperty[setmode].outputfile, FMB_DEFUALT_FILENAME_EXT); + p_FmbProperty[setmode].videoBitrateProp.videoRateCtl = FMBEnmVideoRateCtlCbr; + p_FmbProperty[setmode].videoBitrateProp.videoBitrateCbr = FMB_DEFUALT_BITRATE_CBR_ENC; + p_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrAverage = FMB_DEFUALT_BITRATE_VBR_AVE_ENC; + p_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrPeak = FMB_DEFUALT_BITRATE_VBR_PEAK_ENC; + + p_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + p_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i; + p_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_59i; + p_FmbProperty[setmode].videoScalerEnc = FMBEnmVideoSclEnc_NotUse; + p_FmbProperty[setmode].speedSlow = 0; + p_FmbProperty[setmode].isMute = FALSE; + //< calculation bitrate in video bitrate base + p_FmbProperty[setmode].videoBitrateProp.bitrateCalckind = FMBEnmBitrateCalcVideobase; + p_FmbComProperty->setMode = FMBEnmFuncModeEnc; + FmbCalcVideoBitrateParam(&p_FmbProperty[setmode].videoBitrateProp, + p_FmbProperty[setmode].videoFrm, + p_FmbProperty[setmode].audioFmt); + + + //< Initialize Decode setting + setmode = FMBEnmFuncModeDec; + p_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtMpeg1l2; + p_FmbProperty[setmode].audioFmtReload = g_ReloadAudio[p_FmbProperty[setmode].audioFmt]; + p_FmbProperty[setmode].inputPort = FMBEnmPortFile; + //strcpy(p_FmbProperty[setmode].inputfile , FMB_DEFUALT_FILEPATH_IN_DEC); + strcpy(p_FmbProperty[setmode].inputfile, FMB_DEFUALT_FILENAME); + strcat(p_FmbProperty[setmode].inputfile, cDevcienumA); + strcat(p_FmbProperty[setmode].inputfile, FMB_DEFUALT_FILENAME_EXT); + p_FmbProperty[setmode].videoFmt = FMBEnmVideoFmt1920x1080; + p_FmbProperty[setmode].videoFrm = FMBEnmVideoFrm_5994i; + p_FmbProperty[setmode].videoRsltn = FMBEnmVideoRsltn_1920_1080_59i; + p_FmbProperty[setmode].speedSlow = 0; + p_FmbProperty[setmode].isMute = FALSE; + + + + memset(p_FmbComProperty->deviceName, 0, FMB_DEVNAME_MAX_CHAR); + strcpy(p_FmbComProperty->deviceName, FMB_DEVNAME_CHAR); + strcat(p_FmbComProperty->deviceName, cDevcienumA); + + p_FmbComProperty->deviceNum = deviceNum; + p_FmbComProperty->setMode = FMBEnmFuncModeEnc; ///<Kind of Mode(enc/dec) + p_FmbComProperty->currentRequest = FMBEnmReqNothing; + p_FmbComProperty->lastRequest = FMBEnmReqNothing; + p_FmbComProperty->isInternalDecodeStatus = FALSE; ///<FALSE:Status is not decoding. + p_FmbComProperty->waitStreamSendEnd = FMBEnmStreamSendEndOff; ///<Not wait + p_FmbComProperty->PidType = FMBEnmInputVideoPid; + p_FmbComProperty->TsType = FMBEnmInputTsPacket; + p_FmbComProperty->PidValue[FMBEnmInputVideoPid] = FMB_DEFAULT_INPUT_VIDEO_PID; + p_FmbComProperty->PidValue[FMBEnmInputAudioPid] = FMB_DEFAULT_INPUT_AUDIO_PID; + p_FmbComProperty->PidValue[FMBEnmInputPmtPid] = FMB_DEFAULT_INPUT_PMT_PID; + p_FmbComProperty->PidValue[FMBEnmInputSitPid] = FMB_DEFAULT_INPUT_SIT_PID; + p_FmbComProperty->PidValue[FMBEnmInputPcrPid] = FMB_DEFAULT_INPUT_PCR_PID; + p_FmbComProperty->PidValue[FMBEnmOutputVideoPid] = FMB_DEFAULT_OUTPUT_VIDEO_PID; + p_FmbComProperty->PidValue[FMBEnmOutputAudioPid] = FMB_DEFAULT_OUTPUT_AUDIO_PID; + p_FmbComProperty->PidValue[FMBEnmOutputPmtPid] = FMB_DEFAULT_OUTPUT_PMT_PID; + p_FmbComProperty->PidValue[FMBEnmOutputSitPid] = FMB_DEFAULT_OUTPUT_SIT_PID; + p_FmbComProperty->PidValue[FMBEnmOutputPcrPid] = FMB_DEFAULT_OUTPUT_PCR_PID; + p_FmbComProperty->tsFormat[FMBEnmInputTsPacket] = FMBEnmTsFormat188; + p_FmbComProperty->tsFormat[FMBEnmOutputTsPacket] = FMBEnmTsFormat188; + p_FmbComProperty->fmbRc = FMBEnmResultContinue; + + + + p_RecvThread->t_env.deviceNum = p_FmbComProperty->deviceNum; + p_RecvThread->t_env.p_devicePath = p_FmbComProperty->devicePath; + p_RecvThread->t_env.p_fdPipeWrite = &p_FmbComProperty->fdPipeWrite; + p_RecvThread->t_env.p_fdPipeRead = &p_FmbComProperty->fdPipeRead; + fd = FmbRecvBegin(p_RecvThread); + + + p_BootThread->t_env.p_firmPath = gp_FmbInfo->firmPath_A; + p_BootThread->t_env.p_firmLSIVer = &p_DevInfo->firmLSIVer; + p_BootThread->t_env.p_version_info = &p_DevInfo->version_info; + p_BootThread->t_env.p_subSystemId = &p_DevInfo->subSystemId; + p_BootThread->t_env.p_sceHandle = &p_FmbComProperty->hEmptyScet; + p_BootThread->t_env.p_deviceFd = &p_FmbComProperty->deviceFd; + p_BootThread->t_env.p_fdPipeRead = &p_FmbComProperty->fdPipeRead; + + + + p_StreamThread[FMBEnmStreamRcv].start_routine = NULL; + p_StreamThread[FMBEnmStreamRcv].fBuf = NULL; + p_StreamThread[FMBEnmStreamRcv].isThread = FALSE; + p_StreamThread[FMBEnmStreamRcv].isStop = FALSE; + p_StreamThread[FMBEnmStreamRcv].isForceStop = FALSE; + p_StreamThread[FMBEnmStreamRcv].fmbfd = -1; + p_StreamThread[FMBEnmStreamRcv].fd = -1; + p_StreamThread[FMBEnmStreamRcv].streamSize = 0; + p_StreamThread[FMBEnmStreamRcv].isFrameUpdate = FALSE; + p_StreamThread[FMBEnmStreamRcv].isSeqEnd = FALSE; + p_StreamThread[FMBEnmStreamRcv].isSystemCmdAck = FALSE; + p_StreamThread[FMBEnmStreamRcv].fSize = FMB_STREAM_THREAD_RECV_FSIZE; + p_StreamThread[FMBEnmStreamRcv].priority = FMB_STREAM_THREAD_RECV_PRI; + p_StreamThread[FMBEnmStreamRcv].fileStartPos = 0; + p_StreamThread[FMBEnmStreamRcv].fileEndPos = 0; + p_StreamThread[FMBEnmStreamRcv].deviceNum = p_FmbComProperty->deviceNum; + p_StreamThread[FMBEnmStreamRcv].p_fdPipeWrite = &p_FmbComProperty->fdPipeWrite; + + p_StreamThread[FMBEnmStreamSend].start_routine = NULL; + p_StreamThread[FMBEnmStreamSend].fBuf = NULL; + p_StreamThread[FMBEnmStreamSend].isThread = FALSE; + p_StreamThread[FMBEnmStreamSend].isStop = FALSE; + p_StreamThread[FMBEnmStreamSend].isForceStop = FALSE; + p_StreamThread[FMBEnmStreamSend].fmbfd = -1; + p_StreamThread[FMBEnmStreamSend].fd = -1; + p_StreamThread[FMBEnmStreamSend].streamSize = 0; + p_StreamThread[FMBEnmStreamSend].isFrameUpdate = FALSE; + p_StreamThread[FMBEnmStreamSend].isSeqEnd = FALSE; + p_StreamThread[FMBEnmStreamSend].isSystemCmdAck = FALSE; + p_StreamThread[FMBEnmStreamSend].fSize = FMB_STREAM_THREAD_SEND_FSIZE; + p_StreamThread[FMBEnmStreamSend].priority = FMB_STREAM_THREAD_SEND_PRI; + p_StreamThread[FMBEnmStreamSend].fileStartPos = 0; + p_StreamThread[FMBEnmStreamSend].fileEndPos = 0; + p_StreamThread[FMBEnmStreamSend].deviceNum = p_FmbComProperty->deviceNum; + p_StreamThread[FMBEnmStreamSend].p_fdPipeWrite = &p_FmbComProperty->fdPipeWrite; + + + FMB_FUNC(FALSE); + return fd; +} + +/** +* @brief The MB86 module is terminated. +* @param[in] p_DevInfo +* @return None +* @note None +* @attention None +*/ +void FmbTerminate(struct FMBDeviceInfo *p_DevInfo) +{ + struct FMBComProperty *p_FmbComProperty; + + FMB_FUNC(TRUE); + + ASSERT_USR(p_DevInfo != NULL, "p_DevInfo == NULL"); + + p_FmbComProperty = &p_DevInfo->t_ComProperty; + + + DrvClose(p_FmbComProperty->deviceFd); + p_FmbComProperty->deviceFd = -1; + SceClose(p_FmbComProperty->hEmptyScet); + p_FmbComProperty->hEmptyScet = NULL; + + FMB_FUNC(FALSE); +} + +/** +* @brief Initialization for one picture encoding. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbInitEnc1pic(void) +{ + BOOL isContinue; + enum FMBVideoFormatEnum fmt; + enum FMBVideoFrameEnum frm; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqInitEnc1pic; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + gp_FmbComProperty->setMode = FMBEnmFuncModeEnc; + + FmbApplySettingGpioVideoFormat(); + + SceGoSync(m_sceCoreFmtEnc[gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt], NULL, deviceNum); + + SceGoSync(m_sceEncParam, NULL, deviceNum); + + if(gp_FmbDevInfo->subSystemId == 0xFFFFFFFE){ + SceGoSync(m_sceEncParamExtsync, NULL, deviceNum); + + fmt = gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm; + ASSERT_USR(m_sceCoreFmtEncExtsync[fmt][frm] != NULL, " This video format is illegal in External sync."); + SceGoSync(m_sceCoreFmtEncExtsync[fmt][frm], NULL, deviceNum); + } + + switch(gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm){ + case FMBEnmVideoFrm_60p: + case FMBEnmVideoFrm_5994p: + case FMBEnmVideoFrm_50p: + SceGoSync(m_sceEnc1PicProgressive, NULL, deviceNum); + break; + default: + SceGoSync(m_sceEnc1PicInterlace, NULL, deviceNum); + break; + } + + SceGoSync(m_sceAudioBitrate, NULL, deviceNum); + + SceGoSync(m_sceVideoBitrate, NULL, deviceNum); + + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended!"); + hSceCurrent = SceCreate(m_sceEncReload1Pic[gp_FmbProperty[FMBEnmFuncModeEnc].outputPort],NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief Initialization for encoding. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbInitEnc(void) +{ + BOOL isContinue; + enum FMBVideoFormatEnum fmt; + enum FMBVideoFrameEnum frm; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqInitEnc; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + gp_FmbComProperty->setMode = FMBEnmFuncModeEnc; + + FmbApplySettingGpioVideoFormat(); + + SceGoSync(m_sceCoreFmtEnc[gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt], NULL, deviceNum); + + SceGoSync(m_sceEncParam, NULL, deviceNum); + + if(gp_FmbDevInfo->subSystemId == 0xFFFFFFFE){ + SceGoSync(m_sceEncParamExtsync, NULL, deviceNum); + + fmt = gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm; + ASSERT_USR(m_sceCoreFmtEncExtsync[fmt][frm] != NULL, " This video format is illegal in External sync."); + SceGoSync(m_sceCoreFmtEncExtsync[fmt][frm], NULL, deviceNum); + } + + SceGoSync(m_sceAudioBitrate, NULL, deviceNum); + + SceGoSync(m_sceVideoBitrate, NULL, deviceNum); + + SceGoSync(m_sceCoreAudioFmtEnc[gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt], NULL, deviceNum); + + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended!"); + + hSceCurrent = SceCreate(m_sceEncReload[gp_FmbProperty[FMBEnmFuncModeEnc].outputPort],NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + + +/** +* @brief Initialization for decoding. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbInitDec(void) +{ + BOOL isContinue; + enum FMBVideoFormatEnum fmt; + enum FMBVideoFrameEnum frm; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqInitDec; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + gp_FmbComProperty->setMode = FMBEnmFuncModeDec; + + FmbApplySettingGpioVideoFormat(); + + SceGoSync(m_sceCoreFmtDec[gp_FmbProperty[FMBEnmFuncModeDec].videoFmt], NULL, deviceNum); + + SceGoSync(m_sceDecParam, NULL, deviceNum); + + if(gp_FmbDevInfo->subSystemId == 0xFFFFFFFE){ + SceGoSync(m_sceDecParamExtsync, NULL, deviceNum); + + fmt = gp_FmbProperty[FMBEnmFuncModeDec].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeDec].videoFrm; + ASSERT_USR(m_sceCoreFmtDecExtsync[fmt][frm] != NULL, " This video format is illegal in External sync."); + SceGoSync(m_sceCoreFmtDecExtsync[fmt][frm], NULL, deviceNum); + } + + if (gp_FmbProperty[FMBEnmFuncModeDec].inputPort == FMBEnmPortStreamport) { + SceGoSync(m_sceDecParamOtherPort, NULL, deviceNum); + } + SceGoSync(m_sceCoreAudioFmtDec[gp_FmbProperty[FMBEnmFuncModeDec].audioFmt], NULL, deviceNum); + + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended!"); + + hSceCurrent = SceCreate(m_sceDecReload[gp_FmbProperty[FMBEnmFuncModeDec].inputPort],NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief Initialization for 1pic decoding. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbInitDec1pic(void) +{ + FMB_FUNC(TRUE); + + FmbInitDec(); + gp_FmbComProperty->currentRequest = FMBEnmReqInitDec1pic; + + FMB_FUNC(FALSE); +} + +/** +* @brief Initialization for pause-start. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbInitStartPause(void) +{ + FMB_FUNC(TRUE); + + FmbInitDec(); + + gp_FmbComProperty->currentRequest = FMBEnmReqInitStartPause; + + FMB_FUNC(FALSE); +} +/** +* @brief Encoding begins. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStartEnc(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStartEnc; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + if (gp_FmbProperty[FMBEnmFuncModeEnc].outputPort == FMBEnmPortFile) { + hSceCurrent = SceCreate(m_sceEncStartFile, NULL, deviceNum); + } + else { + hSceCurrent = SceCreate(m_sceEncStartOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief The still picture is encoded. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStartEnc1Pic(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStartEnc1Pic; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + if (gp_FmbProperty[FMBEnmFuncModeEnc].outputPort == FMBEnmPortFile) { + hSceCurrent = SceCreate(m_sceEnc1PicStartFile, NULL, deviceNum); + } + else { + hSceCurrent = SceCreate(m_sceEnc1PicStartOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief Decoding begins(Normal decode start or already decode start). +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStartDecNormal(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStartDecNormal; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + if(gp_FmbComProperty->isInternalDecodeStatus){ //if decode status is start, restart decode. + hSceCurrent = SceCreate(m_sceDecNormal, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + else { + if (gp_FmbProperty[FMBEnmFuncModeDec].inputPort == FMBEnmPortFile) { + //< File + hSceCurrent = SceCreate(m_sceDecStartFile, NULL, deviceNum); + } + else { + //< Streamport + hSceCurrent = SceCreate(m_sceDecStartOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + + FMB_FUNC(FALSE); +} + +/** +* @brief 1 picture decoding begins. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStartDec1pic(void) +{ + BOOL isContinue; + FMB_FUNC(TRUE); + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStartDec1pic; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + if (gp_FmbProperty[FMBEnmFuncModeDec].inputPort == FMBEnmPortFile) { + //< File + hSceCurrent = SceCreate(m_sceDecStart1picFile, NULL, deviceNum); + } + else { + //< Streamport + hSceCurrent = SceCreate(m_sceDecStart1picOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief It reproduces slowly. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +enum FMBResultEnum FmbStartDecSlow(void) +{ + BOOL isContinue; + HANDLE hScenario; + enum FMBResultEnum fmbResult; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->isInternalDecodeStatus, "Invalid status!"); + + if(gp_FmbProperty[FMBEnmFuncModeDec].speedSlow == 0){ + hSceCurrent = SceCreate(m_sceDecSlow, NULL, deviceNum); //slow decording + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + fmbResult = FMBEnmResultContinue; //The request is being executed. + gp_FmbComProperty->currentRequest = FMBEnmReqStartDecSlow; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + } + else { + hScenario = SceCreate(m_sceDecSlowToSlow, NULL, deviceNum); //slow to slow decording + isContinue = SceGo(hScenario, NULL); + ASSERT_USR(!isContinue, "Invalid scenario"); + + SceClose(hScenario); + fmbResult = FMBEnmResultRequestComplete; //The request was completed. + } + + FMB_FUNC(FALSE); + return fmbResult; +} + +/** +* @brief The FrameAdvance reproduces. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStartDecFrameAdvance(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + ASSERT_USR(gp_FmbComProperty->isInternalDecodeStatus, "Invalid status!"); + + gp_FmbComProperty->currentRequest = FMBEnmReqStartDecFrameAdvance; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + hSceCurrent = SceCreate(m_sceDecFrameAdvance, NULL, deviceNum); //FrameAdvance decoding + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + + +/** +* @brief The reproduction is stopped temporarily. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbPause(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + if(gp_FmbComProperty->isInternalDecodeStatus){ //if decode inside, + hSceCurrent = SceCreate(m_sceDecPause, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + else{ + hSceCurrent = SceCreate(m_sceDecStartPause, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + + gp_FmbComProperty->currentRequest = FMBEnmReqPause; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + FMB_FUNC(FALSE); +} + +/** +* @brief The mute mode of audio is set. +* @param[in] isMute It specifies whether to muffle it. +* @return None +* @note None +* @attention None +*/ +void FmbSetMuteMode(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqMute; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + hSceCurrent = SceCreate(m_sceDecMute[gp_FmbProperty[gp_FmbComProperty->setMode].isMute], NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief The decoding or the encoding or the decodeing is stopped. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStop(void) +{ + BOOL isContinue; + //int deviceFd = gp_FmbComProperty->deviceFd; + HANDLE hSceCurrent; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + + FMB_FUNC(TRUE); + + ASSERT_USR( (gp_FmbComProperty->currentRequest == FMBEnmReqNothing), + "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStop; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + if(gp_FmbDevInfo->stateAutoStop){ + LogFmb("[FmbStop]\t AutoStopped."); + hSceCurrent = SceCreate(m_sceDecStopCore, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + FMB_FUNC(FALSE); + return; + } + + if (gp_FmbComProperty->setMode == FMBEnmFuncModeDec){ + if (gp_FmbProperty[FMBEnmFuncModeDec].inputPort == FMBEnmPortFile) { + //< File + hSceCurrent = SceCreate(m_sceDecStopFile, NULL, deviceNum); + } + else { + //< Streamport + hSceCurrent = SceCreate(m_sceDecStopOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + else if (gp_FmbComProperty->setMode == FMBEnmFuncModeEnc) { + if (gp_FmbProperty[FMBEnmFuncModeEnc].outputPort == FMBEnmPortFile) { + //< File + hSceCurrent = SceCreate(m_sceEncStopFile, NULL, deviceNum); + } + else { + //< Streamport + hSceCurrent = SceCreate(m_sceEncStopOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + + FMB_FUNC(FALSE); +} + +/** +* @brief The decoding is stopped for the automatable senario. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbAutoStop(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR( (gp_FmbComProperty->currentRequest == FMBEnmReqNothing), + "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqAutoStop; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + gp_FmbDevInfo->stateAutoStop = TRUE; + + ASSERT_USR(gp_FmbComProperty->setMode != FMBEnmFuncModeEnc, "The scenario has not ended."); + + if (gp_FmbComProperty->setMode == FMBEnmFuncModeDec){ + if(gp_FmbComProperty->isInternalDecodeStatus == TRUE){ + hSceCurrent = SceCreate(m_sceDecAutoStopFile, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + } + else{ + hSceCurrent = SceCreate(m_sceDecAutoStop1picFile, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + } + } + + FMB_FUNC(FALSE); +} + +/** +* @brief The 1pic decoding is stopped. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbStop1picDec(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStop; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + if (gp_FmbProperty[FMBEnmFuncModeDec].inputPort == FMBEnmPortFile) { + //< File + hSceCurrent = SceCreate(m_sceDecStop1picFile, NULL, deviceNum); + } + else { + //< Streamport + hSceCurrent = SceCreate(m_sceDecStop1picOtherPort, NULL, deviceNum); + } + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief The sequence end decoding is stopped. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbDecStopCore(void) +{ + BOOL isContinue; + HANDLE hSceCurrent; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + gp_FmbComProperty->currentRequest = FMBEnmReqStopDecCore; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + + hSceCurrent = SceCreate(m_sceDecStopCore, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief MB86 is reset. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbReset(void) +{ + BOOL isContinue; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + gp_FmbProperty[FMBEnmFuncModeDec].isMute = FALSE; + gp_FmbComProperty->waitStreamSendEnd = FMBEnmStreamSendEndOff; + gp_FmbDevInfo->stateAutoStop = FALSE; + + gp_FmbComProperty->currentRequest = FMBEnmReqReset; + gp_FmbComProperty->fmbRc = FMBEnmResultContinue; + hSceCurrent = SceCreate(m_sceSytemIdle, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + ASSERT_USR(isContinue, "Invalid scenario"); + + FMB_FUNC(FALSE); +} + +/** +* @brief sending a command. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +enum FMBResultEnum FmbStartCommand(char* cmdbuf) +{ + BOOL isContinue; + enum FMBResultEnum fmbResult; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + + gp_FmbComProperty->currentRequest = FMBEnmReqStartCommand; + m_sceStartCommand[0].arg1 = (int)cmdbuf; + m_sceStartCommand[0].arg2 = SCE_IGNORE; + m_sceStartCommand[0].arg3 = SCE_IGNORE; + hSceCurrent = SceCreate(m_sceStartCommand, NULL, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + if(isContinue){ + fmbResult = FMBEnmResultContinue; //The request is being executed. + } + else { + SceClose(hSceCurrent); + FmbSetHandSceCurrent(NULL); + fmbResult = FMBEnmResultRequestComplete; //The request was completed. + gp_FmbComProperty->currentRequest = FMBEnmReqNothing; + } + + FMB_FUNC(FALSE); + return fmbResult; +} +/** +* @brief sending a command. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +enum FMBResultEnum FmbStartCommandSenario(struct SceTableType* cmdtable) +{ + BOOL isContinue; + enum FMBResultEnum fmbResult; + enum FMBDeviceNumEnum deviceNum = gp_FmbComProperty->deviceNum; + HANDLE hSceCurrent; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "The request has not ended."); + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario has not ended."); + + + gp_FmbComProperty->currentRequest = FMBEnmReqStartCommand; + hSceCurrent = SceCreate(cmdtable, (char*)cmdtable, deviceNum); + FmbSetHandSceCurrent(hSceCurrent); + + isContinue = SceGo(hSceCurrent, NULL); + if(isContinue){ + fmbResult = FMBEnmResultContinue; //The request is being executed. + } + else { + SceClose(hSceCurrent); + FmbSetHandSceCurrent(NULL); + fmbResult = FMBEnmResultRequestComplete; //The request was completed. + gp_FmbComProperty->currentRequest = FMBEnmReqNothing; + } + + FMB_FUNC(FALSE); + return fmbResult; +} + +/** +* @brief The request is canceled. +* @param[in] None +* @return TRUE There was a request, and it canceled. +* @return FALSE There was no request. +* @note None +* @attention None +*/ +BOOL FmbCancelRequest(void) +{ + FMB_FUNC(TRUE); + + if(gp_FmbComProperty->currentRequest == FMBEnmReqNothing){ + FMB_FUNC(FALSE); + return FALSE; + } + + ASSERT_USR(FmbGetHandSceCurrent() != NULL, "The scenario has ended."); + + SceClose(FmbGetHandSceCurrent()); + FmbSetHandSceCurrent(NULL); + + gp_FmbComProperty->currentRequest = FMBEnmReqNothing; + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The request is canceled. +* @param[in] None +* @return TRUE There was a request, and it canceled. +* @return FALSE There was no request. +* @note None +* @attention None +*/ +BOOL FmbCheckSenario(void) +{ + FMB_FUNC(TRUE); + + if(FmbGetHandSceCurrent() != NULL){ + FMB_FUNC(FALSE); + return FALSE; + } + + FMB_FUNC(FALSE); + return TRUE; +} + + +/** +* @brief Recieve from driver. +* @param[in] fd +* @return Running state of request. It's continue or complete. +* @note None +* @attention None +*/ +enum FMBResultEnum OnFmbMessage(int fd) +{ + BOOL isScenarioContinue; + struct RecvEventArgType evnt; + + FMB_FUNC(TRUE); + + isScenarioContinue = TRUE; + while(FmbRecvGetEventInfo(&evnt, fd)){ + LogFmb("[OnFmbMessage]\t[1]evnt.devNum\t%d\t" + "evnt.dev\t%d\t" + "evnt.evnt\t%d\t" + "SysAck.id\t%d\t" + "waitStreamSendEnd\t%d\t" + "currentRequest\t%d\t", + evnt.devNum, evnt.dev, evnt.evnt, evnt.WaitDetail.SysAck.id, + gp_FmbComProperty->waitStreamSendEnd, gp_FmbComProperty->currentRequest); + + if( (evnt.dev == FMBEnmCoreDeviceVideo) && + ((evnt.WaitDetail.VideoMsg.mode == 1)||(evnt.WaitDetail.VideoMsg.mode == 2)) && + (evnt.WaitDetail.VideoMsg.seq_end == 1) ){ + + if ( ( gp_FmbComProperty->currentRequest == FMBEnmReqStop )|| + ( gp_FmbComProperty->currentRequest == FMBEnmReqStartDecFrameAdvance ) ) { + SceClose(FmbGetHandSceCurrent()); + FmbSetHandSceCurrent(NULL); + LogFmb("[OnFmbMessage]\t[4]currentRequest\t%d\t", gp_FmbComProperty->currentRequest); + gp_FmbComProperty->currentRequest = FMBEnmReqNothing; + } + SetInputEnabled(FALSE); + FmbDecStopCore(); + } + + if (gp_FmbComProperty->waitStreamSendEnd == FMBEnmStreamSendEndOn) { + + + if((evnt.dev == FMBEnmCoreDeviceStream) && (evnt.evnt == FMBEnmCoreFromSteamEndMsg) && + (evnt.WaitDetail.SysAck.id == FMBEnmStreamSend)){ + + if ( gp_FmbComProperty->currentRequest == FMBEnmReqStop){ + LogFmb("[OnFmbMessage]\t FMBEnmReqStopping.. event skip"); + continue; + } + + LogFmb("[OnFmbMessage]\t[2]waitStreamSendEnd\t%d\t" + "setmode\t%d\t" + , gp_FmbComProperty->waitStreamSendEnd, gp_FmbComProperty->setMode); + + FmbAutoStop(); + gp_FmbComProperty->waitStreamSendEnd = FMBEnmStreamSendEndOff; + + } + + } + if(gp_FmbComProperty->currentRequest == FMBEnmReqNothing){ + continue; + } + + if(! isScenarioContinue){ + continue; + } + isScenarioContinue = SceGo(FmbGetHandSceCurrent(), &evnt); + } + + if(isScenarioContinue){ + LogFmb("[OnFmbMessage]\t[3]isScenarioContinue\t%d\t",isScenarioContinue); + FMB_FUNC(FALSE); + return FMBEnmResultContinue; + } + + //Current decode-status is set. + switch(gp_FmbComProperty->currentRequest){ + case FMBEnmReqNothing: + ASSERT_USR(FmbGetHandSceCurrent() == NULL, "The scenario not closed."); + FMB_FUNC(FALSE); + return FMBEnmResultRequestComplete; + + case FMBEnmReqStartDecNormal: + case FMBEnmReqPause: + case FMBEnmReqStartDecSlow: + case FMBEnmReqStartDecFrameAdvance: + case FMBEnmReqMute: + case FMBEnmReqStop: + case FMBEnmReqAutoStop: + gp_FmbComProperty->isInternalDecodeStatus = TRUE; + break; + + default: + gp_FmbComProperty->isInternalDecodeStatus = FALSE; + break; + } + + ASSERT_USR(FmbGetHandSceCurrent() != NULL, "The scenario has ended."); + + //Scenario end. + SceClose(FmbGetHandSceCurrent()); + FmbSetHandSceCurrent(NULL); + + FMB_FUNC(FALSE); + return FMBEnmResultRequestComplete; +} +/** +* @brief The video format(GPIO setting) is applied. (sync i/o) +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void FmbApplySettingGpioVideoFormat() +{ + enum FMBVideoFormatEnum fmt; + enum FMBVideoFrameEnum frm; + int data; + HANDLE hScet; + + FMB_FUNC(TRUE); + + switch (gp_FmbComProperty->setMode) { + case FMBEnmFuncModeEnc: + fmt = gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm; + break; + case FMBEnmFuncModeDec: + fmt = gp_FmbProperty[FMBEnmFuncModeDec].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeDec].videoFrm; + break; + default: + FMB_FUNC(FALSE); + return; + } + + if (g_FmbGpioVideoFormat[fmt][frm] == 0xFFFF){ + return; + } + + hScet = gp_FmbComProperty->hEmptyScet; + PciSetReg(hScet,PCI_TYPE_BAR0,PCI_OUSER_ADDR,0xffff0000); + + data = g_FmbGpioVideoFormat[fmt][frm]; + switch (gp_FmbComProperty->setMode) { + case FMBEnmFuncModeEnc: + data = (data&0xFFEF); + break; + case FMBEnmFuncModeDec: + data = (data|0x0010); + break; + default: + FMB_FUNC(FALSE); + return; + } + LsiSetReg(hScet,LSI_GPIO_OUT_ADDR, (data|0x0008), 0); + + LsiSetReg(hScet,LSI_GPIO_CNT_ADDR,0x0FF8,0); + + + LsiSetReg(hScet,LSI_GPIO_OUT_ADDR,data,0); + + + FMB_FUNC(FALSE); +} diff --git a/fmb_player_apl/src/sce/FmbSceAudioFmtCore.c b/fmb_player_apl/src/sce/FmbSceAudioFmtCore.c new file mode 100644 index 0000000..78e408b --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceAudioFmtCore.c @@ -0,0 +1,268 @@ +/** +* @brief The scenario that sets the format of the Audio to MB86 is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" + +/** +* @brief Set Audio format in MB86 scenario table(MPEG1L2Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtMpeg1l2Enc[] = { + {CoreParamSet, 0x0005002a, 0, 0}, //< Set to initialize parameter A E_MPEG_PROTECT + {CoreParamSet, 0x00050029, 0, 0}, //< Set to initialize parameter A E_MPEG_MODE + {CoreParamSet, 0x00050028, 0, 0}, //< Set to initialize parameter A E_MPEG_COPYR + {CoreParamSet, 0x00050027, 0, 0}, //< Set to initialize parameter A E_MPEG_ORIG + {CoreParamSet, 0x00050026, 0, 0}, //< Set to initialize parameter A E_MPEG_EMP + {WriteEsInfoAudio, 0, 0, 0}, //< Additional parameter M set ES_INFO + {CoreParamSet, 0x0003001d, 0x00c0, 0}, //< initialize Parameter M set only for initialization A_SID(DVB) + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set Audio format in MB86 scenario table(AC3Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtAc3Enc[] = { + {CoreParamSet, 0x00050025, 0, 0}, //< Set to initialize parameter A E_AC3_ACMOD + {CoreParamSet, 0x00050024, 1, 0}, //< Set to initialize parameter A E_AC3_COMPR + {CoreParamSet, 0x00050023, 1, 0}, //< Set to initialize parameter A E_AC3_COMPR2 + {CoreParamSet, 0x00050022, 0, 0}, //< Set to initialize parameter A E_AC3_RUNMOD + {WriteEsInfoAudio, 0, 0, 0}, //< Additional parameter M set ES_INFO + {NULL, 0, 0, 0} +}; + +/** +* @brief Set Audio format in MB86 scenario table(LPCMEnc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtLpcmEnc[] = { + {CoreParamSet, 0x00050031, 3, 0}, //< Set to initialize parameter A E_LPCM_CHANNEL_NUM(2CH) + {WriteEsInfoAudio, 0, 0, 0}, //< Additional parameter M set ES_INFO + {CoreParamSet, 0x0003001d, 0x00bd, 0}, //< Parameter M set only for initialization A_SID(BD) + {NULL, 0, 0, 0} +}; + +/** +* @brief Set Audio format in MB86 scenario table(AACEnc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtAacEnc[] = { + {CoreParamSet, 0x0005002f, 0, 0}, //< Set to initialize parameter A E_AAC_PROTECT_ABS + {CoreParamSet, 0x0005002e, 1, 0}, //< Set to initialize parameter A E_AAC_PROFILE + {CoreParamSet, 0x0005002d, 2, 0}, //< Set to initialize parameter A E_AAC_CH_CONFIG + {CoreParamSet, 0x0005002c, 1, 0}, //< Set to initialize parameter A E_AAC_ORIG + {WriteEsInfoAudio, 0, 0, 0}, //< Additional parameter M set ES_INFO + {CoreParamSet, 0x0003001d, 0x00c0, 0}, //< Parameter M set only for initialization A_SID(DVB) + {NULL, 0, 0, 0} +}; + +/** +* @brief Set Audio format in MB86 scenario table(no need setting). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtNothing[] = { + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set Audio format in MB86 scenario table(AC3Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtAc3Dec[] = { + {CoreParamSet, 0x00050035, 0, 0}, //< Set to initialize parameter A D_AC3_OUT_CH_MODE + {CoreParamSet, 0x00050034, 1, 0}, //< Set to initialize parameter A D_AC3_STEREO_MODE + {CoreParamSet, 0x00050033, 0, 0}, //< Set to initialize parameter A D_AC3_DUALMODE + {NULL, 0, 0, 0} +}; + +/** +* @brief Set Audio format in MB86 scenario table(AACDec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreAudioFmtAacDec[] = { + {CoreParamSet, 0x00050037, 0, 0}, //< Set to initialize parameter A D_AAC_CHMAP + {NULL, 0, 0, 0} +}; + + + +/** +* @brief Set Audio format in MB86 scenario 1ST table(Enc). +* @note None +* @attention None +*/ +struct SceTableType *m_sceCoreAudioFmtEnc[] = { + m_sceCoreAudioFmtMpeg1l2Enc, //< some set data FMBEnmAudioFmtMpeg1l2 + m_sceCoreAudioFmtAc3Enc, //< some set data FMBEnmAudioFmtAc3 + m_sceCoreAudioFmtAacEnc, //< some set data FMBEnmAudioFmtAac + m_sceCoreAudioFmtLpcmEnc, //< some set data FMBEnmAudioFmtLpcm +}; + +/** +* @brief Set Audio format in MB86 scenario 1ST table(Dec). +* @note None +* @attention None +*/ +struct SceTableType *m_sceCoreAudioFmtDec[] = { + m_sceCoreAudioFmtNothing, //< some set data FMBEnmAudioFmtMpeg1l2(no need setting) + m_sceCoreAudioFmtAc3Dec, //< some set data FMBEnmAudioFmtAc3 + m_sceCoreAudioFmtAacDec, //< some set data FMBEnmAudioFmtAac + m_sceCoreAudioFmtNothing, //< some set data FMBEnmAudioFmtLpcm(no need setting) +}; + +/** +* @brief The value is written in ES_info by audio format. +* @param[in] sceHandle Scenario handle +* @param[in] dummy1 dummy1 +* @param[in] dummy2 dummy2 +* @param[in] dummy3 dummy3 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum WriteEsInfoAudio(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3) +{ + int tmp; + + switch(gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt){ + case FMBEnmAudioFmtMpeg1l2: + CoreParamSet(sceHandle, 0x00000014, 0x000d , 0); //< Additional parameter M set ES_INFO_LENGTH + tmp = ( (gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] >> 0x8)& 0x1f); + CoreParamSet(sceHandle, 0x0000002a, (0x3e0 | tmp) , 0); //< Additional parameter M set ES_INFO_08 + tmp = ((gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] & 0xff) << 0x8); + CoreParamSet(sceHandle, 0x0000002b, (0xf0 | tmp) , 0); //< Additional parameter M set ES_INFO_0A + CoreParamSet(sceHandle, 0x0000002c, 0x0000 , 0); //< Additional parameter M set ES_INFO_0C + break; + + case FMBEnmAudioFmtAc3: + if(g_AudioFormatCheck[gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt] == FMBEnmAFmtDVB){ + CoreParamSet(sceHandle, 0x00000014, 0x0010 , 0); //< Additional parameter M set ES_INFO_LENGTH + tmp = ( (gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] >> 0x8)& 0x1f); + CoreParamSet(sceHandle, 0x0000002a, (0x6e0 | tmp) , 0); //< Additional parameter M set ES_INFO_08 + tmp = ((gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] & 0xff) << 0x8); + CoreParamSet(sceHandle, 0x0000002b, (0xf0 | tmp) , 0); //< Additional parameter M set ES_INFO_0A + CoreParamSet(sceHandle, 0x0000002c, 0x036a , 0); //< Additional parameter M set ES_INFO_0C + CoreParamSet(sceHandle, 0x0000002d, 0x0100 , 0); //< Additional parameter M set ES_INFO_0E + CoreParamSet(sceHandle, 0x0003001d, 0x00bd , 0); //< Parameter M_E set only for initialization A_SID(DVB) + }else{ + CoreParamSet(sceHandle, 0x00000014, 0x002b , 0); //< Additional parameter M set ES_INFO_LENGTH + CoreParamSet(sceHandle, 0x00000032, 0xff81 , 0); //< Additional parameter M set ES_INFO_18 + tmp = ( (0x7 << 13) | (gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] & 0x1fff) ); + CoreParamSet(sceHandle, 0x00000033, tmp, 0); //< Additional parameter M set ES_INFO_1A + CoreParamSet(sceHandle, 0x00000034, 0xf00d , 0); //< Additional parameter M set ES_INFO_1C + CoreParamSet(sceHandle, 0x00000035, 0x0504 , 0); //< Additional parameter M set ES_INFO_1E + CoreParamSet(sceHandle, 0x00000036, 0x4143 , 0); //< Additional parameter M set ES_INFO_20 + CoreParamSet(sceHandle, 0x00000037, 0x2d33 , 0); //< Additional parameter M set ES_INFO_22 + CoreParamSet(sceHandle, 0x00000038, 0x8105 , 0); //< Additional parameter M set ES_INFO_24 + + switch(gp_FmbProperty[FMBEnmFuncModeEnc].audioBitrateCbr[FMBEnmAudioFmtAc3]) { + case 64: + CoreParamSet(sceHandle, 0x00000039, 0x0410, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0309, 0); //< Additional parameter M set ES_INFO_28 + break; + case 80: + CoreParamSet(sceHandle, 0x00000039, 0x0414, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0309, 0); //< Additional parameter M set ES_INFO_28 + break; + case 96: + CoreParamSet(sceHandle, 0x00000039, 0x0418, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0309, 0); //< Additional parameter M set ES_INFO_28 + break; + case 112: + CoreParamSet(sceHandle, 0x00000039, 0x041c, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0309, 0); //< Additional parameter M set ES_INFO_28 + break; + case 128: + CoreParamSet(sceHandle, 0x00000039, 0x0420, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 160: + CoreParamSet(sceHandle, 0x00000039, 0x0424, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 192: + CoreParamSet(sceHandle, 0x00000039, 0x0428, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 224: + CoreParamSet(sceHandle, 0x00000039, 0x042c, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 256: + CoreParamSet(sceHandle, 0x00000039, 0x0430, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 320: + CoreParamSet(sceHandle, 0x00000039, 0x0434, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 384: + CoreParamSet(sceHandle, 0x00000039, 0x0438, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + case 448: + CoreParamSet(sceHandle, 0x00000039, 0x043c, 0); //< Additional parameter M set ES_INFO_26 + CoreParamSet(sceHandle, 0x0000003a, 0x0509, 0); //< Additional parameter M set ES_INFO_28 + break; + default: + ASSERT_USR(FALSE, "Invalid audio bitrate."); + break; + } + CoreParamSet(sceHandle, 0x0000003b, 0x7f00 , 0); //< Additional parameter M set ES_INFO_2A + CoreParamSet(sceHandle, 0x0003001d, 0x00fd , 0); //< Parameter M_E set only for initialization A_SID(BD) + } + break; + + case FMBEnmAudioFmtAac: + CoreParamSet(sceHandle, 0x00000014, 0x000d , 0); //< Additional parameter M set ES_INFO_LENGTH + tmp = ( (gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] >> 0x8)& 0x1f); + CoreParamSet(sceHandle, 0x0000002a, (0xfe0 | tmp) , 0); //< Additional parameter M set ES_INFO_08 + tmp = ((gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] & 0xff) << 0x8); + CoreParamSet(sceHandle, 0x0000002b, (0xf0 | tmp) , 0); //< Additional parameter M set ES_INFO_0A + CoreParamSet(sceHandle, 0x0000002c, 0x0000 , 0); //< Additional parameter M set ES_INFO_0C + break; + + case FMBEnmAudioFmtLpcm: + CoreParamSet(sceHandle, 0x00000014, 0x0028 , 0); //< Additional parameter M set ES_INFO_LENGTH + CoreParamSet(sceHandle, 0x00000032, 0xff80 , 0); //< Additional parameter M set ES_INFO_18 + tmp = ( (0x7 << 13) | (gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid] & 0x1fff) ); + CoreParamSet(sceHandle, 0x00000033, tmp, 0); //< Additional parameter M set ES_INFO_1A + CoreParamSet(sceHandle, 0x00000034, 0xf00a , 0); //< Additional parameter M set ES_INFO_1C + CoreParamSet(sceHandle, 0x00000035, 0x0508 , 0); //< Additional parameter M set ES_INFO_1E + CoreParamSet(sceHandle, 0x00000036, 0x4844 , 0); //< Additional parameter M set ES_INFO_20 + CoreParamSet(sceHandle, 0x00000037, 0x4d56 , 0); //< Additional parameter M set ES_INFO_22 + CoreParamSet(sceHandle, 0x00000038, 0xff80 , 0); //< Additional parameter M set ES_INFO_24 + CoreParamSet(sceHandle, 0x00000039, 0x317f , 0); //< Additional parameter M set ES_INFO_26(2ch 16bit set) + break; + + default: + ASSERT_USR(FALSE, "Invalid audio type."); + break; + } + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} + diff --git a/fmb_player_apl/src/sce/FmbSceBitrate.c b/fmb_player_apl/src/sce/FmbSceBitrate.c new file mode 100644 index 0000000..c72de5c --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceBitrate.c @@ -0,0 +1,108 @@ +/** +* @brief The scenario that sets the video bitrate is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + + +/** +* @brief The VideoBitrate is set. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +static enum SceResultEnum SetVideoBitrate(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode != FMBEnmFuncModeDec, "Function mode is illegal.(VIDEO bitrate set)"); + + CoreParamSet(sceHandle, 0x0003000a, gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp.videoBitrateParam.muxRate, 0); //<Parameter M set MUX_RATE + CoreParamSet(sceHandle, 0x00040009, gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp.videoBitrateParam.vRateMode, 0); //<Set to initialize parameter V V_RATE_MODE + CoreParamSet(sceHandle, 0x0004000a, gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp.videoBitrateParam.vBitrate, 0); //<Set to initialize parameter V V_BITERATE + CoreParamSet(sceHandle, 0x0004000b, gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp.videoBitrateParam.vAveBitrate, 0); //<Set to initialize parameter V V_AVE_BITRATE + CoreParamSet(sceHandle, 0x0004001f, gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp.videoBitrateParam.vMinBitrate, 0); //<Set to initialize parameter V V_MIN_BITRATE + CoreParamSet(sceHandle, 0x00040020, gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp.videoBitrateParam.vMaxBitrate, 0); //<Set to initialize parameter V V_MAX_BITRATE + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief The AudioBitrate is set. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +static enum SceResultEnum SetAudioBitrate(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + enum FMBFuncModeEnum setmode; + enum FMBAudioFormatEnum afmt; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal.(AUDIO bitrate set)"); + + setmode = gp_FmbComProperty->setMode; + afmt = gp_FmbProperty[setmode].audioFmt; + + switch (afmt) { + case FMBEnmAudioFmtMpeg1l2: + case FMBEnmAudioFmtAc3: + case FMBEnmAudioFmtLpcm: + //< MPEG1L2, AC3, LPCM + CoreParamSet(sceHandle, 0x00050002, gp_FmbProperty[setmode].audioBitrateCbr[afmt], 0); //<Set to initialize parameter A A_BITERATE + break; + + case FMBEnmAudioFmtAac: + //< AAC + CoreParamSet(sceHandle, 0x00050002, gp_FmbProperty[setmode].audioBitrateVbrAverage, 0); //<Set to initialize parameter A A_BITERATE + CoreParamSet(sceHandle, 0x00050030, gp_FmbProperty[setmode].audioBitrateVbrPeak, 0); //<Set to initialize parameter A A_AAC_MAX_BITRATE + break; + default: + ASSERT_USR(FALSE, "AUDIO format is illegal.(AUDIO bitrate set)"); + break; + } + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief AudioBitrate scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceAudioBitrate[] = { + {SetAudioBitrate, 0, 0, 0}, //<Parameter A only for initialization A_BITRATE + {NULL, 0, 0, 0} +}; + +/** +* @brief VideoBitrate scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceVideoBitrate[] = { + {SetVideoBitrate, 0, 0, 0}, + {NULL, 0, 0, 0} +}; diff --git a/fmb_player_apl/src/sce/FmbSceDecode.c b/fmb_player_apl/src/sce/FmbSceDecode.c new file mode 100644 index 0000000..60dca48 --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceDecode.c @@ -0,0 +1,530 @@ +/** +* @brief The scenario of the decode is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + + +struct SceDecInfo { + enum FMBTsFormatEnum tsFormat; ///<Kind of TS format(188 ,192,192e) + int PidValue[FMBEnmPidMax]; ///<PID value + int audioFmtReload; ///<Audio Format Reload data +}; + +static struct SceDecInfo g_SecDecInfo; + +//It reproduces slowly. +static enum SceResultEnum DecodeSlow(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2); + +static enum SceResultEnum SceGetDecInfo(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2); + + +/** +* @brief Decode parameter scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecParam[] = { + {CoreParamSet,0x00030002,0x0000,0}, //< Parameter M set only for initialization STMODE + {CoreParamSet,0x0003000c,0x0001,0}, //< Parameter M set only for initialization DEC_SYNC_MODE + {CoreParamSet,0x0003000d,0x0002,0}, //< Parameter M set only for initialization DEC_WAIT_MODE + {CoreParamSet,0x00030001,0x0002,0}, //< Parameter M set only for initialization DEC_STC_MODE + {SceGetDecInfo,0,0,0}, + {CoreParamSetPtr,0x0003000e,(unsigned long)&g_SecDecInfo.tsFormat,0},//< Parameter M set only for initialization TS_PAKET_SIZE + {CoreParamSetPtr,0x00030016,(unsigned long)&g_SecDecInfo.PidValue[FMBEnmInputVideoPid],0}, //< Parameter M set only for initialization V_PID + {CoreParamSetPtr,0x00030017,(unsigned long)&g_SecDecInfo.PidValue[FMBEnmInputAudioPid],0}, //< Parameter M set only for initialization A_PID + {CoreParamSetPtr,0x0003001a,(unsigned long)&g_SecDecInfo.PidValue[FMBEnmInputPcrPid],0}, //< Parameter M set only for initialization PCR_PID + {CoreParamSetPtr,0x00030018,(unsigned long)&g_SecDecInfo.PidValue[FMBEnmInputPmtPid],0}, //< Parameter M set only for initialization PMT_PID + {CoreParamSetPtr,0x00030019,(unsigned long)&g_SecDecInfo.PidValue[FMBEnmInputSitPid],0}, //< Parameter M set only for initialization SIT_PID + {CoreParamSet,0x0003001e,0x0001,0}, //< Parameter M set only for initialization VOUT_SYNC_MODE + {CoreParamSet,0x00030044,0x0001,0}, //< Parameter M set only for initialization AMCK_MODE + {CoreParamSet,0x0004001b,0x0001,0}, //< Set to initialize parameter V VOUT_SWAP + {CoreParamSet,0x0004001c,0x0001,0}, //< Set to initialize parameter V VIN_SWAP + {CoreParamSet,0x00040016,0x0001,0}, //< Set to initialize parameter V errRatePpic + {CoreParamSet,0x00040017,0x0001,0}, //< Set to initialize parameter V errRateIpic + {CoreParamSet,0x00040018,0x0001,0}, //< Set to initialize parameter V errRateRefpic + {CoreParamSet,0x00040019,0x0001,0}, //< Set to initialize parameter V errRateBpic + {CoreParamSet,0x00050000,0x0000,0}, //< Parameter A only for initialization AV_RESYNC_THRESHOLD + {CoreParamSet,0x00050001,0x0000,0}, //< Parameter A only for initialization A_SAMPLE + {CoreParamSet,0x00050016,0x0001,0}, //< Parameter A only for initialization AOUT_MASTER + {CoreParamSet,0x00050014,0x0000,0}, //< Parameter A only for initialization AOUT_BIT_POSB + {CoreParamSet,0x00050015,0x0000,0}, //< Parameter A only for initialization AOUT_LSB_FIRST + {CoreParamSet,0x00050012,0x0001,0}, //< Parameter A only for initialization AOUT_LR_HLSET + {CoreParamSet,0x00050011,0x0001,0}, //< Parameter A only for initialization AOUT_I2S + {CoreParamSet,0x00050010,0x0002,0}, //< Parameter A only for initialization AOUT_LRCLK_SEL + {CoreParamSet,0x0005000f,0x0000,0}, //< Parameter A only for initialization AOUT_SCLK_SEL + {CoreParamSet,0x0005000d,0x0001,0}, //< Parameter A only for initialization AOUT_BCLK_HL + {CoreParamSet,0x0005000e,0x0000,0}, //< Parameter A only for initialization AOUT_BCLK_SEL + {CoreParamSet,0x00050018,0x0000,0}, //< Parameter A only for initialization ASOUT_OFFSET + {CoreParamSet,0x0005001a,0x0000,0}, //< Parameter A only for initialization MUTE_TIME + {CoreParamSetPtr,0x00020000,(unsigned long)&g_SecDecInfo.audioFmtReload, 0}, //< Additional parameter A A_MODE + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode parameter scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecParamExtsync[] = { + {CoreParamSet,0x0003003f,0x0000,0}, //< Parameter M set only for initialization VIDEO_LOOPBACK + {CoreParamSet,0x00030040,0x0000,0}, //< Parameter M set only for initialization HVIO_XOE + {CoreParamSet,0x00030041,0x0000,0}, //< Parameter M set only for initialization SEL_VINDT_VIO + {CoreParamSet,0x0004001b,0x0000,0}, //< Set to initialize parameter V VOUT_SWAP + {CoreParamSet,0x0004001c,0x0000,0}, //< Set to initialize parameter V VIN_SWAP + {CoreParamSet,0x00040098,0x0000,0}, //< Set to initialize parameter SCALE_FLAG + {CoreParamSet,0x0004009a,0x0000,0}, //< Set to initialize parameter V_SCALE_FORMAT + {CoreParamSet,0x0004009b,0x0000,0}, //< Set to initialize parameter SCALE_H_START_POS_SOURCE + {CoreParamSet,0x0004009c,0x0000,0}, //< Set to initialize parameter SCALE_V_START_POS_SOURCE + {CoreParamSet,0x0004009d,0x0000,0}, //< Set to initialize parameter SCALE_H_SIZE_SOURCE + {CoreParamSet,0x0004009e,0x0000,0}, //< Set to initialize parameter SCALE_V_SIZE_SOURCE + {CoreParamSet,0x000400a1,0x0000,0}, //< Set to initialize parameter SCALE_H_SIZE_DESTINATE + {CoreParamSet,0x000400a2,0x0000,0}, //< Set to initialize parameter SCALE_V_SIZE_DESTINATE + {NULL, 0, 0, 0} +}; + + +/** +* @brief Decode parameter scenario table(OtherPort). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecParamOtherPort[] = { + {CoreParamSet,0x0003000c,0x0000,0}, //< Parameter M set only for initialization DEC_SYNC_MODE + {NULL, 0, 0, 0} +}; + +/** +* @brief Reload for decode scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecReloadFile[] = { + {CoreParamSet,0x00030003,0x0001,0}, //< Parameter M set only for initialization STCLK_HL + {CoreParamSet,0x00030005,0x0000,0}, //< Parameter M set only for initialization STCLK_HL_IO + {SceGetDecInfo,0,0,0}, + {CoreCmdSendSysPtr,0x04,0x11,(unsigned long)&g_SecDecInfo.audioFmtReload}, //< Send System Command cmd, sub_cmd , bodyReload, Decode, audio + {WaitSysAckFor,0x04,0,0}, //< Wait for system command ack cack_IDReload + {NULL, 0, 0, 0} +}; + +struct SceTableType m_sceDecReloadOtherPort[] = { + {CoreParamSet,0x00030003,0x0000,0}, //< Parameter M set only for initialization STCLK_HL + {CoreParamSet,0x00030005,0x0001,0}, //< Parameter M set only for initialization STCLK_HL_IO + {SceGetDecInfo,0,0,0}, + {CoreCmdSendSysPtr,0x04,0x11,(unsigned long)&g_SecDecInfo.audioFmtReload}, //< Send System Command cmd, sub_cmd , bodyReload, Decode, audio + {WaitSysAckFor,0x04,0,0}, //< Wait for system command ack cack_IDReload + {NULL, 0, 0, 0} +}; + +struct SceTableType *m_sceDecReload[] = { + m_sceDecReloadFile, m_sceDecReloadOtherPort +}; + + +/** +* @brief Decode start scenario table (File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStartFile[] = { + {CoreCmdSendVideo,0x01,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart normal decoding, NORMAL, - + {CoreCmdSendAudio,0x00,0x00,0}, //< Send Audio Command A_MUTE, A_CHMute canceled, (L, R) Stereo + {WaitVideoMsgFor,0x01,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODENormal decoding state, NORMAL + {CoreCmdSendSys,0x0a,0x01,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, Start, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_ID Stream Start + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0001}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0000}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_OPT_ADDR, 0x0010}, //< Decode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0002}, //< Decode stream interface control + {StartSendThread, 0, 0, 0}, //< Start Send stream thread(H264) + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode start scenario table (except File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStartOtherPort[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0001}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0000}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_OPT_ADDR, 0x0000}, //< Decode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0002}, //< Decode stream interface control + {CoreCmdSendVideo,0x01,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart normal decoding, NORMAL, - + {CoreCmdSendAudio,0x00,0x00,0}, //< Send Audio Command A_MUTE, A_CHMute canceled, (L, R) Stereo + {WaitVideoMsgFor,0x01,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODENormal decoding state, NORMAL + {CoreCmdSendSys,0x0a,0x01,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, Start, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_ID Stream Start + {NULL, 0, 0, 0} +}; + +/** +* @brief 1pic decode start scenario table (File port). +* @note None +* @attention None +*/ + +struct SceTableType m_sceDecStart1picFile[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0001}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0000}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_OPT_ADDR, 0x0010}, //< Decode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0002}, //< Decode stream interface control + {CoreCmdSendVideo,0x02,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart I-Only decoding, NORMAL, - + {WaitVideoMsgFor,0x02,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEI-Only decoding state, NORMAL + {CoreCmdSendSys,0x0a,0x01,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, Start, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_ID Stream Start + {StartSendThread, 0, 0, 0}, //< Start Send stream thread(H264) + {NULL, 0, 0, 0} +}; + + +/** +* @brief 1pic decode start scenario table (except File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStart1picOtherPort[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0001}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0000}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_OPT_ADDR, 0x0000}, //< Decode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0002}, //< Decode stream interface control + {CoreCmdSendVideo,0x02,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart I-Only decoding, NORMAL, - + {WaitVideoMsgFor,0x02,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEI-Only decoding state, NORMAL + {CoreCmdSendSys,0x0a,0x01,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, Start, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_ID Stream Start + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode stop scenario table (File Port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStopFile[] = { + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {StopSendThread, 0, 0, 0}, //< Stop Send stream thread(H264) + {WaitThreadEndFor, FMBEnmStreamSend, 0, 0}, //< Wait Stop Send stream thread(H264) + {CoreCmdSendSys,0x0a,0x02,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, End, - + {WaitSysAckFor,0x0A,0,0}, //< Wait for system command ack cack_IDStream + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, NORMAL, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, NORMAL + {NULL, 0, 0, 0} +}; + + +/** +* @brief Decode stop scenario table (except File Port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStopOtherPort[] = { + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {CoreCmdSendSys,0x0a,0x02,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, End, - + {WaitSysAckFor,0x0A,0,0}, //< Wait for system command ack cack_IDStream + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, NORMAL, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, NORMAL + {NULL, 0, 0, 0} +}; + + +/** +* @brief Decode autostop scenario table (File Port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecAutoStopFile[] = { + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {CoreCmdSendSys,0x0a,0x02,0x00}, //< stop stream + {WaitSysAckFor,0x0a,0,0}, //< wait for stream stop + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode sequence end stop scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStopCore[] = { + {CoreCmdSendVideo,0x00,0x00,0}, //< stop decode + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< wait for decode stop + {NULL, 0, 0, 0} +}; + +/** +* @brief 1pic decode stop scenario table (File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStop1picFile[] = { + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {StopSendThread, 0, 0, 0}, //< Stop Send stream thread(H264) + {WaitThreadEndFor, FMBEnmStreamSend, 0, 0}, //< Wait Stop Send stream thread(H264) + {CoreCmdSendSys,0x0a,0x02,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, End, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_IDStream + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, Normal, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, Normal + {NULL, 0, 0, 0} +}; + +/** +* @brief 1pic decode stop scenario table (except File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStop1picOtherPort[] = { + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {CoreCmdSendSys,0x0a,0x02,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, End, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_IDStream + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, Normal, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, Normal + {NULL, 0, 0, 0} +}; + +/** +* @brief 1pic decode stop scenario table (File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceDecAutoStop1picFile[] = { + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {CoreCmdSendSys,0x0a,0x02,0x00}, //< stop stream + {WaitSysAckFor,0x0a,0,0}, //< wait for stream stop + {NULL, 0, 0, 0} +}; + +/** +* @brief Start and pause decode scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecStartPause[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0001}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0000}, //< Decode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_OPT_ADDR, 0x0010}, //< Decode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_DEC_IF_CTL_ADDR, 0x0002}, //< Decode stream interface control + {CoreCmdSendVideo,0x01,0x02,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart normal decoding, PAUSE, - + {WaitVideoMsgFor, 0x01, SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODENormal decoding + {CoreCmdSendSys,0x0a,0x01,0x00}, //< Send System Command cmd, sub_cmd , bodyStream, Start, - + {WaitSysAckFor,0x0a,0,0}, //< Wait for system command ack cack_ID Stream Start + {StartSendThread, 0, 0, 0, }, //< Start Send stream thread(H264) + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_OFF , 0}, + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode frame advance scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecFrameAdvance[] = { + {CoreCmdSendVideo, 0x01, 0x03,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart normal decoding, Frame advance, - + {WaitVideoMsgFor, 0x01, 0x03,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStart normal decoding, Frame advance + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode restart scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecNormal[] = { + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {CoreCmdSendVideo, 0x01, 0x00,0}, //< decode start + {WaitVideoMsgFor, 0x01, SCE_IGNORE,SCE_IGNORE}, //< wait for decode start + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_ON , 0}, + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode pause start scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecPause[] = { + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {CoreCmdSendVideo, 0x01, 0x02,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart normal decoding, PAUSE, - + {WaitVideoMsgFor, 0x01, 0x02,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStart normal decoding, PAUSE + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_OFF , 0}, + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode slow scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecSlow[] = { + {DecodeSlow, 0, 0, 0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart normal decoding, SLOW, - + {WaitVideoMsgFor, 0x01, 0x01, SCE_IGNORE}, + {DrvSetInternal, FMB_DATA_TYPE_WDMAFLAG , FMB_DATA_DMAFLAG_OFF , 0}, + {NULL, 0, 0, 0} +}; + +/** +* @brief Decode slow scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceDecSlowToSlow[] = { + {DecodeSlow, 0, 0, 0}, //< Slow + {NULL, 0, 0, 0} +}; + +/** +* @brief AUDIO mute on scenario table. +* @note None +* @attention None +*/ +static struct SceTableType m_sceDecMuteOn[] = { + {CoreCmdSendAudio, 0x01, 0x00,0}, //< Send Audio Command A_MUTE, A_CHMute activated, (L, R) Stereo + {WaitAudioMsgFor, 0x01, SCE_IGNORE,0}, //< Wait for audio message A_MUTE, A_CHMute activated, (L, R) Stereo + {NULL, 0, 0, 0} +}; + +/** +* @brief AUDIO mute off scenario table. +* @note None +* @attention None +*/ +static struct SceTableType m_sceDecMuteOff[] = { + {CoreCmdSendAudio, 0x00, 0x00,0}, //< Send Audio Command A_MUTE, A_CHMute canceled, (L, R) Stereo + {WaitAudioMsgFor, 0x00, SCE_IGNORE,0}, //< Wait for audio message A_MUTE, A_CHMute canceled, (L, R) Stereo + {NULL, 0, 0, 0} +}; + +/** +* @brief AUDIO mute scenario table(1st Table). +* @note None +* @attention None +*/ +struct SceTableType *m_sceDecMute[] = { + m_sceDecMuteOff, m_sceDecMuteOn +}; + +/** +* @brief Reset decode slow speed. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum ResetSlowSpeed(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + struct FMBProperty *p_Property; + FMB_FUNC(TRUE); + + p_Property = FmbGetProperty( SceGetDevNum(sceHandle) ); + p_Property[FMBEnmFuncModeDec].speedSlow = 0; + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Set decode slow speed. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +static enum SceResultEnum DecodeSlow(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + int coefficient; + int vDispTime; + enum SceResultEnum result; + struct FMBProperty *p_Property; + + FMB_FUNC(TRUE); + + p_Property = FmbGetProperty( SceGetDevNum(sceHandle) ); + + if(p_Property[FMBEnmFuncModeDec].speedSlow >= 20){ + p_Property[FMBEnmFuncModeDec].speedSlow = 0; + } + + p_Property[FMBEnmFuncModeDec].speedSlow *= 2; + + switch (p_Property[FMBEnmFuncModeDec].videoFrm) { + case FMBEnmVideoFrm_60i: + case FMBEnmVideoFrm_5994i: + case FMBEnmVideoFrm_50i: + if(p_Property[FMBEnmFuncModeDec].speedSlow <= 1){ + p_Property[FMBEnmFuncModeDec].speedSlow = 2.5; + } + coefficient = 4; + break; + case FMBEnmVideoFrm_60p: + case FMBEnmVideoFrm_5994p: + case FMBEnmVideoFrm_50p: + if(p_Property[FMBEnmFuncModeDec].speedSlow <= 1){ + p_Property[FMBEnmFuncModeDec].speedSlow = 5; + } + coefficient = 2; + break; + default: + ASSERT_USR(FALSE, "Invalid video format value."); + } + + vDispTime = (int)(p_Property[FMBEnmFuncModeDec].speedSlow * coefficient); /* pgr0000 */ + + result = CoreCmdSendVideo(sceHandle, 0x01, 0x01, vDispTime); + + FMB_FUNC(FALSE); + return result; +} + +/** +* @brief . +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +static enum SceResultEnum SceGetDecInfo(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + struct FMBComProperty *p_ComProperty; + struct FMBProperty *p_Property; + + FMB_FUNC(TRUE); + + p_ComProperty = FmbGetComProperty( SceGetDevNum(sceHandle) ); + p_Property = FmbGetProperty( SceGetDevNum(sceHandle) ); + + g_SecDecInfo.tsFormat = p_ComProperty->tsFormat[FMBEnmInputTsPacket]; + g_SecDecInfo.PidValue[FMBEnmInputVideoPid] = p_ComProperty->PidValue[FMBEnmInputVideoPid]; + g_SecDecInfo.PidValue[FMBEnmInputAudioPid] = p_ComProperty->PidValue[FMBEnmInputAudioPid]; + g_SecDecInfo.PidValue[FMBEnmInputPcrPid] = p_ComProperty->PidValue[FMBEnmInputPcrPid]; + g_SecDecInfo.PidValue[FMBEnmInputPmtPid] = p_ComProperty->PidValue[FMBEnmInputPmtPid]; + g_SecDecInfo.PidValue[FMBEnmInputSitPid] = p_ComProperty->PidValue[FMBEnmInputSitPid]; + + g_SecDecInfo.audioFmtReload = p_Property[FMBEnmFuncModeDec].audioFmtReload; + + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} diff --git a/fmb_player_apl/src/sce/FmbSceEncode.c b/fmb_player_apl/src/sce/FmbSceEncode.c new file mode 100644 index 0000000..1d5b6e6 --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceEncode.c @@ -0,0 +1,365 @@ +/** +* @brief The scenario of encode is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> +#include "FmbCmn.h" + +struct SceEncInfo { + enum FMBTsFormatEnum tsFormat; ///<Kind of TS format(188 ,192,192e) + int PidValue[FMBEnmPidMax]; ///<PID value + int audioFmtReload; ///<Audio Format Reload data +}; + +static struct SceEncInfo g_SecEncInfo; + +static enum SceResultEnum SceGetEncInfo(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2); + + +/** +* @brief Encode parameter scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceEncParam[] = { + {CoreParamSet, 0x00030002, 0x0000, 0}, //< Parameter M set only for initialization STMODE + {CoreParamSet, 0x0003000b, 0x0002, 0}, //< Parameter M set only for initialization ENC_WAIT_MODE + {CoreParamSet, 0x00030000, 0x0002, 0}, //< Parameter M set only for initialization ENC_STC_MODE + {SceGetEncInfo,0,0,0}, + {CoreParamSetPtr, 0x0003000e, (unsigned long)&g_SecEncInfo.tsFormat, 0}, //Parameter M set only for initialization TS_PAKET_SIZE + {CoreParamSetPtr, 0x00030016, (unsigned long)&g_SecEncInfo.PidValue[FMBEnmOutputVideoPid], 0}, //< Parameter M set only for initialization V_PID + {CoreParamSetPtr, 0x00030017, (unsigned long)&g_SecEncInfo.PidValue[FMBEnmOutputAudioPid], 0}, //< Parameter M set only for initialization A_PID + {CoreParamSetPtr, 0x0003001a, (unsigned long)&g_SecEncInfo.PidValue[FMBEnmOutputPcrPid], 0}, //< Parameter M set only for initialization PCR_PID + {CoreParamSetPtr, 0x00030018, (unsigned long)&g_SecEncInfo.PidValue[FMBEnmOutputPmtPid], 0}, //< Parameter M set only for initialization PMT_PID + {CoreParamSetPtr, 0x00030019, (unsigned long)&g_SecEncInfo.PidValue[FMBEnmOutputSitPid], 0}, //< Parameter M set only for initialization SIT_PID + {CoreParamSet, 0x0003003f, 0x0001, 0}, //< Parameter M set only for initialization VIDEO_LOOPBACK + {CoreParamSet, 0x00030042, 0x0001, 0}, //< Parameter M set only for initialization AUDIO_LOOPBACK + {CoreParamSet, 0x00030044, 0x0000, 0}, //< Parameter M set only for initialization AMCK_MODE + {CoreParamSet, 0x0000001e, 0x6308, 0}, //< Additional parameter M set TS_INFO_00 + {WritePeakRateInTsInfo, 0xc0, 0xff, 0}, //< Additional parameter M set TS_INFO_02/04 + {CoreParamSet, 0x00000021, 0xffff, 0}, //< Additional parameter M set TS_INFO_06 + {CoreParamSet, 0x00000022, 0xffff, 0}, //< Additional parameter M set TS_INFO_08 + {CoreParamSet, 0x00000012, 0x000a, 0}, //< Additional parameter M set TS_INFO_LENGTH + {CoreParamSet, 0x00000016, 0x0504, 0}, //< Additional parameter M set PROGRAM_INFO_00 + {CoreParamSet, 0x00000017, 0x4844, 0}, //< Additional parameter M set PROGRAM_INFO_02 + {CoreParamSet, 0x00000018, 0x4d56, 0}, //< Additional parameter M set PROGRAM_INFO_04 + {CoreParamSet, 0x00000019, 0x8804, 0}, //< Additional parameter M set PROGRAM_INFO_06 + {CoreParamSet, 0x0000001a, 0x0fff, 0}, //< Additional parameter M set PROGRAM_INFO_08 + {CoreParamSet, 0x0000001b, 0xfcfc, 0}, //< Additional parameter M set PROGRAM_INFO_0A + {CoreParamSet, 0x00000013, 0x000c, 0}, //< Additional parameter M set PROGRAM_INFO_LENGTH + {CoreParamSet, 0x00000015, 0x0000, 0}, //< Additional parameter M set SERVICE_INFO_LENGTH + {CoreParamSet, 0x00030006, 0x0010, 0}, //< Parameter M set only for initialization STCLK + {CoreParamSet, 0x00030009, 0x0002, 0}, //< Parameter M set only for initialization AUTO_NULL + {CoreParamSet, 0x00030008, 0x0000, 0}, //< Parameter M set only for initialization PCR_FIR_ST + {CoreParamSet, 0x00030013, 0x0000, 0}, //< Parameter M set only for initialization INITIAL_STC_ext + {CoreParamSet, 0x00030010, 0x0000, 0}, //< Parameter M set only for initialization INITIAL_STC_H + {CoreParamSet, 0x00030011, 0x0000, 0}, //< Parameter M set only for initialization INITIAL_STC_L + {CoreParamSet, 0x00030012, 0x0000, 0}, //< Parameter M set only for initialization INITIAL_STC_LL + {CoreParamSet, 0x00030014, 0x0000, 0}, //< Parameter M set only for initialization INITIAL_TIME_STAMP_H + {CoreParamSet, 0x00030015, 0x0000, 0}, //< Parameter M set only for initialization INITIAL_TIME_STAMP_L + {CoreParamSet, 0x0003001b, 0x00e0, 0}, //< Parameter M set only for initialization V_SID + {CoreParamSet, 0x00040005, 0x0001, 0}, //< Set to initialize parameter V V_TEMPORAL_DIRECT_ON + {CoreParamSet, 0x00040013, 0x0000, 0}, //< Set to initialize parameter V V_CL_GOP + {CoreParamSet, 0x00040014, 0x0000, 0}, //< Set to initialize parameter V V_ALIGN + {CoreParamSet, 0x00040012, 0x0003, 0}, //< Set to initialize parameter V V_EOS + {CoreParamSet, 0x0004001c, 0x0001, 0}, //< Set to initialize parameter V VIN_SWAP + {CoreParamSet, 0x0004001b, 0x0001, 0}, //< Set to initialize parameter V VOUT_SWAP + {CoreParamSet, 0x0005000c, 0x0000, 0}, //< Parameter A only for initialization AIN_MASTER + {CoreParamSet, 0x0005000a, 0x0000, 0}, //< Parameter A only for initialization AIN_BIT_POSB + {CoreParamSet, 0x0005000b, 0x0000, 0}, //< Parameter A only for initialization AIN_LSB_FIRST + {CoreParamSet, 0x00050008, 0x0001, 0}, //< Parameter A only for initialization AIN_LR_HLSET + {CoreParamSet, 0x00050007, 0x0001, 0}, //< Parameter A only for initialization AIN_I2S + {CoreParamSet, 0x00050006, 0x0002, 0}, //< Parameter A only for initialization AIN_LRCLK_SEL + {CoreParamSet, 0x00050005, 0x0000, 0}, //< Parameter A only for initialization AIN_SCLK_SEL + {CoreParamSet, 0x00050004, 0x0000, 0}, //< Parameter A only for initialization AIN_BCLK_SEL + {CoreParamSet, 0x00050003, 0x0000, 0}, //< Parameter A only for initialization AIN_BCLK_HL + {CoreParamSet, 0x0005001c, 0x0000, 0}, //< Parameter A only for initialization ASIN_OFFSET + {CoreParamSet, 0x00050001, 0x0000, 0}, //< Parameter A only for initialization A_SAMPLE + {CoreParamSet, 0x00050009, 0x0000, 0}, //< Parameter A only for initialization AIN_DLEHGTH + {CoreParamSetPtr, 0x00020000, (unsigned long)&g_SecEncInfo.audioFmtReload, 0}, //< Additional parameter A A_MODE + {NULL, 0, 0, 0} +}; + +/** +* @brief Encode parameter scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceEncParamExtsync[] = { + {CoreParamSet, 0x00030041, 0x0001, 0}, //< Parameter M set only for initialization SEL_VINDT_VIO + {CoreParamSet, 0x00030044, 0x0001, 0}, //< Parameter M set only for initialization AMCK_MODE + {CoreParamSet, 0x0004001b, 0x0000, 0}, //< Set to initialize parameter V VOUT_SWAP + {CoreParamSet, 0x0005000c, 0x0001, 0}, //< Parameter A only for initialization AIN_MASTER + {CoreParamSet, 0x00040098, 0x0000, 0}, //< Set to initialize parameter SCALE_FLAG + {CoreParamSet, 0x0004009a, 0x0000, 0}, //< Set to initialize parameter V_SCALE_FORMAT + {CoreParamSet, 0x0004009b, 0x0000, 0}, //< Set to initialize parameter SCALE_H_START_POS_SOURCE + {CoreParamSet, 0x0004009c, 0x0000, 0}, //< Set to initialize parameter SCALE_V_START_POS_SOURCE + {CoreParamSet, 0x0004009d, 0x0000, 0}, //< Set to initialize parameter SCALE_H_SIZE_SOURCE + {CoreParamSet, 0x0004009e, 0x0000, 0}, //< Set to initialize parameter SCALE_V_SIZE_SOURCE + {CoreParamSet, 0x000400a1, 0x0000, 0}, //< Set to initialize parameter SCALE_H_SIZE_DESTINATE + {CoreParamSet, 0x000400a2, 0x0000, 0}, //< Set to initialize parameter SCALE_V_SIZE_DESTINATE + {NULL, 0, 0, 0} +}; + + +/** +* @brief Encode reload scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceEncReloadFile[] = { + {CoreParamSet,0x00030003,0x0000,0}, //< Parameter M set only for initialization STCLK_HL + {CoreParamSet,0x00030005,0x0001,0}, //< Parameter M set only for initialization STCLK_IO + {CoreParamSet,0x00030006,0x0000,0}, //< Parameter M set only for initialization STCLK + {SceGetEncInfo,0,0,0}, + {CoreCmdSendSysPtr,0x04,0x01,(unsigned long)&g_SecEncInfo.audioFmtReload}, //Send System Command cmd, sub_cmd , bodyReload, Encode, MPEG-layer2 + {WaitSysAckFor,0x04,0,0}, //Wait for system command ack cack_IDReload + {NULL, 0, 0, 0} +}; +struct SceTableType m_sceEncReloadOtherPort[] = { + {CoreParamSet,0x00030003,0x0001,0}, //< Parameter M set only for initialization STCLK_HL + {CoreParamSet,0x00030005,0x0000,0}, //< Parameter M set only for initialization STCLK_IO + {CoreParamSet,0x00030006,0x0006,0}, //< Parameter M set only for initialization STCLK + {SceGetEncInfo,0,0,0}, + {CoreCmdSendSysPtr,0x04,0x01,(unsigned long)&g_SecEncInfo.audioFmtReload}, //Send System Command cmd, sub_cmd , bodyReload, Encode, MPEG-layer2 + {WaitSysAckFor,0x04,0,0}, //Wait for system command ack cack_IDReload + {NULL, 0, 0, 0} +}; + +struct SceTableType *m_sceEncReload[] = { + m_sceEncReloadFile, m_sceEncReloadOtherPort +}; + +/** +* @brief 1pic encode scenario table for interlace. +* @note None +* @attention None +*/ +struct SceTableType m_sceEnc1PicInterlace[] = { + {CoreParamSet,0x0004000f,0x0001,0}, //< Set to initialize parameter V V_IP_FORMAT + {NULL, 0, 0, 0} +}; + + + +/** +* @brief 1pic encode scenario table for progressive. +* @note None +* @attention None +*/ +struct SceTableType m_sceEnc1PicProgressive[] = { + {CoreParamSet,0x0004000f,0x0005,0}, //< Set to initialize parameter V V_IP_FORMAT + {NULL, 0, 0, 0} +}; + + +/** +* @brief 1pic encode reload scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceEncReload1PicFile[] = { + {CoreParamSet,0x00030003,0x0000,0}, //< Parameter M set only for initialization STCLK_HL + {CoreParamSet,0x00030005,0x0001,0}, //< Parameter M set only for initialization STCLK_IO + {CoreCmdSendSys,0x04,0x02,0x0000}, //< Send System Command cmd, sub_cmd , bodyReload, 1pic-Encode, - + {WaitSysAckFor,0x04,0,0}, //< Wait for system command ack cack_IDReload + {NULL, 0, 0, 0} +}; + +struct SceTableType m_sceEncReload1PicOtherPort[] = { + {CoreParamSet,0x00030003,0x0001,0}, //< Parameter M set only for initialization STCLK_HL + {CoreParamSet,0x00030005,0x0000,0}, //< Parameter M set only for initialization STCLK_IO + {CoreParamSet,0x00030006,0x0006,0}, //< Parameter M set only for initialization STCLK + {CoreCmdSendSys,0x04,0x02,0x0000}, //< Send System Command cmd, sub_cmd , bodyReload, 1pic-Encode, - + {WaitSysAckFor,0x04,0,0}, //< Wait for system command ack cack_IDReload + {NULL, 0, 0, 0} +}; +struct SceTableType *m_sceEncReload1Pic[] = { + m_sceEncReload1PicFile, m_sceEncReload1PicOtherPort +}; + +/** +* @brief Encode start scenario table (File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceEncStartFile[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0001}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0000}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_OPT_ADDR, 0x0010}, //< Encode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0002}, //< Encode stream interface control + {StartRecvThread, 0, 0, 0}, + {CoreCmdSendVideo, 0x01,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart encoding, NORMAL, - + {WaitVideoMsgFor, 0x01,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStart encoding, NORMAL + {NULL, 0, 0, 0} +}; + + +/** +* @brief Encode start scenario table (except File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceEncStartOtherPort[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0001}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0000}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_OPT_ADDR, 0x0000}, //< Encode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0002}, //< Encode stream interface control + {CoreCmdSendVideo, 0x01,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart encoding, NORMAL, - + {WaitVideoMsgFor, 0x01,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStart encoding, NORMAL + {NULL, 0, 0, 0} +}; + + +/** +* @brief 1pic encode start scenario table (File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceEnc1PicStartFile[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0001}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0000}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_OPT_ADDR, 0x0010}, //< Encode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0002}, //< Encode stream interface control + {StartRecvThread, 0, 0, 0}, + {CoreCmdSendVideo, 0x01,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart encoding, NORMAL, - + {WaitVideoMsgFor,0x02,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODE Output NULL, NORMAL + {StopRecvThread, 0, 0, 0}, + {WaitThreadEndFor, FMBEnmStreamRcv, 0, 0}, + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, NORMAL, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, NORMAL + {NULL, 0, 0, 0} +}; + +/** +* @brief 1pic encode start scenario table (except File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceEnc1PicStartOtherPort[] = { + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0001}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0000}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_OPT_ADDR, 0x0000}, //< Encode stream interface Option control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0002}, //< Encode stream interface control + {CoreCmdSendVideo,0x01,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStart encoding, NORMAL, - + {WaitVideoMsgFor,0x02,SCE_IGNORE,SCE_IGNORE}, //< Send Video Command MODE, SUB_MODEOutput NULL, NORMAL + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, NORMAL, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, NORMAL + {NULL, 0, 0, 0} +}; + + +/** +* @brief Encode stop scenario table (File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceEncStopFile[] = { + + {CoreCmdSendVideo,0x02,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEOutput NULL, NORMAL, - + {WaitSysMsgFor,0x02,0x1,0x1000}, //< Wait for system message STRM_SIZE + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, NORMAL, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, NORMAL + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_OPT_ADDR, 0x0090}, //< Encode stream interface Option control + {StopRecvThread, 0, 0, 0}, + {WaitThreadEndFor, FMBEnmStreamRcv, 0, 0}, + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0001}, //< Encode stream interface control + {PciSetReg, PCI_TYPE_BAR1, PCI_ENC_IF_CTL_ADDR, 0x0000}, //< Encode stream interface control + {NULL, 0, 0, 0} +}; + +/** +* @brief Encode stop scenario table (except File port). +* @note None +* @attention None +*/ +struct SceTableType m_sceEncStopOtherPort[] = { + {CoreCmdSendVideo,0x02,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEOutput NULL, NORMAL, - + {WaitVideoMsgFor,0x02,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEOutput NULL, NORMAL + {CoreCmdSendVideo,0x00,0x00,0}, //< Send Video Command MODE, SUB_MODE, VDISPTIMEStop, NORMAL, - + {WaitVideoMsgFor,0x00,SCE_IGNORE,SCE_IGNORE}, //< Wait for video message MODE, SUB_MODEStop, NORMAL + {NULL, 0, 0, 0} +}; + +/** +* @brief The value is written in Peak-Rate of TS-Info according to Mux-Rate. +* @param[in] sceHandle Scenario handle +* @param[in] tsInfo1c Value of TS_INFO[0x1c] +* @param[in] tsInfo1f Value of TS_INFO[0x1f] +* @param[in] dummy ignored +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum WritePeakRateInTsInfo(HANDLE sceHandle, unsigned long tsInfo1c, unsigned long tsInfo1f, unsigned long dummy) +{ + unsigned short muxRate; + unsigned short peakRate; + unsigned short tsInfo1c1d; + unsigned short tsInfo1e1f; + struct FMBProperty *p_Property; + struct FMBComProperty *p_ComProperty; + + FMB_FUNC(TRUE); + + p_ComProperty = FmbGetComProperty( SceGetDevNum(sceHandle) ); + p_Property = FmbGetProperty( SceGetDevNum(sceHandle) ); + + muxRate = (unsigned short)p_Property[p_ComProperty->setMode].videoBitrateProp.videoBitrateParam.muxRate; + + peakRate = muxRate * 1000L / 400; + tsInfo1c1d = ((unsigned short)tsInfo1c << 8) | (peakRate >> 8); //0xc000; + tsInfo1e1f = (peakRate << 8) | (unsigned short)tsInfo1f; //0x00ff; + + CoreParamSet(sceHandle, 0x0000001f, tsInfo1c1d, 0); //Additional parameter M set TS_INFO_02Value that changes depending on bit rate. + CoreParamSet(sceHandle, 0x00000020, tsInfo1e1f, 0); //Additional parameter M set TS_INFO_04Value that changes depending on bit rate. + + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} + +/** +* @brief . +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return scenario result +* @note None +* @attention None +*/ +static enum SceResultEnum SceGetEncInfo(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + struct FMBProperty *p_Property; + struct FMBComProperty *p_ComProperty; + + FMB_FUNC(TRUE); + + p_ComProperty = FmbGetComProperty( SceGetDevNum(sceHandle) ); + p_Property = FmbGetProperty( SceGetDevNum(sceHandle) ); + + g_SecEncInfo.tsFormat = p_ComProperty->tsFormat[FMBEnmOutputTsPacket]; + g_SecEncInfo.PidValue[FMBEnmOutputVideoPid] = p_ComProperty->PidValue[FMBEnmOutputVideoPid]; + g_SecEncInfo.PidValue[FMBEnmOutputAudioPid] = p_ComProperty->PidValue[FMBEnmOutputAudioPid]; + g_SecEncInfo.PidValue[FMBEnmOutputPcrPid] = p_ComProperty->PidValue[FMBEnmOutputPcrPid]; + g_SecEncInfo.PidValue[FMBEnmOutputPmtPid] = p_ComProperty->PidValue[FMBEnmOutputPmtPid]; + g_SecEncInfo.PidValue[FMBEnmOutputSitPid] = p_ComProperty->PidValue[FMBEnmOutputSitPid]; + + g_SecEncInfo.audioFmtReload = p_Property[FMBEnmFuncModeEnc].audioFmtReload; + + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} diff --git a/fmb_player_apl/src/sce/FmbSceReset.c b/fmb_player_apl/src/sce/FmbSceReset.c new file mode 100644 index 0000000..8f97c63 --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceReset.c @@ -0,0 +1,32 @@ +/** +* @brief The scenario of reset is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + +/** +* @brief System reset scenario table. +* @note None +* @attention None +*/ +struct SceTableType m_sceSytemIdle[] = { + {RestStreamThread, 0, 0, 0}, //< Rest stream thread + {ResetSlowSpeed, 0, 0, 0}, //< Reset slow speed + {DrvResetCmdInfo,0x07,0,0}, + {CoreCmdSendSys,0x02,0x00,0x00}, //>Send System Command cmd, sub_cmd , bodyReset, + {WaitSysAckFor,0x02,0,0}, //>Wait for system command ack cack_IDReset + {DrvResetFactor,FMB_FACTOR_ASYNC_ALL,0,0}, + {NULL, 0, 0, 0} +}; + diff --git a/fmb_player_apl/src/sce/FmbSceStream.c b/fmb_player_apl/src/sce/FmbSceStream.c new file mode 100644 index 0000000..f094cca --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceStream.c @@ -0,0 +1,144 @@ +/** +* @brief The scenario that sets the stream control is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + + +/** +* @brief Start and create thread for send. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum StartSendThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + BOOL result; + struct FMBComProperty *p_ComProperty; + + FMB_FUNC(TRUE); + + result = FmbStreamBegin(FMBEnmStreamSend, sceHandle); + ASSERT_USR(result == TRUE, "Impossible start to send the stream."); + + p_ComProperty = FmbGetComProperty( SceGetDevNum(sceHandle) ); + p_ComProperty->waitStreamSendEnd = FMBEnmStreamSendEndOn; + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Start and create thread for receive. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum StartRecvThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + BOOL result; + + FMB_FUNC(TRUE); + + result = FmbStreamBegin(FMBEnmStreamRcv, sceHandle); + ASSERT_USR(result == TRUE, "Impossible start to receive the stream."); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief Stop thread for send. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum StopSendThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + struct FMBComProperty *p_ComProperty; + struct FMBDeviceInfo *p_DevInfo; + enum FMBDeviceNumEnum deviceNum; + + FMB_FUNC(TRUE); + + deviceNum = SceGetDevNum(sceHandle); + p_DevInfo = FmbGetDevInfo(deviceNum); + + FmbSetStreamStop(FMBEnmStreamSend, &p_DevInfo->t_StreamThread_A[FMBEnmStreamSend] ); + + p_ComProperty = FmbGetComProperty( deviceNum ); + p_ComProperty->waitStreamSendEnd = FMBEnmStreamSendEndOff; + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + + +/** +* @brief Stop thread for receive. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum StopRecvThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + enum FMBDeviceNumEnum deviceNum; + struct FMBDeviceInfo *p_DevInfo; + FMB_FUNC(TRUE); + + deviceNum = SceGetDevNum(sceHandle); + p_DevInfo = FmbGetDevInfo(deviceNum); + + FmbSetStreamStop(FMBEnmStreamRcv, &p_DevInfo->t_StreamThread_A[FMBEnmStreamRcv] ); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} +/** +* @brief Rest thread for stream. +* @param[in] sceHandle Scenario handle +* @param[in] dummy0 +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum RestStreamThread(HANDLE sceHandle, unsigned long dummy0, unsigned long dummy1, unsigned long dummy2) +{ + FMB_FUNC(TRUE); + + FmbStreamRest(sceHandle); + + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + + diff --git a/fmb_player_apl/src/sce/FmbSceVideoFmtCore.c b/fmb_player_apl/src/sce/FmbSceVideoFmtCore.c new file mode 100644 index 0000000..f4fdf4e --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceVideoFmtCore.c @@ -0,0 +1,537 @@ +/** +* @brief The scenario that sets the format of the video to MB86 is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" + +/** +* @brief Set video format in MB86 scenario table(1920x1080 Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1920x1080_Enc[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {WriteEsInfoVideo, 0, 0 , 0}, //< Set to Additional parameter M set ES_INFO + {CoreParamSet, 0x00040023, 0x0000,0}, //< Set to initialize parameter V V_GOP_STRUCT + {CoreParamSet, 0x00040040, 0x0026,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x007d,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x0056,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x0007,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1920x1080 Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1920x1080_Dec[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {CoreParamSet, 0x00040040, 0x00fc,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x0024,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x00f8,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x00e8,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {CoreParamSet, 0x00040044, 0x00da,0}, //< Set to initialize parameter V V_V420_FILTER_08 + {CoreParamSet, 0x00040045, 0x00c6,0}, //< Set to initialize parameter V V_V420_FILTER_0A + {CoreParamSet, 0x00040046, 0x0076,0}, //< Set to initialize parameter V V_V420_FILTER_0C + {CoreParamSet, 0x00040047, 0x00ea,0}, //< Set to initialize parameter V V_V420_FILTER_0E + {NULL, 0, 0, 0} +}; + + + +/** +* @brief Set video format in MB86 scenario table(1440x1080 Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1440x1080_Enc[] = { + {CoreParamSet,0x0004000c,0x0001,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet,0x0004000e,0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {WriteEsInfoVideo, 0, 0 , 0}, //< Set to Additional parameter M set ES_INFO + {CoreParamSet, 0x00040023, 0x0000,0}, //< Set to initialize parameter V V_GOP_STRUCT + {CoreParamSet,0x00040040,0x00fc,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet,0x00040041,0x0024,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet,0x00040042,0x00f8,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet,0x00040043,0x00e8,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {CoreParamSet,0x00040044,0x00da,0}, //< Set to initialize parameter V V_V420_FILTER_08 + {CoreParamSet,0x00040045,0x00c6,0}, //< Set to initialize parameter V V_V420_FILTER_0A + {CoreParamSet,0x00040046,0x0076,0}, //< Set to initialize parameter V V_V420_FILTER_0C + {CoreParamSet,0x00040047,0x00ea,0}, //< Set to initialize parameter V V_V420_FILTER_0E + {CoreParamSet,0x00040048,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_00 + {CoreParamSet,0x00040049,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_02 + {CoreParamSet,0x0004004a,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_04 + {CoreParamSet,0x0004004b,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_06 + {CoreParamSet,0x0004004c,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_08 + {CoreParamSet,0x0004004d,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_0A + {CoreParamSet,0x0004004e,0x0400,0}, //< Set to initialize parameter V V_H1920_FILTER_0C + {CoreParamSet,0x0004004f,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_0E + {CoreParamSet,0x00040050,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_10 + {CoreParamSet,0x00040051,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_12 + {CoreParamSet,0x00040052,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_14 + {CoreParamSet,0x00040053,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_16 + {CoreParamSet,0x00040054,0xffff,0}, //< Set to initialize parameter V V_H1920_FILTER_18 + {CoreParamSet,0x00040055,0x000b,0}, //< Set to initialize parameter V V_H1920_FILTER_1A + {CoreParamSet,0x00040056,0xffe4,0}, //< Set to initialize parameter V V_H1920_FILTER_1C + {CoreParamSet,0x00040057,0x0039,0}, //< Set to initialize parameter V V_H1920_FILTER_1E + {CoreParamSet,0x00040058,0xff8f,0}, //< Set to initialize parameter V V_H1920_FILTER_20 + {CoreParamSet,0x00040059,0x012b,0}, //< Set to initialize parameter V V_H1920_FILTER_22 + {CoreParamSet,0x0004005a,0x0396,0}, //< Set to initialize parameter V V_H1920_FILTER_24 + {CoreParamSet,0x0004005b,0xff55,0}, //< Set to initialize parameter V V_H1920_FILTER_26 + {CoreParamSet,0x0004005c,0x0050,0}, //< Set to initialize parameter V V_H1920_FILTER_28 + {CoreParamSet,0x0004005d,0xffd7,0}, //< Set to initialize parameter V V_H1920_FILTER_2A + {CoreParamSet,0x0004005e,0x0013,0}, //< Set to initialize parameter V V_H1920_FILTER_2C + {CoreParamSet,0x0004005f,0xfffa,0}, //< Set to initialize parameter V V_H1920_FILTER_2E + {CoreParamSet,0x00040060,0xfffb,0}, //< Set to initialize parameter V V_H1920_FILTER_30 + {CoreParamSet,0x00040061,0x0015,0}, //< Set to initialize parameter V V_H1920_FILTER_32 + {CoreParamSet,0x00040062,0xffcf,0}, //< Set to initialize parameter V V_H1920_FILTER_34 + {CoreParamSet,0x00040063,0x0060,0}, //< Set to initialize parameter V V_H1920_FILTER_36 + {CoreParamSet,0x00040064,0xff3d,0}, //< Set to initialize parameter V V_H1920_FILTER_38 + {CoreParamSet,0x00040065,0x0284,0}, //< Set to initialize parameter V V_H1920_FILTER_3A + {CoreParamSet,0x00040066,0x0284,0}, //< Set to initialize parameter V V_H1920_FILTER_3C + {CoreParamSet,0x00040067,0xff3d,0}, //< Set to initialize parameter V V_H1920_FILTER_3E + {CoreParamSet,0x00040068,0x0060,0}, //< Set to initialize parameter V V_H1920_FILTER_40 + {CoreParamSet,0x00040069,0xffcf,0}, //< Set to initialize parameter V V_H1920_FILTER_42 + {CoreParamSet,0x0004006a,0x0015,0}, //< Set to initialize parameter V V_H1920_FILTER_44 + {CoreParamSet,0x0004006b,0xfffb,0}, //< Set to initialize parameter V V_H1920_FILTER_46 + {CoreParamSet,0x0004006c,0xfffa,0}, //< Set to initialize parameter V V_H1920_FILTER_48 + {CoreParamSet,0x0004006d,0x0013,0}, //< Set to initialize parameter V V_H1920_FILTER_4A + {CoreParamSet,0x0004006e,0xffd7,0}, //< Set to initialize parameter V V_H1920_FILTER_4C + {CoreParamSet,0x0004006f,0x0050,0}, //< Set to initialize parameter V V_H1920_FILTER_4E + {CoreParamSet,0x00040070,0xff55,0}, //< Set to initialize parameter V V_H1920_FILTER_50 + {CoreParamSet,0x00040071,0x0396,0}, //< Set to initialize parameter V V_H1920_FILTER_52 + {CoreParamSet,0x00040072,0x012b,0}, //< Set to initialize parameter V V_H1920_FILTER_54 + {CoreParamSet,0x00040073,0xff8f,0}, //< Set to initialize parameter V V_H1920_FILTER_56 + {CoreParamSet,0x00040074,0x0039,0}, //< Set to initialize parameter V V_H1920_FILTER_58 + {CoreParamSet,0x00040075,0xffe4,0}, //< Set to initialize parameter V V_H1920_FILTER_5A + {CoreParamSet,0x00040076,0x000b,0}, //< Set to initialize parameter V V_H1920_FILTER_5C + {CoreParamSet,0x00040077,0xffff,0}, //< Set to initialize parameter V V_H1920_FILTER_5E + {CoreParamSet,0x00040078,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_60 + {CoreParamSet,0x00040079,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_62 + {CoreParamSet,0x0004007a,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_64 + {CoreParamSet,0x0004007b,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_66 + {CoreParamSet,0x0004007c,0x0400,0}, //< Set to initialize parameter V V_H1920_FILTER_68 + {CoreParamSet,0x0004007d,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_6A + {CoreParamSet,0x0004007e,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_6C + {CoreParamSet,0x0004007f,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_6E + {CoreParamSet,0x00040080,0xfffc,0}, //< Set to initialize parameter V V_H1920_FILTER_70 + {CoreParamSet,0x00040081,0x0020,0}, //< Set to initialize parameter V V_H1920_FILTER_72 + {CoreParamSet,0x00040082,0xffa3,0}, //< Set to initialize parameter V V_H1920_FILTER_74 + {CoreParamSet,0x00040083,0x0121,0}, //< Set to initialize parameter V V_H1920_FILTER_76 + {CoreParamSet,0x00040084,0x0392,0}, //< Set to initialize parameter V V_H1920_FILTER_78 + {CoreParamSet,0x00040085,0xff65,0}, //< Set to initialize parameter V V_H1920_FILTER_7A + {CoreParamSet,0x00040086,0x0038,0}, //< Set to initialize parameter V V_H1920_FILTER_7C + {CoreParamSet,0x00040087,0xfff1,0}, //< Set to initialize parameter V V_H1920_FILTER_7E + {CoreParamSet,0x00040088,0xfff4,0}, //< Set to initialize parameter V V_H1920_FILTER_80 + {CoreParamSet,0x00040089,0x003d,0}, //< Set to initialize parameter V V_H1920_FILTER_82 + {CoreParamSet,0x0004008a,0xff57,0}, //< Set to initialize parameter V V_H1920_FILTER_84 + {CoreParamSet,0x0004008b,0x0278,0}, //< Set to initialize parameter V V_H1920_FILTER_86 + {CoreParamSet,0x0004008c,0x0278,0}, //< Set to initialize parameter V V_H1920_FILTER_88 + {CoreParamSet,0x0004008d,0xff57,0}, //< Set to initialize parameter V V_H1920_FILTER_8A + {CoreParamSet,0x0004008e,0x003d,0}, //< Set to initialize parameter V V_H1920_FILTER_8C + {CoreParamSet,0x0004008f,0xfff4,0}, //< Set to initialize parameter V V_H1920_FILTER_8E + {CoreParamSet,0x00040090,0xfff1,0}, //< Set to initialize parameter V V_H1920_FILTER_90 + {CoreParamSet,0x00040091,0x0038,0}, //< Set to initialize parameter V V_H1920_FILTER_92 + {CoreParamSet,0x00040092,0xff65,0}, //< Set to initialize parameter V V_H1920_FILTER_94 + {CoreParamSet,0x00040093,0x0392,0}, //< Set to initialize parameter V V_H1920_FILTER_96 + {CoreParamSet,0x00040094,0x0121,0}, //< Set to initialize parameter V V_H1920_FILTER_98 + {CoreParamSet,0x00040095,0xffa3,0}, //< Set to initialize parameter V V_H1920_FILTER_9A + {CoreParamSet,0x00040096,0x0020,0}, //< Set to initialize parameter V V_H1920_FILTER_9C + {CoreParamSet,0x00040097,0xfffc,0}, //< Set to initialize parameter V V_H1920_FILTER_9E + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1440x1080_Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1440x1080_Dec[] = { + {CoreParamSet,0x0004000c,0x0001,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet,0x0004000e,0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {CoreParamSet,0x00040040,0x00fc,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet,0x00040041,0x0024,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet,0x00040042,0x00f8,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet,0x00040043,0x00e8,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {CoreParamSet,0x00040044,0x00da,0}, //< Set to initialize parameter V V_V420_FILTER_08 + {CoreParamSet,0x00040045,0x00c6,0}, //< Set to initialize parameter V V_V420_FILTER_0A + {CoreParamSet,0x00040046,0x0076,0}, //< Set to initialize parameter V V_V420_FILTER_0C + {CoreParamSet,0x00040047,0x00ea,0}, //< Set to initialize parameter V V_V420_FILTER_0E + {CoreParamSet,0x00040048,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_00 + {CoreParamSet,0x00040049,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_02 + {CoreParamSet,0x0004004a,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_04 + {CoreParamSet,0x0004004b,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_06 + {CoreParamSet,0x0004004c,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_08 + {CoreParamSet,0x0004004d,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_0A + {CoreParamSet,0x0004004e,0x0400,0}, //< Set to initialize parameter V V_H1920_FILTER_0C + {CoreParamSet,0x0004004f,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_0E + {CoreParamSet,0x00040050,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_10 + {CoreParamSet,0x00040051,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_12 + {CoreParamSet,0x00040052,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_14 + {CoreParamSet,0x00040053,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_16 + {CoreParamSet,0x00040054,0xffff,0}, //< Set to initialize parameter V V_H1920_FILTER_18 + {CoreParamSet,0x00040055,0x000b,0}, //< Set to initialize parameter V V_H1920_FILTER_1A + {CoreParamSet,0x00040056,0xffe4,0}, //< Set to initialize parameter V V_H1920_FILTER_1C + {CoreParamSet,0x00040057,0x0039,0}, //< Set to initialize parameter V V_H1920_FILTER_1E + {CoreParamSet,0x00040058,0xff8f,0}, //< Set to initialize parameter V V_H1920_FILTER_20 + {CoreParamSet,0x00040059,0x012b,0}, //< Set to initialize parameter V V_H1920_FILTER_22 + {CoreParamSet,0x0004005a,0x0396,0}, //< Set to initialize parameter V V_H1920_FILTER_24 + {CoreParamSet,0x0004005b,0xff55,0}, //< Set to initialize parameter V V_H1920_FILTER_26 + {CoreParamSet,0x0004005c,0x0050,0}, //< Set to initialize parameter V V_H1920_FILTER_28 + {CoreParamSet,0x0004005d,0xffd7,0}, //< Set to initialize parameter V V_H1920_FILTER_2A + {CoreParamSet,0x0004005e,0x0013,0}, //< Set to initialize parameter V V_H1920_FILTER_2C + {CoreParamSet,0x0004005f,0xfffa,0}, //< Set to initialize parameter V V_H1920_FILTER_2E + {CoreParamSet,0x00040060,0xfffb,0}, //< Set to initialize parameter V V_H1920_FILTER_30 + {CoreParamSet,0x00040061,0x0015,0}, //< Set to initialize parameter V V_H1920_FILTER_32 + {CoreParamSet,0x00040062,0xffcf,0}, //< Set to initialize parameter V V_H1920_FILTER_34 + {CoreParamSet,0x00040063,0x0060,0}, //< Set to initialize parameter V V_H1920_FILTER_36 + {CoreParamSet,0x00040064,0xff3d,0}, //< Set to initialize parameter V V_H1920_FILTER_38 + {CoreParamSet,0x00040065,0x0284,0}, //< Set to initialize parameter V V_H1920_FILTER_3A + {CoreParamSet,0x00040066,0x0284,0}, //< Set to initialize parameter V V_H1920_FILTER_3C + {CoreParamSet,0x00040067,0xff3d,0}, //< Set to initialize parameter V V_H1920_FILTER_3E + {CoreParamSet,0x00040068,0x0060,0}, //< Set to initialize parameter V V_H1920_FILTER_40 + {CoreParamSet,0x00040069,0xffcf,0}, //< Set to initialize parameter V V_H1920_FILTER_42 + {CoreParamSet,0x0004006a,0x0015,0}, //< Set to initialize parameter V V_H1920_FILTER_44 + {CoreParamSet,0x0004006b,0xfffb,0}, //< Set to initialize parameter V V_H1920_FILTER_46 + {CoreParamSet,0x0004006c,0xfffa,0}, //< Set to initialize parameter V V_H1920_FILTER_48 + {CoreParamSet,0x0004006d,0x0013,0}, //< Set to initialize parameter V V_H1920_FILTER_4A + {CoreParamSet,0x0004006e,0xffd7,0}, //< Set to initialize parameter V V_H1920_FILTER_4C + {CoreParamSet,0x0004006f,0x0050,0}, //< Set to initialize parameter V V_H1920_FILTER_4E + {CoreParamSet,0x00040070,0xff55,0}, //< Set to initialize parameter V V_H1920_FILTER_50 + {CoreParamSet,0x00040071,0x0396,0}, //< Set to initialize parameter V V_H1920_FILTER_52 + {CoreParamSet,0x00040072,0x012b,0}, //< Set to initialize parameter V V_H1920_FILTER_54 + {CoreParamSet,0x00040073,0xff8f,0}, //< Set to initialize parameter V V_H1920_FILTER_56 + {CoreParamSet,0x00040074,0x0039,0}, //< Set to initialize parameter V V_H1920_FILTER_58 + {CoreParamSet,0x00040075,0xffe4,0}, //< Set to initialize parameter V V_H1920_FILTER_5A + {CoreParamSet,0x00040076,0x000b,0}, //< Set to initialize parameter V V_H1920_FILTER_5C + {CoreParamSet,0x00040077,0xffff,0}, //< Set to initialize parameter V V_H1920_FILTER_5E + {CoreParamSet,0x00040078,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_60 + {CoreParamSet,0x00040079,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_62 + {CoreParamSet,0x0004007a,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_64 + {CoreParamSet,0x0004007b,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_66 + {CoreParamSet,0x0004007c,0x0400,0}, //< Set to initialize parameter V V_H1920_FILTER_68 + {CoreParamSet,0x0004007d,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_6A + {CoreParamSet,0x0004007e,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_6C + {CoreParamSet,0x0004007f,0x0000,0}, //< Set to initialize parameter V V_H1920_FILTER_6E + {CoreParamSet,0x00040080,0xfffc,0}, //< Set to initialize parameter V V_H1920_FILTER_70 + {CoreParamSet,0x00040081,0x0020,0}, //< Set to initialize parameter V V_H1920_FILTER_72 + {CoreParamSet,0x00040082,0xffa3,0}, //< Set to initialize parameter V V_H1920_FILTER_74 + {CoreParamSet,0x00040083,0x0121,0}, //< Set to initialize parameter V V_H1920_FILTER_76 + {CoreParamSet,0x00040084,0x0392,0}, //< Set to initialize parameter V V_H1920_FILTER_78 + {CoreParamSet,0x00040085,0xff65,0}, //< Set to initialize parameter V V_H1920_FILTER_7A + {CoreParamSet,0x00040086,0x0038,0}, //< Set to initialize parameter V V_H1920_FILTER_7C + {CoreParamSet,0x00040087,0xfff1,0}, //< Set to initialize parameter V V_H1920_FILTER_7E + {CoreParamSet,0x00040088,0xfff4,0}, //< Set to initialize parameter V V_H1920_FILTER_80 + {CoreParamSet,0x00040089,0x003d,0}, //< Set to initialize parameter V V_H1920_FILTER_82 + {CoreParamSet,0x0004008a,0xff57,0}, //< Set to initialize parameter V V_H1920_FILTER_84 + {CoreParamSet,0x0004008b,0x0278,0}, //< Set to initialize parameter V V_H1920_FILTER_86 + {CoreParamSet,0x0004008c,0x0278,0}, //< Set to initialize parameter V V_H1920_FILTER_88 + {CoreParamSet,0x0004008d,0xff57,0}, //< Set to initialize parameter V V_H1920_FILTER_8A + {CoreParamSet,0x0004008e,0x003d,0}, //< Set to initialize parameter V V_H1920_FILTER_8C + {CoreParamSet,0x0004008f,0xfff4,0}, //< Set to initialize parameter V V_H1920_FILTER_8E + {CoreParamSet,0x00040090,0xfff1,0}, //< Set to initialize parameter V V_H1920_FILTER_90 + {CoreParamSet,0x00040091,0x0038,0}, //< Set to initialize parameter V V_H1920_FILTER_92 + {CoreParamSet,0x00040092,0xff65,0}, //< Set to initialize parameter V V_H1920_FILTER_94 + {CoreParamSet,0x00040093,0x0392,0}, //< Set to initialize parameter V V_H1920_FILTER_96 + {CoreParamSet,0x00040094,0x0121,0}, //< Set to initialize parameter V V_H1920_FILTER_98 + {CoreParamSet,0x00040095,0xffa3,0}, //< Set to initialize parameter V V_H1920_FILTER_9A + {CoreParamSet,0x00040096,0x0020,0}, //< Set to initialize parameter V V_H1920_FILTER_9C + {CoreParamSet,0x00040097,0xfffc,0}, //< Set to initialize parameter V V_H1920_FILTER_9E + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set video format in MB86 scenario table(1280x720_Enc). +* @note None +* @attention None +*/ + +static struct SceTableType m_sceCoreFmt1280x720_Enc[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {WriteEsInfoVideo, 0, 0 , 0}, //< Set to Additional parameter M set ES_INFO + {CoreParamSet, 0x00040023, 0x0000,0}, //< Set to initialize parameter V V_GOP_STRUCT + {CoreParamSet, 0x00040040, 0x0010,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x0070,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x0070,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x0010,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1280x720_Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1280x720_Dec[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {CoreParamSet, 0x00040040, 0x0007,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x0056,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x007d,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x0026,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set video format in MB86 scenario table(720x480_Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x480_Enc[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {WriteEsInfoVideo, 0, 0 , 0}, //< Set to Additional parameter M set ES_INFO + {CoreParamSet, 0x00040023, 0x0000,0}, //< Set to initialize parameter V V_GOP_STRUCT + {CoreParamSet, 0x00040040, 0x0026,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x007d,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x0056,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x0007,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(720x480_Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x480_Dec[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {CoreParamSet, 0x00040040, 0x00fc,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x0024,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x00f8,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x00e8,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {CoreParamSet, 0x00040044, 0x00da,0}, //< Set to initialize parameter V V_V420_FILTER_08 + {CoreParamSet, 0x00040045, 0x00c6,0}, //< Set to initialize parameter V V_V420_FILTER_0A + {CoreParamSet, 0x00040046, 0x0076,0}, //< Set to initialize parameter V V_V420_FILTER_0C + {CoreParamSet, 0x00040047, 0x00ea,0}, //< Set to initialize parameter V V_V420_FILTER_0E + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(720x576_Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x576_Enc[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {WriteEsInfoVideo, 0, 0 , 0}, //< Set to Additional parameter M set ES_INFO + {CoreParamSet, 0x00040023, 0x0000,0}, //< Set to initialize parameter V V_GOP_STRUCT + {CoreParamSet, 0x00040040, 0x0026,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x007d,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x0056,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x0007,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set video format in MB86 scenario table(720x576_Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x576_Dec[] = { + {CoreParamSet, 0x0004000c, 0x0000,0}, //< Set to initialize parameter V V_H1920 + {CoreParamSet, 0x0004000e, 0x0001,0}, //< Set to initialize parameter V V_V420 + {WriteVideoFormat, 0, 0 , 0}, //< Set to initialize parameter V_IP_FORMAT/V_FORMAT/V_STRM_FORMAT + {CoreParamSet, 0x00040040, 0x00fc,0}, //< Set to initialize parameter V V_V420_FILTER_00 + {CoreParamSet, 0x00040041, 0x0024,0}, //< Set to initialize parameter V V_V420_FILTER_02 + {CoreParamSet, 0x00040042, 0x00f8,0}, //< Set to initialize parameter V V_V420_FILTER_04 + {CoreParamSet, 0x00040043, 0x00e8,0}, //< Set to initialize parameter V V_V420_FILTER_06 + {CoreParamSet, 0x00040044, 0x00da,0}, //< Set to initialize parameter V V_V420_FILTER_08 + {CoreParamSet, 0x00040045, 0x00c6,0}, //< Set to initialize parameter V V_V420_FILTER_0A + {CoreParamSet, 0x00040046, 0x0076,0}, //< Set to initialize parameter V V_V420_FILTER_0C + {CoreParamSet, 0x00040047, 0x00ea,0}, //< Set to initialize parameter V V_V420_FILTER_0E + {NULL, 0, 0, 0} +}; + +struct SceTableType *m_sceCoreFmtEnc[] = { + m_sceCoreFmt1920x1080_Enc, + m_sceCoreFmt1440x1080_Enc, + m_sceCoreFmt1280x720_Enc, + m_sceCoreFmt720x480_Enc, + m_sceCoreFmt720x576_Enc, +}; + +struct SceTableType *m_sceCoreFmtDec[] = { + m_sceCoreFmt1920x1080_Dec, + m_sceCoreFmt1440x1080_Dec, + m_sceCoreFmt1280x720_Dec, + m_sceCoreFmt720x480_Dec, + m_sceCoreFmt720x576_Dec, +}; + + + +/** +* @brief The value is written in Video Format(V_IP_FORMAT and V_FORMAT and V_STRM_FORMAT and ES_INFO_0C). +* @param[in] sceHandle Scenario handle +* @param[in] dummy1 dummy1 +* @param[in] dummy2 dummy2 +* @param[in] dummy3 dummy3 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum WriteVideoFormat(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3) +{ + enum FMBVideoFormatEnum fmt; + enum FMBVideoFrameEnum frm; + enum FMBVideoScalerEncEnum scal; + + FMB_FUNC(TRUE); + + switch (gp_FmbComProperty->setMode) { + case FMBEnmFuncModeEnc: + scal = FMBEnmVideoSclEnc_NotUse; + fmt = gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm; + if( fmt == FMBEnmVideoFmt1920x1080 ){ + scal = gp_FmbProperty[FMBEnmFuncModeEnc].videoScalerEnc; + } + break; + case FMBEnmFuncModeDec: + fmt = gp_FmbProperty[FMBEnmFuncModeDec].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeDec].videoFrm; + scal = FMBEnmVideoSclEnc_NotUse; + + switch (frm){ + case FMBEnmVideoFrm_60p: + case FMBEnmVideoFrm_50p: + case FMBEnmVideoFrm_5994p: + CoreParamSet(sceHandle, 0x00040038,0x0007,0); //< Set to initialize parameter V V_V420P_FILTER_00 + CoreParamSet(sceHandle, 0x00040039,0x0056,0); //< Set to initialize parameter V V_V420P_FILTER_02 + CoreParamSet(sceHandle, 0x0004003a,0x007d,0); //< Set to initialize parameter V V_V420P_FILTER_04 + CoreParamSet(sceHandle, 0x0004003b,0x0026,0); //< Set to initialize parameter V V_V420P_FILTER_06 + CoreParamSet(sceHandle, 0x0004003c,0x0000,0); //< Set to initialize parameter V V_V420P_FILTER_08 + CoreParamSet(sceHandle, 0x0004003d,0x0000,0); //< Set to initialize parameter V V_V420P_FILTER_0A + CoreParamSet(sceHandle, 0x0004003e,0x0000,0); //< Set to initialize parameter V V_V420P_FILTER_0C + CoreParamSet(sceHandle, 0x0004003f,0x0000,0); //< Set to initialize parameter V V_V420P_FILTER_0E + CoreParamSet(sceHandle, 0x0004001a,0x0001,0); //< Set to initialize parameter V V_IP_DETECT + break; + default: + CoreParamSet(sceHandle, 0x0004001a,0x0000,0); //< Set to initialize parameter V V_IP_DETECT + break; + } + break; + default: + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + + //V_IP_FORMAT + CoreParamSetPtr(sceHandle, 0x0004000f, (unsigned long)&g_FmbInitVideoIpFormat[fmt][frm] , 0); //< Set to initialize parameter V_IP_FORMAT + + //V_FORMAT + CoreParamSetPtr(sceHandle, 0x00040010, (unsigned long)&g_FmbInitVideoFormat[fmt][frm] , 0); //< Set to initialize parameter V_FORMAT + + //V_STRM_FORMAT + CoreParamSetPtr(sceHandle, 0x00040024, (unsigned long)&g_FmbInitVideoSclEnc[fmt][scal] ,0); //< Set to initialize parameter V_STRM_FORMAT + + //V_VINPELCLK + switch (frm){ + case FMBEnmVideoFrm_60p: + case FMBEnmVideoFrm_50p: + case FMBEnmVideoFrm_60i: + case FMBEnmVideoFrm_50i: + CoreParamSet(sceHandle, 0x00040015, 1 ,0); //< Set to initialize parameter V_VINPELCLK(1:74.25MHz) + break; + case FMBEnmVideoFrm_5994i: + case FMBEnmVideoFrm_5994p: + CoreParamSet(sceHandle, 0x00040015, 0 ,0); //< Set to initialize parameter V_VINPELCLK(0:74.25/1.001MHz) + break; + default: + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} + + +/** +* @brief The value is written in ES_info by video format. +* @param[in] sceHandle Scenario handle +* @param[in] dummy1 dummy1 +* @param[in] dummy2 dummy2 +* @param[in] dummy3 dummy3 +* @return scenario result +* @note None +* @attention None +*/ +enum SceResultEnum WriteEsInfoVideo(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3) +{ + enum FMBVideoFormatEnum fmt; + enum FMBVideoFrameEnum frm; + int tmp; + + FMB_FUNC(TRUE); + + switch (gp_FmbComProperty->setMode) { + case FMBEnmFuncModeEnc: + fmt = gp_FmbProperty[FMBEnmFuncModeEnc].videoFmt; + frm = gp_FmbProperty[FMBEnmFuncModeEnc].videoFrm; + + tmp = ( (gp_FmbComProperty->PidValue[FMBEnmOutputVideoPid] >> 0x8)& 0x1f); + CoreParamSet(sceHandle, 0x00000026, (0x1be0 | tmp) , 0); //< Additional parameter M set ES_INFO_00 + tmp = ((gp_FmbComProperty->PidValue[FMBEnmOutputVideoPid] & 0xff) << 0x8); + CoreParamSet(sceHandle, 0x00000027, (0xf0 | tmp) , 0); //< Additional parameter M set ES_INFO_02 + + if(g_AudioFormatCheck[gp_FmbProperty[FMBEnmFuncModeEnc].audioFmt] == FMBEnmAFmtDVB){ + CoreParamSet(sceHandle, 0x00000028, 0x0302 , 0); //< Set to Additional parameter M set ES_INFO_04 + CoreParamSetPtr(sceHandle, 0x00000029, (unsigned long)&g_FmbVideoEsInfoFormatDVB06[fmt][frm] , 0); //< Set to Additional parameter M set ES_INFO_06(DVB) + }else{ + CoreParamSet(sceHandle, 0x00000028, 0x1405 , 0); //< Set to Additional parameter M set ES_INFO_04 + CoreParamSet(sceHandle, 0x00000029, 0x0848 , 0); //< Set to Additional parameter M set ES_INFO_06 + CoreParamSet(sceHandle, 0x0000002a, 0x444d , 0); //< Set to Additional parameter M set ES_INFO_08 + CoreParamSet(sceHandle, 0x0000002b, 0x56ff , 0); //< Set to Additional parameter M set ES_INFO_0A + CoreParamSetPtr(sceHandle, 0x0000002c, (unsigned long)&g_FmbVideoEsInfoFormatBD0C[fmt][frm] , 0);//< Set to Additional parameter M set ES_INFO_0C + if ((fmt == FMBEnmVideoFmt720x480) || (fmt == FMBEnmVideoFmt720x576)){ + CoreParamSet(sceHandle, 0x0000002d, 0x2f28 , 0); //< Set to Additional parameter M set ES_INFO_0E + }else{ + CoreParamSet(sceHandle, 0x0000002d, 0x3f28 , 0); //< Set to Additional parameter M set ES_INFO_0E + } + CoreParamSet(sceHandle, 0x0000002e, 0x0464 , 0); //< Set to Additional parameter M set ES_INFO_10 + CoreParamSet(sceHandle, 0x0000002f, 0x0028 , 0); //< Set to Additional parameter M set ES_INFO_12 + CoreParamSet(sceHandle, 0x00000030, 0x3f2a , 0); //< Set to Additional parameter M set ES_INFO_14 + CoreParamSet(sceHandle, 0x00000031, 0x027e , 0); //< Set to Additional parameter M set ES_INFO_16 + } + break; + + default: + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + } + FMB_FUNC(FALSE); + + return SceEnmResultSyncEnd; +} + diff --git a/fmb_player_apl/src/sce/FmbSceVideoFmtExtsyncCore.c b/fmb_player_apl/src/sce/FmbSceVideoFmtExtsyncCore.c new file mode 100644 index 0000000..707913a --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceVideoFmtExtsyncCore.c @@ -0,0 +1,524 @@ +/** +* @brief The scenario that sets the format of the video to MB86 is defined(External sync). +* @since 2009/03/06 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + +/** +* @brief Set video format in MB86 scenario table(1920x1080 Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1920x1080_5994i_EncExtsync[] = { + {CoreParamSet, 0x000400a3, 0x0001,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0001,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x0233,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x0897,0},//< Set to initialize parameter VIN_MAX_H_COUNT + {CoreParamSet, 0x000400ac, 0x0465,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x00c5,0},//< Set to initialize parameter VIN_H_VALID_POS + {CoreParamSet, 0x000400ae, 0x0015,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x0248,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x0780,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x021c,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {NULL, 0, 0, 0} +}; + +static struct SceTableType m_sceCoreFmt1920x1080_50i_EncExtsync[] = { + {CoreParamSet, 0x000400a3, 0x0001,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0001,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x0233,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x0a4f,0},//< Set to initialize parameter VIN_MAX_H_COUNT_ + {CoreParamSet, 0x000400ac, 0x0465,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x00c3,0},//< Set to initialize parameter VIN_H_VALID_POS_ + {CoreParamSet, 0x000400ae, 0x0015,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x0248,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x0780,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x021c,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set video format in MB86 scenario table(1920x1080 Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1920x1080_5994i_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0000,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0000,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x002d,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x0030,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0001,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x002d,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0007,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x0004,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x0233,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x0479,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x0239,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x0450,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x0000,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0002,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x0464,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0231,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +static struct SceTableType m_sceCoreFmt1920x1080_50i_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0000,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0000,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x01e5,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x023b,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0001,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x01e5,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0007,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x01e5,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x0233,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x070d,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x0238,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x070d,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x0000,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0002,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x0464,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0231,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1440x1080 Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1440x1080_5994i_EncExtsync[] = { + {CoreParamSet, 0x000400a3, 0x0001,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0001,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x0233,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x0897,0},//< Set to initialize parameter VIN_MAX_H_COUNT + {CoreParamSet, 0x000400ac, 0x0465,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x00c5,0},//< Set to initialize parameter VIN_H_VALID_POS + {CoreParamSet, 0x000400ae, 0x0015,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x0248,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x0780,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x021c,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {NULL, 0, 0, 0} +}; + +static struct SceTableType m_sceCoreFmt1440x1080_50i_EncExtsync[] = { + {CoreParamSet, 0x000400a3, 0x0001,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0001,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x0233,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x0a4f,0},//< Set to initialize parameter VIN_MAX_H_COUNT_ + {CoreParamSet, 0x000400ac, 0x0465,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x00c3,0},//< Set to initialize parameter VIN_H_VALID_POS_ + {CoreParamSet, 0x000400ae, 0x0015,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x0248,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x0780,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x021c,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1440x1080_Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1440x1080_5994i_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0000,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0000,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x002d,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x0030,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0001,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x002d,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0007,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x0004,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x0233,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x0479,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x0239,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x0450,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x0000,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0002,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x0464,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0231,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +static struct SceTableType m_sceCoreFmt1440x1080_50i_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0000,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0000,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x01e5,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x023b,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0001,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x01e5,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0007,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x01e5,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x0233,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x070d,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x0238,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x070d,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x0000,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0002,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x0464,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0231,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1280x720_Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1280x720_5994p_EncExtsync[] = { + {CoreParamSet, 0x000400a3, 0x0001,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x02ff,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x0671,0},//< Set to initialize parameter VIN_MAX_H_COUNT + {CoreParamSet, 0x000400ac, 0x02ee,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x0107,0},//< Set to initialize parameter VIN_H_VALID_POS + {CoreParamSet, 0x000400ae, 0x001a,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x0300,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x0500,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x02d0,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {NULL, 0, 0, 0} +}; + +static struct SceTableType m_sceCoreFmt1280x720_50p_EncExtsync[] = { + {CoreParamSet, 0x000400a3, 0x0001,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE_ + {CoreParamSet, 0x000400aa, 0x02ff,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x07bb,0},//< Set to initialize parameter VIN_MAX_H_COUNT_ + {CoreParamSet, 0x000400ac, 0x02ee,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x010b,0},//< Set to initialize parameter VIN_H_VALID_POS_ + {CoreParamSet, 0x000400ae, 0x001a,0},//< Set to initialize parameter VIN_TOP_VALID_LINE_ + {CoreParamSet, 0x000400af, 0x0300,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x0500,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x02d0,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(1280x720_Dec). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt1280x720_5994p_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0000,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0000,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x0048,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x0050,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0001,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x0048,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0007,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x000a,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x07ff,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x0fff,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x07ff,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x0fff,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x0fff,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0000,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x07ff,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0001,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +static struct SceTableType m_sceCoreFmt1280x720_50p_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0000,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0000,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x0192,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS_ + {CoreParamSet, 0x000400be, 0x01df,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS_ + {CoreParamSet, 0x000400c5, 0x0001,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x0192,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0_ + {CoreParamSet, 0x000400c4, 0x0006,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0_ + {CoreParamSet, 0x000400c0, 0x01b7,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0_ + {CoreParamSet, 0x000400c7, 0x07ff,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x0fff,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x07ff,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x0fff,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x0fff,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0000,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x07ff,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0001,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(720x480_Enc). +* @note None +* @attention None +*/ + +static struct SceTableType m_sceCoreFmt720x480_5994i_EncExtsync[] = { + {CoreParamSet, 0x00030000, 0x0000,0},//< Parameter M set only for initialization ENC_STC_MODE + {CoreParamSet, 0x000400a3, 0x0003,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0001,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0004,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x010a,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x06b4,0},//< Set to initialize parameter VIN_MAX_H_COUNT + {CoreParamSet, 0x000400ac, 0x020d,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x00f5,0},//< Set to initialize parameter VIN_H_VALID_POS + {CoreParamSet, 0x000400ae, 0x0016,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x011d,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x05a0,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x00f4,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {CoreParamSet, 0x00040098, 0x0001,0},//< Set to initialize parameter SCALE_FLAG + {CoreParamSet, 0x0004009a, 0x0004,0},//< Set to initialize parameter V_SCALE_FORMAT + {CoreParamSet, 0x0004009b, 0x0000,0},//< Set to initialize parameter SCALE_H_START_POS_SOURCE + {CoreParamSet, 0x0004009c, 0x0000,0},//< Set to initialize parameter SCALE_V_START_POS_SOURCE + {CoreParamSet, 0x0004009d, 0x059f,0},//< Set to initialize parameter SCALE_H_SIZE_SOURCE + {CoreParamSet, 0x0004009e, 0x01df,0},//< Set to initialize parameter SCALE_V_SIZE_SOURCE + {CoreParamSet, 0x000400a1, 0x02cf,0},//< Set to initialize parameter SCALE_H_SIZE_DESTINATE + {CoreParamSet, 0x000400a2, 0x01df,0},//< Set to initialize parameter SCALE_V_SIZE_DESTINATE + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(720x480_Dec 27Mhz). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x480_5994i_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0001,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0001,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x0012,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x0051,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0005,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x0012,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0008,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x0012,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x010b,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x01bf,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x010d,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x01bf,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x00c8,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0004,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x010a,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0004,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + +/** +* @brief Set video format in MB86 scenario table(720x576_Enc). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x576_50i_EncExtsync[] = { + {CoreParamSet, 0x00030000, 0x0000,0},//< Parameter M set only for initialization ENC_STC_MODE + {CoreParamSet, 0x000400a3, 0x0003,0},//< Set to initialize parameter VIN_EXT_SYNC + {CoreParamSet, 0x000400a4, 0x0001,0},//< Set to initialize parameter VIN_VSYNC_MODE + {CoreParamSet, 0x000400a5, 0x0000,0},//< Set to initialize parameter VIN_HSYNC_EDGE + {CoreParamSet, 0x000400a6, 0x0000,0},//< Set to initialize parameter VIN_VSYNC_EDGE + {CoreParamSet, 0x000400a7, 0x0000,0},//< Set to initialize parameter VIN_FIELD_TB + {CoreParamSet, 0x000400a8, 0x0000,0},//< Set to initialize parameter VIN_YC_MUX + {CoreParamSet, 0x000400a9, 0x0001,0},//< Set to initialize parameter VIN_TOP_START_LINE + {CoreParamSet, 0x000400aa, 0x0139,0},//< Set to initialize parameter VIN_BOT_START_LINE + {CoreParamSet, 0x000400ab, 0x06c0,0},//< Set to initialize parameter VIN_MAX_H_COUNT + {CoreParamSet, 0x000400ac, 0x0271,0},//< Set to initialize parameter VIN_MAX_V_COUNT + {CoreParamSet, 0x000400ad, 0x010f,0},//< Set to initialize parameter VIN_H_VALID_POS + {CoreParamSet, 0x000400ae, 0x0017,0},//< Set to initialize parameter VIN_TOP_VALID_LINE + {CoreParamSet, 0x000400af, 0x0150,0},//< Set to initialize parameter VIN_BOT_VALID_LINE + {CoreParamSet, 0x000400b0, 0x05a0,0},//< Set to initialize parameter VIN_VALID_HCOUNT + {CoreParamSet, 0x000400b1, 0x0120,0},//< Set to initialize parameter VIN_VALID_VCOUNT + {CoreParamSet, 0x00040098, 0x0001,0},//< Set to initialize parameter SCALE_FLAG + {CoreParamSet, 0x0004009a, 0x0005,0},//< Set to initialize parameter V_SCALE_FORMAT + {CoreParamSet, 0x0004009b, 0x0000,0},//< Set to initialize parameter SCALE_H_START_POS_SOURCE + {CoreParamSet, 0x0004009c, 0x0000,0},//< Set to initialize parameter SCALE_V_START_POS_SOURCE + {CoreParamSet, 0x0004009d, 0x059f,0},//< Set to initialize parameter SCALE_H_SIZE_SOURCE + {CoreParamSet, 0x0004009e, 0x023f,0},//< Set to initialize parameter SCALE_V_SIZE_SOURCE + {CoreParamSet, 0x000400a1, 0x02cf,0},//< Set to initialize parameter SCALE_H_SIZE_DESTINATE + {CoreParamSet, 0x000400a2, 0x023f,0},//< Set to initialize parameter SCALE_V_SIZE_DESTINATE + {NULL, 0, 0, 0} +}; + + +/** +* @brief Set video format in MB86 scenario table(720x576_Dec 27Mhz). +* @note None +* @attention None +*/ +static struct SceTableType m_sceCoreFmt720x576_50i_DecExtsync[] = { + {CoreParamSet, 0x000400bb, 0x0001,0}, //< Set to initialize parameter V VOUT_EXT_SYNC + {CoreParamSet, 0x000400bc, 0x0000,0}, //< Set to initialize parameter V VOUT_ADD_CLK_DELAY + {CoreParamSet, 0x000400da, 0x0001,0}, //< Set to initialize parameter V VOUT_CLK_DIV + {CoreParamSet, 0x000400bd, 0x0001,0}, //< Set to initialize parameter V VOUT_YC_MUX + {CoreParamSet, 0x000400bf, 0x000e,0}, //< Set to initialize parameter V VOUT_HSYNC_FALL_HPOS + {CoreParamSet, 0x000400be, 0x0091,0}, //< Set to initialize parameter V VOUT_HSYNC_RISE_HPOS + {CoreParamSet, 0x000400c5, 0x0271,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE0 + {CoreParamSet, 0x000400c1, 0x000e,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS0 + {CoreParamSet, 0x000400c4, 0x0003,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE0 + {CoreParamSet, 0x000400c0, 0x000e,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS0 + {CoreParamSet, 0x000400c7, 0x0137,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_LINE1 + {CoreParamSet, 0x000400c3, 0x035b,0}, //< Set to initialize parameter V VOUT_VSYNC_FALL_HPOS1 + {CoreParamSet, 0x000400c6, 0x013b,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_LINE1 + {CoreParamSet, 0x000400c2, 0x035b,0}, //< Set to initialize parameter V VOUT_VSYNC_RISE_HPOS1 + {CoreParamSet, 0x000400c8, 0x00c8,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_H_POS + {CoreParamSet, 0x000400c9, 0x0004,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_H_POS + {CoreParamSet, 0x000400ca, 0x010a,0}, //< Set to initialize parameter V VOUT_FIELD_RISE_LINE + {CoreParamSet, 0x000400cb, 0x0004,0}, //< Set to initialize parameter V VOUT_FIELD_FALL_LINE + {NULL, 0, 0, 0} +}; + + +struct SceTableType *m_sceCoreFmt1920x1080_EncExtsync[] = { + NULL, + NULL, + NULL, + m_sceCoreFmt1920x1080_5994i_EncExtsync, + m_sceCoreFmt1920x1080_5994i_EncExtsync, + m_sceCoreFmt1920x1080_50i_EncExtsync, +}; + +struct SceTableType *m_sceCoreFmt1440x1080_EncExtsync[] = { + NULL, + NULL, + NULL, + m_sceCoreFmt1440x1080_5994i_EncExtsync, + m_sceCoreFmt1440x1080_5994i_EncExtsync, + m_sceCoreFmt1440x1080_50i_EncExtsync, +}; + +struct SceTableType *m_sceCoreFmt1280x720_EncExtsync[] = { + m_sceCoreFmt1280x720_5994p_EncExtsync, + m_sceCoreFmt1280x720_5994p_EncExtsync, + m_sceCoreFmt1280x720_50p_EncExtsync, + NULL, + NULL, + NULL, +}; + +struct SceTableType *m_sceCoreFmt720x480_EncExtsync[] = { + NULL, + NULL, + NULL, + m_sceCoreFmt720x480_5994i_EncExtsync, + m_sceCoreFmt720x480_5994i_EncExtsync, + NULL, +}; + +struct SceTableType *m_sceCoreFmt720x576_EncExtsync[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + m_sceCoreFmt720x576_50i_EncExtsync, +}; + +struct SceTableType **m_sceCoreFmtEncExtsync[] = { + m_sceCoreFmt1920x1080_EncExtsync, + m_sceCoreFmt1440x1080_EncExtsync, + m_sceCoreFmt1280x720_EncExtsync, + m_sceCoreFmt720x480_EncExtsync, + m_sceCoreFmt720x576_EncExtsync, +}; + + + +struct SceTableType *m_sceCoreFmt1920x1080_DecExtsync[] = { + NULL, + NULL, + NULL, + m_sceCoreFmt1920x1080_5994i_DecExtsync, + m_sceCoreFmt1920x1080_5994i_DecExtsync, + m_sceCoreFmt1920x1080_50i_DecExtsync, +}; + +struct SceTableType *m_sceCoreFmt1440x1080_DecExtsync[] = { + NULL, + NULL, + NULL, + m_sceCoreFmt1440x1080_5994i_DecExtsync, + m_sceCoreFmt1440x1080_5994i_DecExtsync, + m_sceCoreFmt1440x1080_50i_DecExtsync, +}; + +struct SceTableType *m_sceCoreFmt1280x720_DecExtsync[] = { + m_sceCoreFmt1280x720_5994p_DecExtsync, + m_sceCoreFmt1280x720_5994p_DecExtsync, + m_sceCoreFmt1280x720_50p_DecExtsync, + NULL, + NULL, + NULL, +}; + +struct SceTableType *m_sceCoreFmt720x480_DecExtsync[] = { + NULL, + NULL, + NULL, + m_sceCoreFmt720x480_5994i_DecExtsync, + m_sceCoreFmt720x480_5994i_DecExtsync, + NULL, +}; + +struct SceTableType *m_sceCoreFmt720x576_DecExtsync[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + m_sceCoreFmt720x576_50i_DecExtsync, +}; + +struct SceTableType **m_sceCoreFmtDecExtsync[] = { + m_sceCoreFmt1920x1080_DecExtsync, + m_sceCoreFmt1440x1080_DecExtsync, + m_sceCoreFmt1280x720_DecExtsync, + m_sceCoreFmt720x480_DecExtsync, + m_sceCoreFmt720x576_DecExtsync, +}; diff --git a/fmb_player_apl/src/sce/FmbSceWait.c b/fmb_player_apl/src/sce/FmbSceWait.c new file mode 100644 index 0000000..1b25d36 --- /dev/null +++ b/fmb_player_apl/src/sce/FmbSceWait.c @@ -0,0 +1,452 @@ +/** +* @brief The function for the scenario that waits for an asynchronous event is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" + +/** +* @brief The system response is waited for. +* @param[in] sceHandle Scenario handle +* @param[in] cackId System command id that becomes wait condition. +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultRetry Scenario is continued. +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum WaitSysAckFor(HANDLE sceHandle, unsigned long cackId, unsigned long dummy1, unsigned long dummy2) +{ + struct RecvEventArgType *w; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + LogFmb("RecvEventArgType.dev\t%d\t" + "RecvEventArgType.evnt\t%d\t" + "SysAck.id\t0x%x", + w->dev, w->evnt, w->WaitDetail.SysAck.id); + if(w->dev != FMBEnmCoreDeviceSystem){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if(w->evnt != FMBEnmCoreFromAck){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + + if((cackId != SCE_IGNORE) && (w->WaitDetail.SysAck.id != cackId)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + SceCleartArg(sceHandle); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +enum SceResultEnum WaitCmdSysAckFor(HANDLE sceHandle, unsigned long cackId, unsigned long dummy1, unsigned long dummy2) +{ + struct RecvEventArgType *w; + enum SceResultEnum sceResult; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FmbStartCommandPrint(FMB_CMD_WAIT_SYACK); + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + sceResult = WaitSysAckFor(sceHandle, cackId, dummy1, dummy2); + if(sceResult == SceEnmResultSyncEnd){ + FmbEndCommandPrint(FMB_CMD_WAIT_SYACK); + } + + FMB_FUNC(FALSE); + return sceResult; +} + +/** +* @brief The system message is waited for. +* @param[in] sceHandle Scenario handle +* @param[in] msgId Message ID that becomes wait condition +* @param[in] subMsgId Sub message ID that becomes wait condition +* @param[in] body00 Body00 that becomes wait condition +* @return SceEnmResultRetry Scenario is continued. +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum WaitSysMsgFor(HANDLE sceHandle, unsigned long msgId, unsigned long subMsgId, unsigned long body00) +{ + struct RecvEventArgType *w; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + LogFmb("RecvEventArgType.dev\t%d\t" + "RecvEventArgType.evnt\t%d\t" + "SysMsg.id\t0x%x\t" + "SysMsg.sub_id\t0x%x\t" + "SysMsg.body\t0x%x", + w->dev, w->evnt, w->WaitDetail.SysMsg.id, w->WaitDetail.SysMsg.sub_id, w->WaitDetail.SysMsg.body); + + if(w->dev != FMBEnmCoreDeviceSystem){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if(w->evnt != FMBEnmCoreFromMsg){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((msgId != SCE_IGNORE) && (w->WaitDetail.SysMsg.id != msgId)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((subMsgId != SCE_IGNORE) && (w->WaitDetail.SysMsg.sub_id != subMsgId)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((body00 != SCE_IGNORE) && (w->WaitDetail.SysMsg.body != body00)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + SceCleartArg(sceHandle); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} +enum SceResultEnum WaitCmdSysMsgFor(HANDLE sceHandle, unsigned long msgId, unsigned long subMsgId, unsigned long body00) +{ + struct RecvEventArgType *w; + enum SceResultEnum sceResult; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FmbStartCommandPrint(FMB_CMD_WAIT_SYMSG); + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + sceResult = WaitSysMsgFor(sceHandle, msgId, subMsgId, body00); + if(sceResult == SceEnmResultSyncEnd){ + FmbEndCommandPrint(FMB_CMD_WAIT_SYMSG); + } + + FMB_FUNC(FALSE); + return sceResult; +} + +/** +* @brief The video message is waited for. +* @param[in] sceHandle Scenario handle +* @param[in] mode Mode that becomes wait condition. +* @param[in] subMode Sub mode that becomes wait condition. +* @param[in] dummy2 +* @return SceEnmResultRetry Scenario is continued. +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum WaitVideoMsgFor(HANDLE sceHandle, unsigned long mode, unsigned long subMode, unsigned long seqEnd) +{ + struct RecvEventArgType *w; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + LogFmb("RecvEventArgType.dev\t%d\t" + "RecvEventArgType.evnt\t%d\t" + "VideoMsg.mode\t0x%x\t" + "VideoMsg.submode\t0x%x\t", + w->dev, w->evnt, w->WaitDetail.VideoMsg.mode, w->WaitDetail.VideoMsg.submode); + + if(w->dev != FMBEnmCoreDeviceVideo){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if(w->evnt != FMBEnmCoreFromMsg){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((mode != SCE_IGNORE) && (w->WaitDetail.VideoMsg.mode != mode)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((subMode != SCE_IGNORE) && (w->WaitDetail.VideoMsg.submode != subMode)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if( (seqEnd != SCE_IGNORE) && (w->WaitDetail.VideoMsg.seq_end != seqEnd)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + SceCleartArg(sceHandle); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} +enum SceResultEnum WaitCmdVideoMsgFor(HANDLE sceHandle, unsigned long mode, unsigned long subMode, unsigned long seqEnd) +{ + struct RecvEventArgType *w; + enum SceResultEnum sceResult; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + if( seqEnd != SCE_IGNORE ){ + FmbStartCommandPrint(FMB_CMD_WAIT_SEQEND); + }else{ + FmbStartCommandPrint(FMB_CMD_WAIT_MODE); + } + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + sceResult = WaitVideoMsgFor(sceHandle, mode, subMode, seqEnd); + if(sceResult == SceEnmResultSyncEnd){ + if( seqEnd != SCE_IGNORE ){ + FmbEndCommandPrint(FMB_CMD_WAIT_SEQEND); + }else{ + FmbEndCommandPrint(FMB_CMD_WAIT_MODE); + } + } + + FMB_FUNC(FALSE); + return sceResult; +} + +/** +* @brief The Audio message is waited for. +* @param[in] sceHandle Scenario handle +* @param[in] mute Mute that becomes wait condition. +* @param[in] ch Channel that becomes wait condition. +* @param[in] dummy2 +* @return SceEnmResultRetry Scenario is continued. +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum WaitAudioMsgFor(HANDLE sceHandle, unsigned long mute, unsigned long ch, unsigned long dummy) +{ + struct RecvEventArgType *w; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + LogFmb("RecvEventArgType.dev\t%d\t" + "RecvEventArgType.evnt\t%d\t" + "AduioMsg.mute\t0x%x\t" + "AduioMsg.ch\t0x%x", + w->dev, w->evnt, w->WaitDetail.AduioMsg.mute, w->WaitDetail.AduioMsg.ch); + + if(w->dev != FMBEnmCoreDeviceAudio){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if(w->evnt != FMBEnmCoreFromMsg){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((mute != SCE_IGNORE) && (w->WaitDetail.AduioMsg.mute != mute)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((ch != SCE_IGNORE) && (w->WaitDetail.AduioMsg.ch != ch)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + SceCleartArg(sceHandle); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; +} + +/** +* @brief The send or receive thread(file read) End message is waited for. +* @param[in] sceHandle Scenario handle +* @param[in] Id Kind of Thread.(receive :0 send:1) +* @param[in] dummy1 +* @param[in] dummy2 +* @return SceEnmResultRetry Scenario is continued. +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum WaitThreadEndFor(HANDLE sceHandle, unsigned long Id, unsigned long dummy1, unsigned long dummy2) +{ + + struct RecvEventArgType *w; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + LogFmb("RecvEventArgType.dev\t%d\t" + "RecvEventArgType.evnt\t%d\t" + "SysAck.id\t0x%x", + w->dev, w->evnt, w->WaitDetail.SysAck.id); + + if(w->dev != FMBEnmCoreDeviceStream){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if(w->evnt != FMBEnmCoreFromSteamEndMsg){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if((Id != SCE_IGNORE) && (w->WaitDetail.StreamMsg.id != Id)){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + SceCleartArg(sceHandle); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + + +} +enum SceResultEnum WaitCmdThreadEndFor(HANDLE sceHandle, unsigned long Id, unsigned long dummy1, unsigned long dummy2) +{ + struct RecvEventArgType *w; + enum SceResultEnum sceResult; + + FMB_FUNC(TRUE); + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + if( Id != SCE_IGNORE ){ + + if(Id==FMBEnmStreamSend){ + FmbStartCommandPrint(FMB_CMD_WAIT_STRM_SEND); + } + if(Id==FMBEnmStreamRcv){ + FmbStartCommandPrint(FMB_CMD_WAIT_STRM_RCV); + } + } + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + sceResult = WaitThreadEndFor(sceHandle, Id, dummy1, dummy2); + if(sceResult == SceEnmResultSyncEnd){ + if( Id != SCE_IGNORE ){ + + if(Id==FMBEnmStreamSend){ + FmbEndCommandPrint(FMB_CMD_WAIT_STRM_SEND); + } + if(Id==FMBEnmStreamRcv){ + FmbEndCommandPrint(FMB_CMD_WAIT_STRM_RCV); + } + } + } + + FMB_FUNC(FALSE); + return sceResult; +} + +/** +* @brief The input key is waited for. +* @param[in] sceHandle Scenario handle +* @param[in] dummy1 +* @param[in] dummy2 +* @param[in] dummy3 +* @return SceEnmResultRetry Scenario is continued. +* @return SceEnmResultSyncEnd Scenario is end. +* @note None +* @attention None +*/ +enum SceResultEnum WaitCmdInputKeyFor(HANDLE sceHandle, unsigned long dummy1, unsigned long dummy2, unsigned long dummy3) +{ + + struct RecvEventArgType *w; + + FMB_FUNC(TRUE); + + + w = (struct RecvEventArgType *)SceGetArg(sceHandle); + if(w == NULL){ + FmbSetPauseCommand(); + FmbStartCommandPrint(FMB_CMD_PAUSE); + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + LogFmb("RecvEventArgType.dev\t%d\t" + "RecvEventArgType.evnt\t%d\t" + "SysAck.id\t0x%x", + w->dev, w->evnt, w->WaitDetail.SysAck.id); + + if(w->dev != FMBEnmCoreDeviceStream){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + if(w->evnt != FMBEnmCoreFromInputKey){ + FMB_FUNC(FALSE); + return SceEnmResultRetry; + } + + FmbEndCommandPrint(FMB_CMD_PAUSE); + + SceCleartArg(sceHandle); + FMB_FUNC(FALSE); + return SceEnmResultSyncEnd; + + +} diff --git a/fmb_player_apl/src/sce/FmbScenario.c b/fmb_player_apl/src/sce/FmbScenario.c new file mode 100644 index 0000000..9aa6b14 --- /dev/null +++ b/fmb_player_apl/src/sce/FmbScenario.c @@ -0,0 +1,262 @@ +/** +* @brief The function of the scenario module that manages the scenario is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <stdlib.h> +#include <unistd.h> + +#include "FmbCmn.h" + +/** +* @brief Scenario Property data. +* @note None +* @attention None +*/ +struct ScenarioPropertyType{ + BOOL isValid; + struct SceTableType *sceTblHead; + struct SceTableType *sceTblNext; + void *arg; + const char *name; + int currentIdx; + char *freeReqBuf; +// int deviceFd; + enum FMBDeviceNumEnum deviceNum; +}; + +/** +* @brief Make scenario object. +* @param[in] sceTbl Scenario table. +* @param[in] name Scenario name.(For log) +* @return scenario handle +* @note None +* @attention None +*/ +HANDLE _SceCreate(struct SceTableType *sceTbl, const char *name ,char* freeReqBuf, enum FMBDeviceNumEnum deviceNum) +{ + struct ScenarioPropertyType *prop; + + FMB_FUNC(TRUE); + + prop = malloc(sizeof(struct ScenarioPropertyType)); + ASSERT_SYS(prop != NULL, "malloc()"); + + prop->sceTblHead = sceTbl; /* pgr0520 */ + prop->sceTblNext = sceTbl; + prop->isValid = TRUE; + prop->name = name; + prop->currentIdx = 0; + prop->freeReqBuf = freeReqBuf; + prop->deviceNum = deviceNum; + + FMB_FUNC(FALSE); + + return (HANDLE)prop; +} + +/** +* @brief Free scenario object. +* @param[in] scenarioHandle scenario handle +* @return None +* @note None +* @attention None +*/ +void SceClose(HANDLE scenarioHandle) +{ + struct ScenarioPropertyType *prop = (struct ScenarioPropertyType *)scenarioHandle; + + FMB_FUNC(TRUE); + + ASSERT_USR(scenarioHandle != NULL, "It is closed handle!"); + + prop->isValid = FALSE; + + if(prop->freeReqBuf != NULL){ + free(prop->freeReqBuf); + } + free(prop); + + FMB_FUNC(FALSE); +} + +/** +* @brief Execute scenario object. +* @param[in] scenarioHandle scenario handle +* @param[in] arg Argument passed to scenario function. +* @return TURE Scenario is continued. +* @return FALSE Scenario is end. +* @note None +* @attention None +*/ +BOOL SceGo(HANDLE scenarioHandle, void *arg) +{ + struct ScenarioPropertyType *prop = (struct ScenarioPropertyType *)scenarioHandle; + struct SceTableType *scenarios; + enum SceResultEnum rc; + + FMB_FUNC(TRUE); + + ASSERT_USR(scenarioHandle != NULL, "It is closed handle!"); + ASSERT_USR(prop->isValid == TRUE, "memory reak!"); + + prop->arg = arg; + for(scenarios = prop->sceTblNext; scenarios->scenarioFunc != NULL; ){ + TraceSce("%s\t" "Idx\t%d\t" "arg1\t0x%08x\t" "arg2\t0x%08x\t" "arg3\t0x%08x", prop->name, prop->currentIdx, + scenarios->arg1, scenarios->arg2, scenarios->arg3); + rc = scenarios->scenarioFunc(scenarioHandle, scenarios->arg1, scenarios->arg2, scenarios->arg3); + if(rc == SceEnmResultRetry){ + FMB_FUNC(FALSE); + return TRUE; + } + + prop->currentIdx++; + scenarios ++; + prop->sceTblNext = scenarios; + if(rc == SceEnmResultAsyncEnd){ + FMB_FUNC(FALSE); + return TRUE; + } + + ASSERT_USR(rc == SceEnmResultSyncEnd, "Scenario function returned invalid value."); + } + + FMB_FUNC(FALSE); + return FALSE; +} + +/** +* @brief Reset scenario. The following are executed from the beginning. +* @param[in] scenarioHandle scenario handle +* @return None +* @note None +* @attention None +*/ +void SceReset(HANDLE scenarioHandle) +{ + struct ScenarioPropertyType *prop = (struct ScenarioPropertyType *)scenarioHandle; + + FMB_FUNC(TRUE); + + ASSERT_USR(prop->isValid == TRUE, "memory reak!"); + prop->sceTblNext = prop->sceTblHead; + prop->currentIdx = 0; + + FMB_FUNC(FALSE); +} + +/** +* @brief The argument is returned. +* @param[in] scenarioHandle scenario handle +* @return Argument passed by function "SceGo". +* @note None +* @attention None +*/ +void *SceGetArg(HANDLE scenarioHandle) +{ + struct ScenarioPropertyType *prop; + void *arg; + + FMB_FUNC(TRUE); + + prop = (struct ScenarioPropertyType *)scenarioHandle; + ASSERT_USR(prop->isValid == TRUE, "memory reak!"); + arg = prop->arg; + + FMB_FUNC(FALSE); + return arg; +} + +/** +* @brief The argument is cleared. +* @param[in] scenarioHandle scenario handle +* @return None +* @note None +* @attention None +*/ +void SceCleartArg(HANDLE scenarioHandle) +{ + struct ScenarioPropertyType *prop; + + FMB_FUNC(TRUE); + + prop = (struct ScenarioPropertyType *)scenarioHandle; + ASSERT_USR(prop->isValid == TRUE, "memory reak!"); + prop->arg = NULL; + + FMB_FUNC(FALSE); + return ; +} + +/** +* @brief The scenario is synchronously executed. +* @param[in] sceTbl Scenario table. +* @param[in] name Scenario name. For log. +* @param[in] arg Argument passed to scenario function. +* @return None +* @note None +* @attention None +*/ +void _SceGoSync(struct SceTableType *sceTbl, const char *name, void *arg, enum FMBDeviceNumEnum deviceNum) +{ + HANDLE sce; + BOOL isContinue; + + FMB_FUNC(TRUE); + + sce = _SceCreate(sceTbl, name, NULL, deviceNum); + + isContinue = SceGo(sce, arg); + ASSERT_USR(! isContinue, "Invalid scenario"); + + SceClose(sce); + + FMB_FUNC(FALSE); +} + +/** +* @brief Get device handle. +* @param[in] scenarioHandle scenario handle +* @return Device handle +* @note None +* @attention None +*/ +int SceGetDevHandle(HANDLE scenarioHandle) +{ + struct ScenarioPropertyType *prop; + int deviceFd; + + FMB_FUNC(TRUE); + ASSERT_USR(scenarioHandle != NULL, "It is closed handle!"); + + prop = (struct ScenarioPropertyType *)scenarioHandle; + deviceFd = FmbGetDeviceHd(prop->deviceNum); + + FMB_FUNC(FALSE); + + return deviceFd; +} + +enum FMBDeviceNumEnum SceGetDevNum(HANDLE scenarioHandle) +{ + struct ScenarioPropertyType *prop; + + FMB_FUNC(TRUE); + ASSERT_USR(scenarioHandle != NULL, "It is closed handle!"); + + prop = (struct ScenarioPropertyType *)scenarioHandle; + + FMB_FUNC(FALSE); + + return prop->deviceNum; +} diff --git a/fmb_player_apl/src/sce/MmuxAp.c b/fmb_player_apl/src/sce/MmuxAp.c new file mode 100644 index 0000000..b2d6324 --- /dev/null +++ b/fmb_player_apl/src/sce/MmuxAp.c @@ -0,0 +1,773 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h> +#include "mmux.h" +#include "MmuxAp.h" +#include "FmbCmn.h" + + +#define PERROR(str) perror(str)
+
+ +#define BUFFER_SZ (4*1024) +#define PIPE_CMD_SZ 1024 +
+
+static const int TOTAL_INPUT = 4;
+static const int TOTAL_OUTPUT = 1;
+static const int TOTAL_CODEC = 4;
+ + +static const char szDeviceName[] = "/dev/media_mux"; + +static const char *szVideoName_A[] = { + "Video-0", + "Video-1", + "Video-2", + "Video-3", +}; + +static const char* const szOutputSrc_A[] = { + "Video-0", + "Video-1", + "Video-2", + "Video-3", + "Codec-0", + "Codec-1", + "Codec-2", + "Codec-3", +}; + +static const char* const szResolution_A[] = { + "1920x1080@60p", + "1920x1080@59.94p", + "1920x1080@50p", + "1920x1080@60i", + "1920x1080@59.94i", + "1920x1080@50i", + "1920x1080@24p", + "1920x1080@23.98p", + "1280x720@60p", + "1280x720@59.94p", + "1280x720@50p", + "1280x720@24p", + "1280x720@23.98p", + "720x480@59.94i/60i", + "720x576@50i", +}; + +static const char szUnknown[] = "unknown"; + +static const char szError[] = "???"; + + + +struct MmuxInfo { + int fd; + struct MmuxVer ver; + //struct CodecIO codecIO[MMUX_TOTAL_CODEC]; + int totalInput; + int totalOutput; + int totalCodecChip; +}; + + + +static int Mmux_getVer(int fd, struct MmuxVer *p_Ver); +static int Mmux_getCodecSrc(int fd, int codecNum, int *p_srcNum); +static int Mmux_setCodecSrc(int fd, int codecNum, int srcNum); +static int Mmux_getCodecDst(int fd, int codecNum, int *p_dstNum); +static int Mmux_getCodecSrcResolution(int fd, int codecNum, unsigned long *p_resolution); +static int Mmux_isCodecSrcConncet(int fd, int codecNum, int *p_isConncet); +static int Mmux_isCodecSrcDisable(int fd, int codecNum, int *p_isDisable); +static int Mmux_getOutputSrc(int fd, int outputNum, int *p_outputSrc); +static int Mmux_setOutputSrc(int fd, int outputNum, int outputSrc); + + +MmuxHandle MmuxInit(int deviceNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + char deviceName[256]; + + p_MmuxInfo = malloc(sizeof(struct MmuxInfo)); + if(p_MmuxInfo != NULL) { + int fd; + + memset(p_MmuxInfo, 0, sizeof(struct MmuxInfo)); + p_MmuxInfo->fd = -1; + + sprintf(deviceName, "%s%d", szDeviceName, deviceNum); + fd = open(deviceName, O_RDWR); + if (fd < 0) { + PERROR("open"); + ASSERT_SYS(0, "ioctl()"); + free(p_MmuxInfo); + p_MmuxInfo = NULL; + } + else { + p_MmuxInfo->fd = fd; + + Mmux_getVer(fd, &p_MmuxInfo->ver); + + p_MmuxInfo->totalInput = TOTAL_INPUT; + p_MmuxInfo->totalOutput = TOTAL_OUTPUT; + p_MmuxInfo->totalCodecChip = TOTAL_CODEC; + } + } + else { + } + + return (MmuxHandle)p_MmuxInfo; +} + +void MmuxRelease(MmuxHandle hdMmux) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int result; + + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = close(p_MmuxInfo->fd); + if (result < 0) { + PERROR("close"); +// ASSERT_SYS(0, "ioctl()"); + } + + free(p_MmuxInfo); +} + + +char const *MmuxGetResolutionStr(int resolution) +{ + char const *pStr = NULL; + + if(0 <= resolution && resolution < sizeof(szResolution_A)/sizeof(szResolution_A[0])) { + pStr = szResolution_A[resolution]; + } + else if (MMUX_RESOLUTION_UNKNOWN == resolution){ + pStr = szUnknown; + } + else { + ASSERT_USR(0, "Error: Param?"); + pStr = szError; + } + + return pStr; +} + +char const *MmuxGetCodecSrcStr(int srcNum) +{ + char const *pStr = NULL; + + if(0 <= srcNum && srcNum < sizeof(szVideoName_A)/sizeof(szVideoName_A[0])) { + pStr = szVideoName_A[srcNum]; + } + else { + ASSERT_USR(0, "Error: Param?"); + pStr = szError; + } + + return pStr; +} + +char const *MmuxGetOutputSrcStr(int outputSrc) +{ + char const *pStr = NULL; + + if(0 <= outputSrc && outputSrc < sizeof(szOutputSrc_A)/sizeof(szOutputSrc_A[0])) { + pStr = szOutputSrc_A[outputSrc]; + } + else { + ASSERT_USR(0, "Error: Param?"); + pStr = szError; + } + + return pStr; +} + +int MmuxGetVer(MmuxHandle hdMmux, struct MmuxVer *p_Ver) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int ret = 0; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(p_Ver!=NULL, "Error: Param?"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + p_Ver->CPLD = p_MmuxInfo->ver.CPLD; + p_Ver->FPGA = p_MmuxInfo->ver.FPGA; + p_Ver->MCU = p_MmuxInfo->ver.MCU; + strcpy(p_Ver->driver, p_MmuxInfo->ver.driver); + + return ret; +} + +enum MMUX_INPUT MmuxGetCodecSrc(MmuxHandle hdMmux, int codecNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + enum MMUX_INPUT srcNum; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_getCodecSrc(p_MmuxInfo->fd, codecNum, &srcNum); + if (result < 0) { + srcNum = MMUX_INPUT_NONE; + ASSERT_USR(0, "Error!"); + } + + return srcNum; +} + +int MmuxSetCodecSrc(MmuxHandle hdMmux, int codecNum, enum MMUX_INPUT srcNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_setCodecSrc(p_MmuxInfo->fd, codecNum, srcNum); + if (result < 0) { + ASSERT_USR(0, "Error!"); + } + + return result; +} + +enum MMUX_OUTPUT MmuxGetCodecDst(MmuxHandle hdMmux, int codecNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + enum MMUX_OUTPUT dstNum; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_getCodecDst(p_MmuxInfo->fd, codecNum, &dstNum); + if (result < 0) { + dstNum = MMUX_OUTPUT_NONE; + ASSERT_USR(0, "Error!"); + } + + return dstNum; +} + +enum MMUX_RESOLUTION MmuxGetCodecSrcResolution(MmuxHandle hdMmux, int codecNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + enum MMUX_RESOLUTION inResolution; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_getCodecSrcResolution(p_MmuxInfo->fd, codecNum, (unsigned long*)&inResolution); + if (result < 0) { + inResolution = MMUX_RESOLUTION_UNKNOWN; + ASSERT_USR(0, "Error!"); + } + + return inResolution; +} + +int MmuxIsCodecSrcConnect(MmuxHandle hdMmux, int codecNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int isConncet; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_isCodecSrcConncet(p_MmuxInfo->fd, codecNum, &isConncet); + if (result < 0) { + ASSERT_USR(0, "Error!"); + } + + return (isConncet ? 1 : 0); +} + +int MmuxIsCodecSrcDisable(MmuxHandle hdMmux, int codecNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int isDisable; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_isCodecSrcDisable(p_MmuxInfo->fd, codecNum, &isDisable); + if (result < 0) { + ASSERT_USR(0, "Error!"); + } + + return (isDisable ? 1 : 0); +} + +int MmuxGetCodecStatus(MmuxHandle hdMmux, int codecNum, struct CodecIO *p_Codec) +{ + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= codecNum && codecNum < MMUX_TOTAL_CODEC, "Failed: codecNum"); + ASSERT_USR(p_Codec!=NULL, "Failed: p_Codec"); + + p_Codec->inNum = MmuxGetCodecSrc(hdMmux, codecNum); + p_Codec->outNum = MmuxGetCodecDst(hdMmux, codecNum); + p_Codec->inResolution = MmuxGetCodecSrcResolution(hdMmux, codecNum); + p_Codec->fgInputConncet = MmuxIsCodecSrcConnect(hdMmux, codecNum); + p_Codec->fgInputDisable = MmuxIsCodecSrcDisable(hdMmux, codecNum); + + return 0; +} + +enum MMUX_OUTPUT_SRC MmuxGetOutputSrc(MmuxHandle hdMmux, int outputNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int result; + enum MMUX_OUTPUT_SRC outputSrc; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= outputNum && outputNum < TOTAL_OUTPUT, "Failed: output number"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_getOutputSrc(p_MmuxInfo->fd, outputNum, &outputSrc); + if (result < 0) { + outputNum = MMUX_OUT_SRC_NONE; + ASSERT_USR(0, "Error!"); + } + + return outputSrc; +} + +int MmuxSetOutputSrc(MmuxHandle hdMmux, int outputNum, enum MMUX_OUTPUT_SRC outputSrc) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int result; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= outputNum && outputNum < TOTAL_OUTPUT, "Failed: codecNum"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_setOutputSrc(p_MmuxInfo->fd, outputNum, outputSrc); + if (result < 0) { + ASSERT_USR(0, "Error!"); + } + + return result; +} + +enum MMUX_OUTPUT_MODE MmuxGetOutputMode(MmuxHandle hdMmux, int outputNum) +{ + struct MmuxInfo *p_MmuxInfo = NULL; + int result; + enum MMUX_OUTPUT_SRC outputSrc; + enum MMUX_OUTPUT_SRC outputMode; + + ASSERT_USR(hdMmux!=NULL, "Failed: hd"); + ASSERT_USR(0 <= outputNum && outputNum < TOTAL_OUTPUT, "Failed: output number"); + + p_MmuxInfo = (struct MmuxInfo *)hdMmux; + + result = Mmux_getOutputSrc(p_MmuxInfo->fd, outputNum, &outputSrc); + if (result < 0) { + outputNum = MMUX_OUT_SRC_NONE; + ASSERT_USR(0, "Error!"); + } + + switch(outputSrc) { + case MMUX_OUT_SRC_IN_0: + case MMUX_OUT_SRC_IN_1: + case MMUX_OUT_SRC_IN_2: + case MMUX_OUT_SRC_IN_3: + outputMode = MMUX_OUT_MODE_BYPASS; + break; + case MMUX_OUT_SRC_CODEC_0: + case MMUX_OUT_SRC_CODEC_1: + case MMUX_OUT_SRC_CODEC_2: + case MMUX_OUT_SRC_CODEC_3: + outputMode = MMUX_OUT_MODE_H264; + break; + default: + outputMode = MMUX_OUT_MODE_NONE; + break; + } + + return outputMode; +} + +int MmuxCalcCodecChipTotal(void) +{ + const char szCmdParseDev[] = "cat /proc/bus/pci/devices | grep h55fmb"; + FILE *read_fp; + char buffer[BUFFER_SZ+1]; + char cmd[PIPE_CMD_SZ+1]; + unsigned long numBus = 0xffffffff; + unsigned long numBusOld = 0xffffffff; + + int countBus = 0; + int countDev = 0; + + memset(buffer, '\0', sizeof(buffer)); + memset(cmd, '\0', sizeof(cmd)); + + read_fp = popen(szCmdParseDev, "r"); + if (read_fp != NULL ) { + while (fgets(buffer, BUFFER_SZ+1, read_fp)) { + sscanf(buffer, "%lx", &numBus); + if (numBusOld != numBus>>8) { + numBusOld = numBus>>8; + countBus++; + } + countDev++; + } + } + + if (read_fp != NULL) { + fclose(read_fp); + } + + return countDev; +} + +int MmuxCalcBoardTotal(void) +{ + const char szCmdParseDevCoun[] = "cat /proc/bus/pci/devices | grep -c 11720008"; + FILE *read_fp; + int chars_read; + char buffer[BUFFER_SZ+1]; + int countDev = 0; + + memset(buffer, '\0', sizeof(buffer)); + + read_fp = popen(szCmdParseDevCoun, "r"); + if (read_fp != NULL ) { + chars_read = fread(buffer, sizeof(char), 2, read_fp); + if (chars_read) { + sscanf(buffer, "%d\n", &countDev); + } + } + + if (read_fp != NULL) { + fclose(read_fp); + } + + + return countDev; +} + + +static int Mmux_getVer(int fd, struct MmuxVer *p_Ver) +{ + struct MMUX_PARAM_INFO tParamInfo = {0}; + int ret = 0; + struct MMUX_VERSION_INFO tVersion; + + tParamInfo.id = CPLD_VER; + ret = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (ret < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + p_Ver->CPLD = 0; + ret = -1; + } + else { + p_Ver->CPLD = tParamInfo.data; + } + + tParamInfo.id = FPGA_VER; + ret = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (ret < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + p_Ver->FPGA = 0; + ret = -1; + } + else { + p_Ver->FPGA = tParamInfo.data; + } + + tParamInfo.id = MCU_VER; + ret = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (ret < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + p_Ver->MCU = 0; + ret = -1; + } + else { + p_Ver->MCU = tParamInfo.data; + } + + tVersion.driver_ver = p_Ver->driver; + ret = ioctl(fd, MMUX_IOCG_VERSION, &tVersion); + if (ret < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + p_Ver->driver[0] = '\0'; + ret = -1; + } + + return ret; +} + +static int Mmux_getCodecSrc(int fd, int codecNum, int *p_srcNum) +{ + int result; + int ret = 0; + + if (0 <= codecNum && codecNum < MMUX_TOTAL_CODEC) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = CODEC_0_SRC +codecNum; + result = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + else { + *p_srcNum = (int)tParamInfo.data; + } + } + else { + ret = -1; + } + + return ret; +} + +static int Mmux_setCodecSrc(int fd, int codecNum, int srcNum) +{ + int result; + int ret = 0; + + if (0 <= codecNum && codecNum < MMUX_TOTAL_CODEC) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = CODEC_0_SRC +codecNum; + tParamInfo.data = srcNum; + result = ioctl(fd, MMUX_IOCS_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + } + else { + ret = -1; + } + + return ret; +} + +static int Mmux_getCodecDst(int fd, int codecNum, int *p_dstNum) +{ + int result; + int ret = 0; + + if (0 <= codecNum && codecNum < MMUX_TOTAL_CODEC) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = VIDEO_OUT_MODE; + result = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + else { + if (codecNum != (int)tParamInfo.data) { + *p_dstNum = -1; + } + else { + // output_0. + *p_dstNum = 0; + } + } + } + else { + ret = -1; + } + + return ret; +} + +static int Mmux_getCodecSrcResolution(int fd, int codecNum, unsigned long *p_resolution) +{ + int result; + int ret = 0; + + if (0 <= codecNum && codecNum < MMUX_TOTAL_CODEC) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = CODEC_0_SRC_RESOLUTION +codecNum; + result = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + else { + *p_resolution = tParamInfo.data; + } + } + else { + ret = -1; + } + + return ret; +} + +static int Mmux_isCodecSrcConncet(int fd, int codecNum, int *p_isConncet) +{ + int result; + int ret = 0; + + if (0 <= codecNum && codecNum < MMUX_TOTAL_CODEC) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = CODEC_0_SRC_SCDT +codecNum; + result = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + else { + *p_isConncet = (int)tParamInfo.data; + } + } + else { + ret = -1; + } + + return ret; +} + + +static int Mmux_isCodecSrcDisable(int fd, int codecNum, int *p_isDisable) +{ + int result; + int ret = 0; + + if (0 <= codecNum && codecNum < MMUX_TOTAL_CODEC) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = CODEC_0_SRC_DISABLE +codecNum; + result = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + else { + *p_isDisable = (int)tParamInfo.data; + } + } + else { + ret = -1; + } + + return ret; +} + +static int Mmux_getOutputSrc(int fd, int outputNum, int *p_outputSrc) +{ + int result; + int ret = 0; + + if (0 <= outputNum && outputNum < TOTAL_OUTPUT) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = VIDEO_OUT_MODE; + result = ioctl(fd, MMUX_IOCG_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + else { + *p_outputSrc = (int)tParamInfo.data; + } + } + else { + ret = -1; + } + + return ret; +} + +static int Mmux_setOutputSrc(int fd, int outputNum, int outputSrc) +{ + int result; + int ret = 0; + + if (0 <= outputNum && outputNum < TOTAL_OUTPUT) { + struct MMUX_PARAM_INFO tParamInfo = {0}; + + tParamInfo.id = VIDEO_OUT_MODE; + tParamInfo.data = outputSrc; + result = ioctl(fd, MMUX_IOCS_PARAM, &tParamInfo); + if (result < 0) { + PERROR("ioctl"); + //ASSERT_SYS(0, "ioctl()"); + ret = -1; + } + } + else { + ret = -1; + } + + return ret; +} diff --git a/fmb_player_apl/src/scr/ConfEndOfPlay.c b/fmb_player_apl/src/scr/ConfEndOfPlay.c new file mode 100644 index 0000000..a31d400 --- /dev/null +++ b/fmb_player_apl/src/scr/ConfEndOfPlay.c @@ -0,0 +1,143 @@ +/** +* @brief The function of the decode confirmation screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ %s - finished -> Main menu ]]]\n\ + %s ~~~~~~~~->Enter\n\ +Finished %s.\n\ +Press <Enter> key to return to Main menu.\n\ +"; + +static const char validChars[] = "\n"; + +static const char *_screenTitle[2][2] = { + {"Decoding", + " "}, + {"One-picture decoding", + " "} +}; + +static const char *_screenComment[] = { + "decoding", + "One-picture decoding", +}; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +/** +* @brief Initial screen of the decode end confirmation. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitEndOfPlay(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum ScreenDecodeTypeEnum type = 0; + + FMB_FUNC(TRUE); + + switch(GetPrevScreen()){ + case ScrEnmDecNormal: + case ScrEnmDecPause: + case ScrEnmDecSlow: + type = ScrEnmDecType; + break; + case ScrEnmDec1pic: + type = ScrEnmDec1picType; + break; + default: + ASSERT_USR(FALSE, "Invalid prevScreen"); + break; + } + + printOut(_screenStr, _screenTitle[type][0], _screenTitle[type][1], _screenComment[type]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + + ChangeScreenTo(ScrEnmMainMenu); + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + + FMB_FUNC(TRUE); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/ConfPauseStart.c b/fmb_player_apl/src/scr/ConfPauseStart.c new file mode 100644 index 0000000..c477737 --- /dev/null +++ b/fmb_player_apl/src/scr/ConfPauseStart.c @@ -0,0 +1,165 @@ +/** +* @brief The function of posed start confirmation screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Start and pause - confirm -> Pause ]]]\n\ + 'B'<-~~~~~~~->Enter\n\ +Current settings\n\ + Stream input %s%s\n\ + Start file position %llu / %llu byte\n\ + Video format %s\n\ + Video framerate %s\n\ + Audio format %s\n\ +Press <Enter> key to start.\n\ +"; + +static const char validChars[] = "bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the posed start confirmation. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitConfPauseStart(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; + scr->childScreen = ScrEnmSelSingleDev; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + gp_FmbComProperty->setMode = FMBEnmFuncModeDec; + + if(! ScrConfSetData(ScrEnmConfPauseStartType)){ + ChangeScreenTo(ScrEnmScreenError); + FMB_FUNC(FALSE); + return TRUE; + } + + FmbInitStartPause(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmDecPause); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + char inputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; + __off64_t fileSize; + __off64_t fileStartPos; + + FMB_FUNC(TRUE); + + ASSERT_USR(req == FMBEnmReqInitStartPause, "Invalid request mode."); + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + fileStartPos = FmbGetStrmFilePos(FMBEnmStartPos); + fileSize = FmbGetFileSize(gp_FmbProperty[setmode].inputfile); + + printOut(_screenStr, + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath, + (gp_FmbProperty[setmode].inputPort == FMBEnmPortFile ) ? (unsigned long long)fileStartPos : 0, + (gp_FmbProperty[setmode].inputPort == FMBEnmPortFile ) ? (unsigned long long)fileSize : 0, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoFrms[gp_FmbProperty[setmode].videoFrm], + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt]); + + //Init is complete. + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ConfPlay1pic.c b/fmb_player_apl/src/scr/ConfPlay1pic.c new file mode 100644 index 0000000..db09fe8 --- /dev/null +++ b/fmb_player_apl/src/scr/ConfPlay1pic.c @@ -0,0 +1,163 @@ +/** +* @brief The function of 1- pic encode confirmation screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ One-picture decoding - confirm -> One-picture decoding ]]]\n\ + 'B'<-~~~~~~~->Enter\n\ +Current settings\n\ + Stream input %s%s\n\ + Video format %s\n\ + Video framerate %s\n\ + Audio format %s\n\ +Press <Enter> key to start.\n\ +"; + +static const char validChars[] = "bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the 1pic decode confirmation. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitConfDec1pic(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; + scr->childScreen = ScrEnmSelSingleDev; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + gp_FmbComProperty->setMode = FMBEnmFuncModeDec; + + if(! ScrConfSetData(ScrEnmConfDec1picType)){ + ChangeScreenTo(ScrEnmScreenError); + FMB_FUNC(FALSE); + return TRUE; + } + + FmbInitDec1pic(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmDec1pic); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + char inputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + switch(req){ + case FMBEnmReqInitDec1pic: //Init is complete. + + setmode = gp_FmbComProperty->setMode; + + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + printOut(_screenStr, + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoFrms[gp_FmbProperty[setmode].videoFrm], + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt]); + + SetInputEnabled(TRUE); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + } + + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ConfPlayNormal.c b/fmb_player_apl/src/scr/ConfPlayNormal.c new file mode 100644 index 0000000..fe93156 --- /dev/null +++ b/fmb_player_apl/src/scr/ConfPlayNormal.c @@ -0,0 +1,165 @@ +/** +* @brief The function of the normal-decode confirmation screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decoding - confirm -> Decoding ]]]\n\ + 'B'<-~~~~~~~->Enter\n\ +Current settings\n\ + Stream input %s%s\n\ + Start file position %llu / %llu byte\n\ + Video format %s\n\ + Video framerate %s\n\ + Audio format %s\n\ +Press <Enter> key to start decoding.\n\ +"; + +static const char validChars[] = "bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the decoding confirmation. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitConfDecNormal(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; + scr->childScreen = ScrEnmSelSingleDev; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + gp_FmbComProperty->setMode = FMBEnmFuncModeDec; + + if(! ScrConfSetData(ScrEnmConfDecNormalType)){ + ChangeScreenTo(ScrEnmScreenError); + FMB_FUNC(FALSE); + return TRUE; + } + + FmbInitDec(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmDecNormal); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + char inputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; + __off64_t fileSize; + __off64_t fileStartPos; + + + FMB_FUNC(TRUE); + + ASSERT_USR(req == FMBEnmReqInitDec, "Invalid request mode."); + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + fileStartPos = FmbGetStrmFilePos(FMBEnmStartPos); + fileSize = FmbGetFileSize(gp_FmbProperty[setmode].inputfile); + + printOut(_screenStr, + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath, + (gp_FmbProperty[setmode].inputPort == FMBEnmPortFile ) ? (unsigned long long)fileStartPos : 0, + (gp_FmbProperty[setmode].inputPort == FMBEnmPortFile ) ? (unsigned long long)fileSize : 0, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoFrms[gp_FmbProperty[setmode].videoFrm], + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ConfRec1pic.c b/fmb_player_apl/src/scr/ConfRec1pic.c new file mode 100644 index 0000000..27b7693 --- /dev/null +++ b/fmb_player_apl/src/scr/ConfRec1pic.c @@ -0,0 +1,186 @@ +/** +* @brief The function of 1pic encode confirmation screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ One-picture encoding - confirm ]]]\n\ + 'B'<-~~~~~~~->Enter\n\ +Current settings\n\ + Stream output %s%s\n\ + Video format %s\n\ + Video framerate %s\n\ + Video rate control %s\n\ + Video bitrate %s\n\ + System bitrate %dkbps[Muxrate:%dkbps]\n\ + Audio format %s\n\ + Audio bitrate %s\n\ +Press <Enter> key to start.\n\ +"; + +static const char validChars[] = "bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the 1pic encode confirmation. +* @brief Initilize screen +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitConfEnc1pic(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; + scr->childScreen = ScrEnmSelSingleDev; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + gp_FmbComProperty->setMode = FMBEnmFuncModeEnc; + + if(! ScrConfSetData(ScrEnmConfEnc1picType)){ + ChangeScreenTo(ScrEnmScreenError); + FMB_FUNC(FALSE); + return TRUE; + } + +#ifdef USE_MMUX // [ USE_MMUX + FmbAutoSetCurVideoFormat(); +#endif // USE_MMUX ] + FmbInitEnc1pic(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + FmbStartEnc1Pic(); + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + char video_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char audio_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char outputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqInitEnc1pic: //Init is complete. + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + ScrEditVideoBitrateString(video_bitrate, sizeof(video_bitrate)); + + ScrEditAudioBitrateString(audio_bitrate, sizeof(audio_bitrate)); + + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + printOut(_screenStr, + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoFrms[gp_FmbProperty[setmode].videoFrm], + g_FmbNameVideoRateCtls[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl], + video_bitrate, + gp_FmbProperty[setmode].videoBitrateProp.systemMuxRate, + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateParam.muxRate, + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt], + audio_bitrate); + + SetInputEnabled(TRUE); + break; + case FMBEnmReqStartEnc1Pic: //StartEnc1Pic-request is complete. + printOut("The one picture was encoded.\n"); + ChangeScreenTo(ScrEnmMainMenu); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ConfRecording.c b/fmb_player_apl/src/scr/ConfRecording.c new file mode 100644 index 0000000..f2a31bf --- /dev/null +++ b/fmb_player_apl/src/scr/ConfRecording.c @@ -0,0 +1,189 @@ +/** +* @brief The function of the encode confirmation screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStrTitle = "\ +[[[ Encoding - confirm -> Encoding ]]]\n\ + 'B'<-~~~~~~~->Enter\n\ +"; +static const char *_screenStrList = "\ +Current settings\n\ + Stream output %s%s\n\ + Video format %s\n\ + Video framerate %s\n\ + Video rate control %s\n\ + Video bitrate %s\n\ + Audio format %s\n\ + Audio bitrate %s\n\ +"; +static const char *_screenStrEnd = "\ +Press <Enter> key to start encoding.\n\ +"; + + +static const char validChars[] = "bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the encoding confirmation. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitConfEncoding(struct Screen *scr) +{ + FMB_FUNC(TRUE); + //scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; +#ifdef USE_MMUX // [ USE_MMUX + scr->childScreen = ScrEnmSelRecordDev; +#else // USE_MMUX ] [ !USE_MMUX + scr->childScreen = ScrEnmSelMultiDev; +#endif // !USE_MMUX ] + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBDeviceNumEnum devNum, devNum_old; + + FMB_FUNC(TRUE); + + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + gp_FmbComProperty->setMode = FMBEnmFuncModeEnc; + + if(! ScrConfSetData(ScrEnmConfEncodingType)){ + ChangeScreenTo(ScrEnmScreenError); + FMB_FUNC(FALSE); + return TRUE; + } + } + FmbMultiCall(FmbInitEnc); + + FmbSetCurDeviceNum(devNum_old); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmEncoding); + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + char video_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char audio_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char outputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; + enum FMBDeviceNumEnum devNum, devNum_old; + + FMB_FUNC(TRUE); + + printOut(_screenStrTitle); + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + + ASSERT_USR(req == FMBEnmReqInitEnc, "Invalid request mode."); + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + ScrEditVideoBitrateString(video_bitrate, sizeof(video_bitrate)); + + ScrEditAudioBitrateString(audio_bitrate, sizeof(audio_bitrate)); + + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + printOut(_screenStrList, + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoFrms[gp_FmbProperty[setmode].videoFrm], + g_FmbNameVideoRateCtls[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl], + video_bitrate, + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt], + audio_bitrate); + } + FmbSetCurDeviceNum(devNum_old); + printOut(_screenStrEnd); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ExecPlay1pic.c b/fmb_player_apl/src/scr/ExecPlay1pic.c new file mode 100644 index 0000000..fd4df7b --- /dev/null +++ b/fmb_player_apl/src/scr/ExecPlay1pic.c @@ -0,0 +1,130 @@ +/** +* @brief The function of 1pic-decode screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ One-picture decoding ]]]\n\ +Press <Enter> key to stop.\n\ +"; + +static const char validChars[] = "\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the 1pic-decode. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitDec1pic(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + FmbStartDec1pic(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + + FmbStop1picDec(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqStartDec1pic: //StartDec1pic-request is complete. + printOut(_screenStr); + SetInputEnabled(TRUE); + break; + case FMBEnmReqStop: //Stop-request is complete. + ChangeScreenTo(ScrEnmMainMenu); + break; + case FMBEnmReqAutoStop: //AutoStop-request is complete. + break; + case FMBEnmReqStopDecCore: //Stop-request is complete. + fprintOut(stdout, "\n"); + ChangeScreenTo(ScrEnmEndOfPlay); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ExecPlayNormal.c b/fmb_player_apl/src/scr/ExecPlayNormal.c new file mode 100644 index 0000000..1ef5b93 --- /dev/null +++ b/fmb_player_apl/src/scr/ExecPlayNormal.c @@ -0,0 +1,157 @@ +/** +* @brief The function of the normal-decode screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decoding ]]]\n\ +Select following character.\n\ + p Pause\n\ + s Slow\n\ + m Mute (%s)\n\ + e Stop and return\n\ +"; +static const char validChars[] = "pPsSmMeE"; + +static const char *_muteString[] = {"OFF", "ON"}; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the decoding. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitDecNormal(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->validChars = validChars; + scr->OnShowFunc = OnShow; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + FmbStartDecNormal(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'p': + case 'P': + ChangeScreenTo(ScrEnmDecPause); + break; + case 's': + case 'S': + ChangeScreenTo(ScrEnmDecSlow); + break; + case 'm': + case 'M': + gp_FmbProperty[gp_FmbComProperty->setMode].isMute = ! gp_FmbProperty[gp_FmbComProperty->setMode].isMute; /* pgr2711 */ + FmbSetMuteMode(); + SetInputEnabled(FALSE); + break; + case 'e': + case 'E': + FmbStop(); + SetInputEnabled(FALSE); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqStartDecNormal: //Dec-request is complete. + printOut(_screenStr, _muteString[gp_FmbProperty[gp_FmbComProperty->setMode].isMute]); + SetInputEnabled(TRUE); + break; + case FMBEnmReqMute: //The mute mode of audio is set. + DrawDelimitationLine(); + printOut(_screenStr, _muteString[gp_FmbProperty[gp_FmbComProperty->setMode].isMute]); + SetInputEnabled(TRUE); + break; + case FMBEnmReqStop: //Stop-request is complete. + ChangeScreenTo(ScrEnmMainMenu); + break; + case FMBEnmReqAutoStop: //AutoStop-request is complete. + break; + case FMBEnmReqStopDecCore: //Stop-request is complete. + fprintOut(stdout, "\n"); + ChangeScreenTo(ScrEnmEndOfPlay); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ExecPlayPause.c b/fmb_player_apl/src/scr/ExecPlayPause.c new file mode 100644 index 0000000..ec7d6f7 --- /dev/null +++ b/fmb_player_apl/src/scr/ExecPlayPause.c @@ -0,0 +1,153 @@ +/** +* @brief The function of the pause decode screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Pause ]]]\n\ +Select following character.\n\ + d Decoding\n\ + s Slow\n\ + f Frame advance\n\ + e Stop and return\n\ +"; + +static const char validChars[] = "dDsSfFeE"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the pause decode. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitDecPause(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + FmbPause(); + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + switch(InputCharacterCode){ + case 'd': + case 'D': + ChangeScreenTo(ScrEnmDecNormal); + break; + case 's': + case 'S': + ChangeScreenTo(ScrEnmDecSlow); + break; + case 'f': + case 'F': + FmbStartDecFrameAdvance(); + SetInputEnabled(FALSE); + break; + case 'e': + case 'E': + FmbStop(); + SetInputEnabled(FALSE); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqPause: //Pause-Request is complete. + printOut(_screenStr); + SetInputEnabled(TRUE); + break; + case FMBEnmReqStartDecFrameAdvance: //FrameAdvancePlay-request is complete. + ChangeScreenTo(ScrEnmDecPause); + break; + case FMBEnmReqStop: //Stop-request is complete. + ChangeScreenTo(ScrEnmMainMenu); + break; + case FMBEnmReqAutoStop: //AutoStop-request is complete. + break; + case FMBEnmReqStopDecCore: //Stop-request is complete. + fprintOut(stdout, "\n"); + ChangeScreenTo(ScrEnmEndOfPlay); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ExecPlaySlow.c b/fmb_player_apl/src/scr/ExecPlaySlow.c new file mode 100644 index 0000000..46657bc --- /dev/null +++ b/fmb_player_apl/src/scr/ExecPlaySlow.c @@ -0,0 +1,158 @@ +/** +* @brief The function of the slow decode screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Slow 1/%g ]]]\n\ +Select following character.\n\ + p Pause\n\ + d Decoding\n\ + s Slow\n\ + e Stop and return\n\ +"; + +static const char validChars[] = "pPdDsSeE"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the slow decode. +* @brief Initilize screen +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitDecSlow(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBResultEnum fmbResult; + + FMB_FUNC(TRUE); + + fmbResult = FmbStartDecSlow(); + if(fmbResult == FMBEnmResultRequestComplete){ + printOut(_screenStr, gp_FmbProperty[gp_FmbComProperty->setMode].speedSlow); + SetInputEnabled(TRUE); + } + else{ + SetInputEnabled(FALSE); + } + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case 'p': + case 'P': + ChangeScreenTo(ScrEnmDecPause); + break; + case 'd': + case 'D': + ChangeScreenTo(ScrEnmDecNormal); + break; + case 's': + case 'S': + ChangeScreenTo(ScrEnmDecSlow); + break; + case 'e': + case 'E': + FmbStop(); + SetInputEnabled(FALSE); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqStartDecSlow: //Start-request is complete. + printOut(_screenStr, gp_FmbProperty[gp_FmbComProperty->setMode].speedSlow); + SetInputEnabled(TRUE); + break; + case FMBEnmReqStop: //Stop-request is complete. + ChangeScreenTo(ScrEnmMainMenu); + break; + case FMBEnmReqAutoStop: //AutoStop-request is complete. + break; + case FMBEnmReqStopDecCore: //Stop-request is complete. + fprintOut(stdout, "\n"); + ChangeScreenTo(ScrEnmEndOfPlay); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/ExecRecording.c b/fmb_player_apl/src/scr/ExecRecording.c new file mode 100644 index 0000000..3037c0b --- /dev/null +++ b/fmb_player_apl/src/scr/ExecRecording.c @@ -0,0 +1,122 @@ +/** +* @brief The function of the encode screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encoding ]]]\n\ +Press <Enter> key to stop.\n\ +"; + +static const char validChars[] = "\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the encoding. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitEncoding(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + FmbMultiCall(FmbStartEnc); // FmbStartEnc(); + + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + + FmbMultiCall( FmbStop ); // FmbStop(); + SetInputEnabled(FALSE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqStartEnc: //StartEncode-request is complete. + printOut(_screenStr); + SetInputEnabled(TRUE); + break; + case FMBEnmReqStop: //Stop-request is complete. + ChangeScreenTo(ScrEnmMainMenu); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/ExecScriptCommand.c b/fmb_player_apl/src/scr/ExecScriptCommand.c new file mode 100644 index 0000000..02241ca --- /dev/null +++ b/fmb_player_apl/src/scr/ExecScriptCommand.c @@ -0,0 +1,241 @@ +/** +* @brief The function of the script commands is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <sys/stat.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" +#include "CmdUtil.h" + +static const char *_screenStr = "\ +[[[ Script command mode ]]]\n\ +"; + +static BOOL s_waitState = FALSE; +static BOOL s_isRecvTrace; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +static BOOL excute_command( int len , char* cmdbuf); + + +void FmbSetPauseCommand(void) +{ + FMB_FUNC(TRUE); + + s_waitState=TRUE; + + FMB_FUNC(FALSE); +} + +/** +* @brief Initial screen of the script command. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSriptCommand(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + fprintOut(stdout, _screenStr); + + SetInputEnabled(TRUE); + + s_isRecvTrace = g_dbg.isRecvTrace; + g_dbg.isRecvTrace=TRUE; + + s_waitState=FALSE; + + FMB_FUNC(FALSE); + return TRUE; +} +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqStartCommand: + break; + case FMBEnmReqAutoStop: + break; + case FMBEnmReqStopDecCore: + ChangePrevScreenTo(ScrEnmNormalMode, ScrEnmEndOfPlay); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + }; + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + int len; + char* cmdbuf; + struct RecvEventArgType event; + BOOL cmdExec; + enum FMBDeviceNumEnum deviceNum = FMBEnmDevice_0; + + + FMB_FUNC(TRUE); + + if (s_waitState){ + event.devNum = deviceNum; + event.dev = FMBEnmCoreDeviceStream; + event.evnt = FMBEnmCoreFromInputKey; + LogFmb("[OnLineInput]FmbRecvSendEvent dev=%d evnt=%d ",event.dev,event.evnt); + FmbRecvSendEvent(&event, *gp_FmbInfo->pt_deviceInfo_A[deviceNum]->t_RecvThread.t_env.p_fdPipeWrite ); + s_waitState=FALSE; + + FMB_FUNC(FALSE); + return TRUE; + } + + switch(*lineString){ + case 'q': + case 'Q': + switch(g_RunMode){ + case FMBEnmRunModeCommand: + FMB_FUNC(FALSE); + exit(0); + return TRUE; + break; + default: + if(lineString[1] == '\0'){ + g_dbg.isRecvTrace= s_isRecvTrace; + FmbCancelRequest(); + ReturnToAnotherScreenMode(ScrEnmNormalMode); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + } + break; + default: + len = strlen(lineString); + if (len==0) { + SetInputEnabled(TRUE); + break; + } + cmdbuf = malloc(len+1); + if(cmdbuf != NULL){ + strcpy(cmdbuf,lineString); + cmdExec = excute_command(len,cmdbuf); + } + SetInputEnabled(TRUE); + break; + } + + + FMB_FUNC(FALSE); + return TRUE; /* pgr0524 */ +} + +static BOOL excute_command( int len , char* cmdbuf) +{ + int i=0; + FMB_FUNC(TRUE); + struct SceTableType *sceScriptCommand = NULL ; + + for(i=0;i<len;i++){ + if ( cmdbuf[i] == ' ' || cmdbuf[i]=='\n' || cmdbuf[i]=='\r'){ + break; + } + } + + if ( memcmp("scrpt",cmdbuf,i) == 0){ + sceScriptCommand = FmbCeateCommandScenario(cmdbuf); + if (sceScriptCommand == NULL){ + return FALSE; + } + FmbStartCommandSenario(sceScriptCommand); + return TRUE; + } + else{ + FmbStartCommand(cmdbuf); + } + +// +// +// +// + + FMB_FUNC(FALSE); + return TRUE; + +} diff --git a/fmb_player_apl/src/scr/MainMenu.c b/fmb_player_apl/src/scr/MainMenu.c new file mode 100644 index 0000000..f17c77c --- /dev/null +++ b/fmb_player_apl/src/scr/MainMenu.c @@ -0,0 +1,182 @@ +/** +* @brief The function of the main menu screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +#ifdef USE_MMUX // [USE_MMUX +static const char *_screenStr = "\ +< Main menu >\n\ +Select following character.\n\ +\n\ + 1 Encoding\n\ + 2 Decoding\n\ + 3 Decoding(Start pause)\n\ +\n\ + 4 One-picture encoding\n\ + 5 One-picture decoding\n\ +\n\ + 6 Encode settings\n\ + 7 Decode settings\n\ +\n\ + 8 Video I/O settings\n\ +\n\ + 9 Exit\n\ +\n\ +"; + +static const char validChars[] = "123456789"; +#else // USE_MMUX] [!USE_MMUX +static const char *_screenStr = "\ +< Main menu >\n\ +Select following character.\n\ +\n\ + 1 Encoding\n\ + 2 Decoding\n\ + 3 Decoding(Start pause)\n\ +\n\ + 4 One-picture encoding\n\ + 5 One-picture decoding\n\ +\n\ + 6 Encode settings\n\ + 7 Decode settings\n\ +\n\ + 9 Exit\n\ +\n\ +"; + +static const char validChars[] = "12345679"; +#endif +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitMainMenu(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + scr->OnShowFunc = OnShow; + scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + FmbEnableDevUseAll(); + FmbMultiCall(FmbReset); //FmbReset(); + + SetInputEnabled(FALSE); //The input is enabled. + FmbDisableDeviceSel(); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + ChangeScreenTo(ScrEnmConfEncoding); + break; + case '2': + ChangeScreenTo(ScrEnmConfDecNormal); + break; + case '3': + ChangeScreenTo(ScrEnmConfPauseStart); + break; + case '4': + ChangeScreenTo(ScrEnmConfEnc1pic); + break; + case '5': + ChangeScreenTo(ScrEnmConfDec1pic); + break; + case '6': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + break; + case '7': + ChangeScreenTo(ScrEnmSetSubMenuDec); + break; + case '8': + ChangeScreenTo(ScrEnmSetVideoInOut); + break; + case '9': + FMB_FUNC(FALSE); + return FALSE; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + + FMB_FUNC(TRUE); + + printOut(_screenStr); + SetScreenMode(ScrEnmMode1key); + + SetInputEnabled(TRUE); //The input is enabled. + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/Screen.c b/fmb_player_apl/src/scr/Screen.c new file mode 100644 index 0000000..d918dc5 --- /dev/null +++ b/fmb_player_apl/src/scr/Screen.c @@ -0,0 +1,1361 @@ +/** +* @brief The function of the Screen collection module and the screen module is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <stdarg.h> +#include <termios.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + + +//Local, static variable +static struct ScreenCollection _screens; +static BOOL _isEnable = FALSE; + +//The input buffer of Stdin is cleared. +static void FlushStdin(void); + +//It changes to the next screen. +static BOOL ChangeNextScreen(void); + +//The specified buffer is dumping edited. +static void LogKeyBuff(const char *keyBuff, size_t len); + +static enum FMBRequestEnum ClrAllLastRequest(void); + + +///Error screen message +struct ErrorScreenMessage g_ErrorScreenMessage; + +///select mark "*" +const char g_selectMarks[16][16] = { + {'*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' '}, + {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*'}, + }; + +const char *_videoBitrateRanges[] = { + "6000kbps -- 24000kbps(I) or 30000kbps(P)", + "5000kbps -- 24000kbps", + "4000kbps -- 24000kbps", + "2000kbps -- 10000kbps", + "2000kbps -- 10000kbps", +}; + +///Kind of result file access.(index by FMBFileResultEnum) +const char *_fileResult[] = { + "File Normal end", ///<Normal end + "File access fail", ///<File access fail + "File execution fail", ///<File execution fail + "File packet size fail", ///<File Packet Size fail + "File open fail", ///<File open fail +}; + +///Kind of confirmation screen.(index by ScreenConfTypeEnum) +const char *_confScreen[] = { + "Encoding", ///<1:Encoding + "Decoding", ///<2:Decoding + "Start and pause", ///<3:Start and pause + "", ///<4:reserve + "One-picture encoding", ///<5:One-picture encoding + "One-picture decoding", ///<6:One-picture decoding +}; + +///Kind of the sub menu setting screen.(index by ScreenSetSubMenuTypeEnum) +const char *_screenSubmenuTitle[2][2] = { + {"Encode settings - Sub menu", + " "}, + {"Decode settings - Sub menu", + " "} +}; + +///Invalid character code. +const int g_invalidCharaCode[] = { + FMB_CODE_QUOTATION_MARKS, + FMB_CODE_ASTERISK, + FMB_CODE_COLON, + FMB_CODE_LESS_THAN_SIGN, + FMB_CODE_GRATER_THAN_SIGN, + FMB_CODE_QUESTION_MARK, + FMB_CODE_BACKSLASH, + FMB_CODE_BERTIE_KALVER, +}; + +const enum FMBCheckVideoFormatEnum g_VideoFormatCheckEnc[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = { + { + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +const enum FMBCheckVideoFormatEnum g_VideoFormatCheckDec[FMBEnmVideoFmtMax][FMBEnmVideoFrmMax] = { + { + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtLimitations , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1920x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt1440x1080 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994p + FMBEnmVFmtOK , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt1280x720 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50p + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_60i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_5994i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x480 FMBEnmVideoFrm_50i + }, + { + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50p + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_60i + FMBEnmVFmtNG , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_5994i + FMBEnmVFmtOK , //< FMBEnmVideoFmt720x576 FMBEnmVideoFrm_50i + } +}; + +enum FMBCheckAudioFormatEnum g_AudioFormatCheck[FMBEnmAudioFmtMax]= { + FMBEnmAFmtNG , //< FMBEnmAudioFmtMpeg1l2 + FMBEnmAFmtNG , //< FMBEnmAudioFmtAc3 + FMBEnmAFmtNG , //< FMBEnmAudioFmtAac + FMBEnmAFmtNG , //< FMBEnmAudioFmtLpcm +}; + +static const char *_screenStrErrorInfoBitrateEnc = "\ + Current screen %s - confirm\n\ + Video input %s\n\ + Stream output %s%s\n\ + Video format %s\n\ + Video rate control %s\n\ + Video bitrate %s\n\ + System bitrate %dkbps[Muxrate:%dkbps]\n\ + Audio format %s\n\ + Audio bitrate %s"; + +static const char *_screenStrErrorInfoFileIn = "\ + Current screen %s - confirm\n\ + Stream input %s%s\n\ + Result %s"; + +static const char *_screenStrErrorInfoFileOut = "\ + Current screen %s - confirm\n\ + Stream output %s%s\n\ + Result %s"; + +static const char *_screenStrErrorVideoFormat = "\ + Current screen %s - confirm\n\ + Video format %s\n\ + Video framerate %s\n\ + Video scaler %s"; + +static const char *_screenStrErrorPaketSizeIn = "\ + Current screen %s - confirm\n\ + Stream input %s%s"; + +static const char *_screenStrErrorPaketSizeOut = "\ + Current screen %s - confirm\n\ + Stream output %s%s"; + +static const char *_screenStrErrorInputPort = "\ + Current screen %s - confirm\n\ + Stream input %s%s"; + +static const char *_screenStrErrorOutputPort = "\ + Current screen %s - confirm\n\ + Stream output %s%s"; + +static char s_error_variable_factor[FMB_FACTOR_MAX_CHAR]={0}; + +//unsigned short g_Firm_LSI_Ver = 0x0000; +//unsigned long g_SubsystemId = 0x0000; +enum FMBRunModeEnum g_RunMode = FMBEnmRunModeNormal; + +/** +* @brief The Screen collection module is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitScreens(void) +{ + memset(&_screens, 0, sizeof(_screens)); + + FMB_FUNC(TRUE); + + InitMainMenu(&_screens.screens[ScrEnmMainMenu]); + InitSetSubMenuEnc(&_screens.screens[ScrEnmSetSubMenuEnc]); + InitSetSubMenuDec(&_screens.screens[ScrEnmSetSubMenuDec]); + InitSetAudioBitrateMpeg1l2Enc(&_screens.screens[ScrEnmSetAudioBitrateMpeg1l2Enc]); + InitSetAudioBitrateAc3Enc(&_screens.screens[ScrEnmSetAudioBitrateAc3Enc]); + InitSetAudioBitrateAacEnc(&_screens.screens[ScrEnmSetAudioBitrateAacEnc]); + InitSetAudioBitrateLpcmEnc(&_screens.screens[ScrEnmSetAudioBitrateLpcmEnc]); + InitSetAudioFormatEnc(&_screens.screens[ScrEnmSetAudioFormatEnc]); + InitSetAudioFormatDec(&_screens.screens[ScrEnmSetAudioFormatDec]); + InitSetInputPortDec(&_screens.screens[ScrEnmSetInputPortDec]); + InitSetOutputPortEnc(&_screens.screens[ScrEnmSetOutputPortEnc]); + InitSetVideoRatecontrol(&_screens.screens[ScrEnmSetVideoRatecontrol]); + InitSetVideoBitrateCbr(&_screens.screens[ScrEnmSetVideoBitrateCbr]); + InitSetVideoBitrateVbr(&_screens.screens[ScrEnmSetVideoBitrateVbr]); + InitSetVideoFormatEnc(&_screens.screens[ScrEnmSetVideoFormatEnc]); + InitSetVideoFormatDec(&_screens.screens[ScrEnmSetVideoFormatDec]); + InitSetVideoFrameEnc(&_screens.screens[ScrEnmSetVideoFrameEnc]); + InitSetVideoFrameDec(&_screens.screens[ScrEnmSetVideoFrameDec]); + InitSetVideoScalerEnc(&_screens.screens[ScrEnmSetVideoScalerEnc]); + InitConfEncoding(&_screens.screens[ScrEnmConfEncoding]); + InitConfDecNormal(&_screens.screens[ScrEnmConfDecNormal]); + InitConfDec1pic(&_screens.screens[ScrEnmConfDec1pic]); + InitConfPauseStart(&_screens.screens[ScrEnmConfPauseStart]); + InitConfEnc1pic(&_screens.screens[ScrEnmConfEnc1pic]); + InitEncoding(&_screens.screens[ScrEnmEncoding]); + InitDecPause(&_screens.screens[ScrEnmDecPause]); + InitDecNormal(&_screens.screens[ScrEnmDecNormal]); + InitDec1pic(&_screens.screens[ScrEnmDec1pic]); + InitDecSlow(&_screens.screens[ScrEnmDecSlow]); + InitEndOfPlay(&_screens.screens[ScrEnmEndOfPlay]); + InitSetFile(&_screens.screens[ScrEnmSetFile]); + InitSetFileStartPos(&_screens.screens[ScrEnmSetFileStartPos]); + InitSetSystemBitrate(&_screens.screens[ScrEnmSetSystemBitrate]); + InitSetSubMenuCom(&_screens.screens[ScrEnmSetSubMenuCom]); + InitSetTsPacketCom(&_screens.screens[ScrEnmSetTsPacketCom]); + InitSetPidTypeCom(&_screens.screens[ScrEnmSetPidTypeCom]); + InitSetInOutPidCom(&_screens.screens[ScrEnmSetInOutPidCom]); + InitSetTsTypeCom(&_screens.screens[ScrEnmSetTsTypeCom]); + InitSetFirmCom(&_screens.screens[ScrEnmSetFirmCom]); + InitSetConfigCom(&_screens.screens[ScrEnmSetConfigCom]); + InitScreenError(&_screens.screens[ScrEnmScreenError]); + InitSetOption(&_screens.screens[ScrEnmSetOption]); + InitSriptCommand(&_screens.screens[ScrEnmEecScriptCommand]); + InitSelSingleDev(&_screens.screens[ScrEnmSelSingleDev]); +#ifdef USE_MMUX // [ USE_MMUX + InitSelRecordDev(&_screens.screens[ScrEnmSelRecordDev]); +#else // USE_MMUX ] [ !USE_MMUX + InitSelMultiDev(&_screens.screens[ScrEnmSelMultiDev]); +#endif // !USE_MMUX ] + InitSetVideoIO(&_screens.screens[ScrEnmSetVideoInOut]); + InitSetVideoOut(&_screens.screens[ScrEnmSetVideoOut]); + InitSetVideoResolutionEnc(&_screens.screens[ScrEnmSetVideoRsltnEnc]); + InitSetVideoResolutionDec(&_screens.screens[ScrEnmSetVideoRsltnDec]); + InitSetVideoOutMode(&_screens.screens[ScrEnmSetVideoOutMode]); + InitSetVideoOutBypass(&_screens.screens[ScrEnmSetVideoOutBypass]); + InitSetVideoOutH264(&_screens.screens[ScrEnmSetVideoOutH264]); + + switch(g_RunMode){ + case FMBEnmRunModeCommand: + ChangeScreenAndModeTo(ScrEnmEecScriptCommand, ScrEnmScriptCommandMode); + ChangeNextScreen(); + break; + default: + ChangeScreenAndModeTo(ScrEnmMainMenu, ScrEnmNormalMode); + ChangeNextScreen(); + } + + _screens.inputMode[ScrEnmScriptCommandMode]=ScrEnmModeKeybuffer; + _screens.inputMode[ScrEnmOptionMode]=ScrEnmMode1key; + _screens.prevScreen[ScrEnmScriptCommandMode]=ScrEnmSetOption; + _screens.prevScreen[ScrEnmOptionMode]=ScrEnmSetOption; + _screens.currentScreen[ScrEnmScriptCommandMode]=ScrEnmEecScriptCommand; + _screens.currentScreen[ScrEnmOptionMode]=ScrEnmEecScriptCommand; + + FMB_FUNC(FALSE); +} + +/** +* @brief The screen is set to 1Key or the Key-Buffer mode. +* @param[in] inputMode Kind of screen input mode. +* @return The input mode before is returned. +* @note None +* @attention None +*/ +enum ScreenInputModeEnum SetScreenMode(enum ScreenInputModeEnum inputMode) +{ + static BOOL _isFirst = TRUE; + static struct termios _settingsOriginal; + static struct termios _settingsKeybuffer; + static struct termios _settings1Key; + int rc; + enum ScreenInputModeEnum previnputMode; + + if(_isFirst){ + rc = tcgetattr(STDIN_FILENO, &_settingsOriginal); + ASSERT_SYS(rc == 0, "tcgetattr"); + _settings1Key = _settingsOriginal; + _settings1Key.c_lflag &= ~ICANON; + _settings1Key.c_lflag &= ~ECHO; + _settings1Key.c_cc[VMIN] = 0; + _settings1Key.c_cc[VTIME] = 0; + + _settingsKeybuffer = _settingsOriginal; + _settingsKeybuffer.c_lflag |= ICANON; + _settingsKeybuffer.c_lflag |= ECHO; + _settingsKeybuffer.c_lflag |= ECHOCTL; + _isFirst = FALSE; + } + + FMB_FUNC(TRUE); + switch(inputMode){ + case ScrEnmMode1key: + rc = tcsetattr(STDIN_FILENO, TCSANOW, &_settings1Key); + ASSERT_SYS(rc == 0, "tcsetattr"); + break; + case ScrEnmModeKeybuffer: + rc = tcsetattr(STDIN_FILENO, TCSANOW, &_settingsKeybuffer); + ASSERT_SYS(rc == 0, "tcsetattr"); + break; + case ScrEnmModeOriginal: + rc = tcsetattr(STDIN_FILENO, TCSANOW, &_settingsOriginal); + ASSERT_SYS(rc == 0, "tcsetattr"); + break; + default: + ASSERT_USR(FALSE, "Invalid inputMode"); + } + previnputMode = _screens.inputMode[_screens.currentMode]; + _screens.inputMode[_screens.currentMode] = inputMode; + FMB_FUNC(FALSE); + return previnputMode; +} + +/** +* @brief Event when input is done to standard input +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +BOOL OnStdinInput(void) +{ + int rc; + BOOL isContinue = TRUE; + struct Screen *scr; + char keybuff[FMB_KEYBUFF_MAX_CHAR]; + char *geted; + size_t len; + + FMB_FUNC(TRUE); + + if(_screens.inputMode[_screens.currentMode] == ScrEnmMode1key){ + rc = read(STDIN_FILENO, keybuff, sizeof(keybuff)); //One character is read. + ASSERT_SYS(rc != -1, "read()"); + len = rc; + LogKeyBuff(keybuff, len); + if((len == 1) && (keybuff[0] == FMB_KEY_ESC)){ /* pgr0020 */ //If Esc-key, + if(_screens.currentScreen[_screens.currentMode] != ScrEnmMainMenu){ + FmbMultiCall(FmbCancelRequest); + fprintOut(stdout, "\n"); + ChangeScreenTo(ScrEnmMainMenu); + ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; + } + } + } + else{ + geted = fgets(keybuff, sizeof(keybuff), stdin); //1 line is read. + ASSERT_SYS(geted != NULL, "fgets()"); + len = strlen(keybuff); + LogKeyBuff(keybuff, len); + } + + if(GetInputEnabled()){ //If the input to the screen is effective, + if(keybuff[0] == FMB_KEY_CTRL_O){ //If Ctrl+o key, + if(_screens.currentScreen[_screens.currentMode] != ScrEnmSetOption){ + fprintOut(stdout, "\n"); + ChangeScreenAndModeTo(ScrEnmSetOption, ScrEnmOptionMode); + ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; + } + } + if(keybuff[0] == FMB_KEY_CTRL_X){ //If Ctrl+x key, + if(_screens.currentScreen[_screens.currentMode] != ScrEnmEecScriptCommand){ + fprintOut(stdout, "\n"); + ChangeScreenAndModeTo(ScrEnmEecScriptCommand, ScrEnmScriptCommandMode); + ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; + } + } + + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + if(_screens.inputMode[_screens.currentMode] == ScrEnmMode1key){ + if(strchr(scr->validChars, keybuff[0]) == NULL){ + FMB_FUNC(FALSE); + return TRUE; + } + putchar(keybuff[0]); + if(keybuff[0] != '\n'){ + putchar('\n'); + } + ASSERT_USR(scr->OnKeyFunc != NULL, "Current OnKeyFunc is NULL."); + + LogScrEvent("OnKeyFunc\t%d\tkey\t%d", _screens.currentScreen[_screens.currentMode], keybuff[0]); + isContinue = scr->OnKeyFunc(keybuff[0]); + } + else{ + if(keybuff[len-1] != '\n'){ + MsgDispInputErr(FMB_INPUTERR_TOO_LONG_CHAR); + FlushStdin(); + FMB_FUNC(FALSE); + return TRUE; + } + ASSERT_USR(keybuff[len-1] == '\n', "Not terminated LF"); + keybuff[len-1] = '\0'; + ASSERT_USR(scr->OnLineInputFunc != NULL, "Current OnLineInputFunc is NULL."); + LogScrEvent("OnLineInputFunc\t%d\tkeybuff\t%s", _screens.currentScreen[_screens.currentMode], keybuff); + isContinue = scr->OnLineInputFunc(keybuff); + } + if(GetInputEnabled()){ + if ( gp_FmbComProperty->currentRequest == FMBEnmReqStartCommand){ + return TRUE; //Continue:TRUE End of AP:FALSE + } + ASSERT_USR(gp_FmbComProperty->currentRequest == FMBEnmReqNothing, "It is possible to input it though it is requesting. "); + } + + isContinue &= ChangeNextScreen(); + } + FMB_FUNC(FALSE); + return isContinue; //Continue:TRUE End of AP:FALSE +} + +/** +* @brief The specified buffer is dumping edited. +* @param[in] keybuff Target key buffer +* @param[in] len Size of key buffer +* @return None +* @note For output log. +* @attention None +*/ +static void LogKeyBuff(const char *keybuff, size_t len) +{ + char logStringBuff[FMB_KEYBUFF_MAX_CHAR * 3 +1]; + char *logString; + size_t i; + + FMB_FUNC(TRUE); + + if(! g_dbg.isScrLog){ + FMB_FUNC(FALSE); + return; + } + logString = logStringBuff; + logStringBuff[sizeof(logStringBuff) -1] = '\0'; + for(i = 0; i < len; i++){ + logString += snprintf(logString, 4, "%02x ", keybuff[i]); + } + ASSERT_USR(logStringBuff[sizeof(logStringBuff) -1] == '\0', "Buffer over run."); + LogScr("InputCharCode\t%s", logStringBuff); + + FMB_FUNC(FALSE); +} + +/** +* @brief Response of demand for FMB device. +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +BOOL OnFmbRequestResponse(void) +{ + struct Screen *scr; + enum FMBRequestEnum req; + BOOL isContinue; + + FMB_FUNC(TRUE); + + req = ClrAllLastRequest(); + + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnFmbRequestCompleteFunc != NULL, "OnFmbRequestCompleteFunc is NULL."); + + LogScrEvent("OnFmbRequestCompleteFunc\t%d\treq\t%d", _screens.currentScreen[_screens.currentMode], req); + + scr->OnFmbRequestCompleteFunc(req); + + isContinue = ChangeNextScreen(); + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The state of the screen (..can input.. impropriety) is set. +* @param[in] isEnable TRUE:Inputting enable FALSE:Inputting disable +* @return None +* @note None +* @attention None +*/ +void SetInputEnabled(BOOL isEnable) +{ + struct Screen *scr; + + FMB_FUNC(TRUE); + + if(isEnable){ + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + if(scr->prompt != NULL){ + printOut("%s", scr->prompt); + } + printOut("%s?>", gp_FmbComProperty->deviceName); + fflush(stdout); + } + _isEnable = isEnable; + + FMB_FUNC(FALSE); +} + +/** +* @brief The state of the screen (..can input.. impropriety) is returned. +* @param[in] None +* @return TRUE Inputting enable +* @return FALSE Inputting disable +* @note None +* @attention None +*/ +BOOL GetInputEnabled(void) +{ + FMB_FUNC(TRUE); + FMB_FUNC(FALSE); + return _isEnable; +} + +/** +* @brief It changes to the specified screen. +* @param[in] scrEnm Enumeration that identifies screen. +* @return None +* @note None +* @attention None +*/ +void ChangeScreenTo(enum ScreenEnum scrEnm) +{ + FMB_FUNC(TRUE); + _screens.isScreenChanged = TRUE; + _screens.nextScreen = scrEnm; + FMB_FUNC(FALSE); +} + +/** +* @brief It changes to the specified screen and mode. +* @param[in] scrEnm Enumeration that identifies screen. +* @param[in] scrMode Enumeration that identifies mode. +* @return None +* @note None +* @attention None +*/ +void ChangeScreenAndModeTo(enum ScreenEnum scrEnm, enum ScreenMode scrMode) +{ + FMB_FUNC(TRUE); + _screens.isScreenChanged = TRUE; + _screens.isScreenModeChanged = TRUE; + _screens.nextScreen = scrEnm; + _screens.nextMode = scrMode; + FMB_FUNC(FALSE); +} + +/** +* @brief The message of the input error is displayed. +* @param[in] msg Error message +* @return None +* @note None +* @attention None +*/ +void MsgDispInputErr(char *msg) +{ + FMB_FUNC(TRUE); + + MsgDispInputErrNoPrompt(msg); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); +} + +/** +* @brief The message of the input error is displayed. +* @param[in] msg Error message +* @return None +* @note Don't display prompt +* @attention None +*/ +void MsgDispInputErrNoPrompt(char *msg) +{ + FMB_FUNC(TRUE); + + fprintOut(stdout, "\x1b[31mInput Error:"); + + printOut( msg); + + fprintOut(stdout, "\x1b[m\n"); + + FMB_FUNC(FALSE); +} + +/* +Internal Functions +*/ + +/** +* @brief The input buffer of Stdin is cleared. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +static void FlushStdin(void) +{ + int ch; + + FMB_FUNC(TRUE); + do{ + ch = getchar(); + ASSERT_SYS(EOF != ch, "getchar()"); + LogScr("FlushStdin\tgetchar\t0x%02x", ch); + }while(ch != '\n'); + FMB_FUNC(FALSE); +} + +/** +* @brief It changes to the next screen. +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL ChangeNextScreen(void) +{ + struct Screen *scr; + BOOL isContinue; + + FMB_FUNC(TRUE); + if(_screens.isScreenChanged){ //if screen changed, + if(_screens.isScreenModeChanged){ + _screens.isScreenModeChanged = FALSE; + _screens.currentMode = _screens.nextMode; + } + _screens.isScreenChanged = FALSE; + _screens.prevScreen[_screens.currentMode] = _screens.currentScreen[_screens.currentMode]; + _screens.currentScreen[_screens.currentMode] = _screens.nextScreen; + DrawDelimitationLine(); + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnShowFunc != NULL, "Next OnShowFunc is NULL."); + + if (scr->IsShowChildFunc != NULL && _screens.currentMode == ScrEnmNormalMode){ + if (scr->IsShowChildFunc()) { + _screens.prevScreen[_screens.currentMode] = _screens.currentScreen[_screens.currentMode]; + _screens.currentScreen[_screens.currentMode] = scr->childScreen; + DrawDelimitationLine(); + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnShowFunc != NULL, "Next OnShowFunc is NULL."); + } + } + + LogScrEvent("OnShowFunc\t%d", _screens.currentScreen[_screens.currentMode]); + isContinue = scr->OnShowFunc(); + + //Case of Error Screen + if (_screens.nextScreen == ScrEnmScreenError){ + _screens.prevScreen[_screens.currentMode] = _screens.currentScreen[_screens.currentMode]; + _screens.currentScreen[_screens.currentMode] = _screens.nextScreen; + scr = &_screens.screens[_screens.currentScreen[_screens.currentMode]]; + ASSERT_USR(scr->OnShowFunc != NULL, "Next OnShowFunc is NULL."); + + LogScrEvent("OnShowFunc\t%d", _screens.currentScreen[_screens.currentMode]); + isContinue = scr->OnShowFunc(); + } + + FMB_FUNC(FALSE); + return isContinue; + } + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The delimitation line is displayed. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void DrawDelimitationLine(void) +{ + fprintOut(stdout, "-------------------------------------------------------------------------------\n"); +} + +/** +* @brief The video bitrate character string is edited. +* @param[out] destBuff Buffer where edited character string is stored. +* @param[in] destBuffSize The size of the buffer is specified. + The application terminates abnormally when the edit result exceeds this. +* @return None +* @note None +* @attention None +*/ +void ScrEditVideoBitrateString(char *destBuff, int destBuffSize) +{ + int editedNumofChar = 0; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + if(gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl == FMBEnmVideoRateCtlCbr){ + editedNumofChar = snprintf(destBuff, destBuffSize, "%dkbps", + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateCbr); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "Average:%dkbps, Peak:%dkbps", + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrAverage, + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrPeak); + } + + ASSERT_USR(editedNumofChar <= destBuffSize, "The size of the buffer is too small."); + + FMB_FUNC(FALSE); +} + +/** +* @brief The audio bitrate character string is edited. +* @param[out] destBuff Buffer where edited character string is stored. +* @param[in] destBuffSize The size of the buffer is specified. + The application terminates abnormally when the edit result exceeds this. +* @return None +* @note None +* @attention None +*/ +void ScrEditAudioBitrateString(char *destBuff, int destBuffSize) +{ + int editedNumofChar = 0; + enum FMBFuncModeEnum setmode; + enum FMBAudioFormatEnum afmt; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + afmt = gp_FmbProperty[setmode].audioFmt; + + switch (afmt) { + case FMBEnmAudioFmtLpcm: + if(setmode == FMBEnmFuncModeEnc){ + if(_screens.currentScreen[_screens.currentMode] == ScrEnmSetSubMenuEnc){ + editedNumofChar = snprintf(destBuff, destBuffSize, ", %dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "%dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + break; + } /* pgr0007 */ + case FMBEnmAudioFmtMpeg1l2: + case FMBEnmAudioFmtAc3: + if((_screens.currentScreen[_screens.currentMode] == ScrEnmSetSubMenuEnc) ){ + //If current-screen is SetSubMenuEnc + editedNumofChar = snprintf(destBuff, destBuffSize, ", %dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "%dkbps", + gp_FmbProperty[setmode].audioBitrateCbr[afmt]); + } + break; + case FMBEnmAudioFmtAac: + if((_screens.currentScreen[_screens.currentMode] == ScrEnmSetSubMenuEnc) ){ + //If current-screen is SetSubMenuEnc + editedNumofChar = snprintf(destBuff, destBuffSize, ", Average:%dkbps, Peak:%dkbps", + gp_FmbProperty[setmode].audioBitrateVbrAverage, + gp_FmbProperty[setmode].audioBitrateVbrPeak); + } + else{ + editedNumofChar = snprintf(destBuff, destBuffSize, "Average:%dkbps, Peak:%dkbps", + gp_FmbProperty[setmode].audioBitrateVbrAverage, + gp_FmbProperty[setmode].audioBitrateVbrPeak); + } + break; + default: + break; + } + + ASSERT_USR(editedNumofChar <= destBuffSize, "The size of the buffer is too small."); + + FMB_FUNC(FALSE); +} + + +/** +* @brief It returns to the previous screen mode. +* @param[in] scrMode Enumeration that identifies mode. +* @return None +* @note None +* @attention None +*/ +void ReturnToAnotherScreenMode(enum ScreenMode scrMode) +{ + FMB_FUNC(TRUE); + + _screens.isScreenModeChanged = FALSE; + _screens.currentMode = scrMode; + + fprintOut(stdout, "-------------------------------------------------------------------------------\n"); + fprintOut(stdout, "It returned to the former screen. \n"); + (void)SetScreenMode(_screens.inputMode[scrMode]); + SetInputEnabled(TRUE); + FMB_FUNC(FALSE); +} + + +/** +* @brief It changes to the previous screen. +* @param[in] scrEnm Enumeration that identifies screen. +* @return None +* @note None +* @attention None +*/ +void ChangePrevScreenTo(enum ScreenMode scrMode, enum ScreenEnum scrEnm) +{ + FMB_FUNC(TRUE); + + _screens.prevScreen[scrMode] = _screens.currentScreen[scrMode]; + _screens.currentScreen[scrMode] = scrEnm; + + FMB_FUNC(FALSE); +} + + +/** +* @brief The file character string is edited. +* @param[out] destBuff Buffer where edited character string is stored. +* @param[in] portenum port kind(input port : FMBEnmInPort / output port : FMBEnmOutPort) +* destBuffSize The size of the buffer is specified. + The application terminates abnormally when the edit result exceeds this. +* @return None +* @note None +* @attention None +*/ +void ScrEditFilePathString(enum FMBInOutPortEnum portenum, char *destBuff, int destBuffSize) +{ + int editedNumofChar = 0; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch (portenum){ + case FMBEnmOutPort: + if(gp_FmbProperty[setmode].outputPort == FMBEnmPortFile){ + editedNumofChar = snprintf(destBuff, destBuffSize, " %s", gp_FmbProperty[setmode].outputfile); + } + else{ + destBuff[0] = '\0'; + editedNumofChar = 1; + } + break; + case FMBEnmInPort: + if(gp_FmbProperty[setmode].inputPort == FMBEnmPortFile){ + editedNumofChar = snprintf(destBuff, destBuffSize, " %s", gp_FmbProperty[setmode].inputfile); + } + else{ + destBuff[0] = '\0'; + editedNumofChar = 1; + } + break; + default: + break; + } + + ASSERT_USR(editedNumofChar <= destBuffSize, "The size of the buffer is too small."); + + FMB_FUNC(FALSE); +} + +/** +* @brief The previous of the screen is returned. +* @param[in] None +* @return _screens.prevScreen Previous screen +* @note None +* @attention None +*/ +enum ScreenEnum GetPrevScreen(void) +{ + FMB_FUNC(TRUE); + FMB_FUNC(FALSE); + return _screens.prevScreen[_screens.currentMode]; +} + +/** +* @brief The file character string check. +* @param[in] destBuff Buffer where edited character string is stored. +* @param[in] len The size of the buffer is specified. +* @return FMBEnmNormal Normal end +* @return FMBEnmTooLongCharErr Too long char error +* @return FMBEnmInvalidValueErr Invalid value error +* @note None +* @attention None +*/ +enum FMBCharChkResultEnum ScrChkCodeStringBuff(char *destBuff, size_t len) +{ + size_t i; + int j; + + FMB_FUNC(TRUE); + + if (len > FMB_FILEPATH_MAX_CHAR){ + FMB_FUNC(FALSE); + return FMBEnmTooLongCharErr; + } + for(i = 0; i < len; i++){ + if ((destBuff[i] < FMB_FILEPATH_MIN_CODE_RANGE)|| + (destBuff[i] > FMB_FILEPATH_MAX_CODE_RANGE)){ + FMB_FUNC(FALSE); + return FMBEnmInvalidValueErr; + } + } + for(j= 0; j < FMB_CODE_INVALID_KIND; j++){ + if(strchr(destBuff, g_invalidCharaCode[j]) != NULL){ + FMB_FUNC(FALSE); + return FMBEnmInvalidValueErr; + } + } + + FMB_FUNC(FALSE); + return FMBEnmNormal; +} + +/** +* @brief The confirmation of setting data. +* @param[in] scrConfEnm Enumeration that identifies confirmation screen. +* @return TRUE Normal +* @return FALSE Error +* @note None +* @attention None +*/ +BOOL ScrConfSetData(enum ScreenConfTypeEnum scrConfEnm) +{ + enum FMBFuncModeEnum setmode; + enum FMBFileResultEnum ret_file_in = FMBEnmFileNormal; + enum FMBFileResultEnum ret_file_out = FMBEnmFileNormal; + char wk_msg[FMB_ERRINFO_MAX_CHAR]={0}; + char video_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char audio_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char inputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + char outputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + int errPacketCnt; + enum FMBCheckVideoFormatEnum checkVFmt; + enum FMBVideoFormatEnum videoFmt = FMBEnmVideoFmt1920x1080; + enum FMBVideoFrameEnum videoFrm = FMBEnmVideoFrm_5994i; + __off64_t fileSize; + __off64_t fileStartPos; + BOOL errVideoFormat = FALSE; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + + if((setmode == FMBEnmFuncModeEnc) ){ + + if(! FmbCalcVideoBitrateParam(&gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp, + gp_FmbProperty[gp_FmbComProperty->setMode].videoFrm, + gp_FmbProperty[gp_FmbComProperty->setMode].audioFmt)){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OVERFLOW; + + //(2)message information set + + ScrEditVideoBitrateString(video_bitrate, sizeof(video_bitrate)); + + ScrEditAudioBitrateString(audio_bitrate, sizeof(audio_bitrate)); + + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + //Encode mode + sprintf(wk_msg, _screenStrErrorInfoBitrateEnc, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + g_FmbNameVideoFmts[gp_FmbProperty[setmode].videoFmt], + g_FmbNameVideoRateCtls[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl], + video_bitrate, + gp_FmbProperty[setmode].videoBitrateProp.systemMuxRate, + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateParam.muxRate, + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt], + audio_bitrate); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OVERFLOW; + + FMB_FUNC(FALSE); + return FALSE; + } + } + + + if(((setmode == FMBEnmFuncModeDec) && (gp_FmbProperty[setmode].inputPort == FMBEnmPortFile)) ){ + + ret_file_in = FmbFileOpen( FMBEnmInFile, gp_FmbProperty[setmode].inputfile , &errPacketCnt); + + if(ret_file_in != FMBEnmFileNormal){ + switch (ret_file_in) { + case FMBEnmFileAccesFail: + case FMBEnmFileOtherFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_INFILEPATH; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INFILEPATH; + + break; + case FMBEnmFilePacketSizeFail: + sprintf(s_error_variable_factor, FMB_ERRSCR_FACT_INPACKET_SIZE, errPacketCnt); + //(1)factor set + g_ErrorScreenMessage.factor = s_error_variable_factor; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INPACKET_SIZE; + + break; + case FMBEnmFileExecutionFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_TERMINATING; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_EXECRETRY; + + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + //(2)message information set + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + sprintf(wk_msg, _screenStrErrorInfoFileIn, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath, + _fileResult[ret_file_in]); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + FMB_FUNC(FALSE); + return FALSE; + } + if(gp_FmbComProperty->tsFormat[FMBEnmInputTsPacket] != FMBEnmTsFormat188){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_INPACKET_SIZE2; + + //(2)message information set + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + sprintf(wk_msg, _screenStrErrorPaketSizeIn, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INPACKET_SIZE; + + FMB_FUNC(FALSE); + return FALSE; + } + if(scrConfEnm == ScrEnmConfDecNormalType || scrConfEnm == ScrEnmConfPauseStartType){ + fileStartPos = FmbGetStrmFilePos(FMBEnmStartPos); + fileSize = FmbGetFileSize(gp_FmbProperty[setmode].inputfile); + if(fileStartPos > fileSize){ + fileStartPos = 0; + FmbSetStrmFilePos(FMBEnmStartPos,fileStartPos); + } + } + } + + if((setmode == FMBEnmFuncModeDec) && (gp_FmbProperty[setmode].inputPort == FMBEnmPortStreamport)){ + if(scrConfEnm != ScrEnmConfDecNormalType){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_INPUTPORT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorInputPort, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_INPUTPORT; + + FMB_FUNC(FALSE); + return FALSE; + } + } + + if(((setmode == FMBEnmFuncModeEnc) && (gp_FmbProperty[setmode].outputPort == FMBEnmPortFile)) ){ + ret_file_out = FmbFileOpen( FMBEnmOutFile, gp_FmbProperty[setmode].outputfile , &errPacketCnt ); + + if(ret_file_out != FMBEnmFileNormal){ + switch (ret_file_out) { + case FMBEnmFileAccesFail: + case FMBEnmFileOtherFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OUTFILEPATH; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTFILEPATH; + + break; + case FMBEnmFilePacketSizeFail: + sprintf(s_error_variable_factor, FMB_ERRSCR_FACT_OUTPACKET_SIZE, errPacketCnt); + //(1)factor set + g_ErrorScreenMessage.factor = s_error_variable_factor; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTPACKET_SIZE; + + break; + case FMBEnmFileExecutionFail: + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_TERMINATING; + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_EXECRETRY; + + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + //(2)message information set + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + sprintf(wk_msg, _screenStrErrorInfoFileOut, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + _fileResult[ret_file_out]); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + FMB_FUNC(FALSE); + return FALSE; + } + if(gp_FmbComProperty->tsFormat[FMBEnmOutputTsPacket] != FMBEnmTsFormat188){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OUTPACKET_SIZE2; + + //(2)message information set + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + sprintf(wk_msg, _screenStrErrorPaketSizeOut, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath); + + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTPACKET_SIZE; + + FMB_FUNC(FALSE); + return FALSE; + } + } + if((setmode == FMBEnmFuncModeEnc) && (gp_FmbProperty[setmode].outputPort == FMBEnmPortStreamport)){ + if(scrConfEnm != ScrEnmConfEncodingType){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_OUTPUTPORT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorOutputPort, + _confScreen[scrConfEnm], + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_OUTPUTPORT; + + FMB_FUNC(FALSE); + return FALSE; + } + } + + if(setmode == FMBEnmFuncModeEnc){ + videoFmt = gp_FmbProperty[setmode].videoFmt; + videoFrm = gp_FmbProperty[setmode].videoFrm; + } + else{ + videoFmt = gp_FmbProperty[setmode].videoFmt; + videoFrm = gp_FmbProperty[setmode].videoFrm; + } + checkVFmt = g_VideoFormatCheckEnc[videoFmt][videoFrm]; + + if(checkVFmt == FMBEnmVFmtNG){ + errVideoFormat = TRUE; + } + + if(checkVFmt == FMBEnmVFmtLimitations){ + if(gp_FmbDevInfo->subSystemId == 0xFFFFFFFE){ + errVideoFormat = TRUE; + } + else if(gp_FmbDevInfo->firmLSIVer != 0x41){ + errVideoFormat = TRUE; + } + } + + if(errVideoFormat == TRUE){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_VIDEOFORMAT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorVideoFormat, + _confScreen[scrConfEnm], + g_FmbNameVideoFmts[videoFmt], + g_FmbNameVideoFrms[videoFrm], + g_FmbNameVideoSclEncs[gp_FmbProperty[setmode].videoScalerEnc]); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_VIDEOFORMAT; + + FMB_FUNC(FALSE); + return FALSE; + } + + if (g_AudioFormatCheck[gp_FmbProperty[gp_FmbComProperty->setMode].audioFmt] == FMBEnmAFmtBD){ + + if ( videoFrm == FMBEnmVideoFrm_60p || + videoFrm == FMBEnmVideoFrm_60i ){ + //(1)factor set + g_ErrorScreenMessage.factor = FMB_ERRSCR_FACT_VIDEOFORMAT; + + //(2)message information set + sprintf(wk_msg, _screenStrErrorVideoFormat, + _confScreen[scrConfEnm], + g_FmbNameVideoFmts[videoFmt], + g_FmbNameVideoFrms[videoFrm], + g_FmbNameVideoSclEncs[gp_FmbProperty[setmode].videoScalerEnc]); + strcpy(g_ErrorScreenMessage.information, wk_msg); + + //(3)reaction set + g_ErrorScreenMessage.reaction = FMB_ERRSCR_REACT_VIDEOFORMAT; + + FMB_FUNC(FALSE); + return FALSE; + + } + } + + FMB_FUNC(FALSE); + return TRUE; +} + +static enum FMBRequestEnum ClrAllLastRequest(void) +{ + enum FMBRequestEnum req = FMBEnmReqNothing; + enum FMBDeviceNumEnum devNum, devNum_old; + + FMB_FUNC(TRUE); + + devNum_old = FmbGetCurDeviceNum(); + for (devNum = FmbSetFirstDev(); devNum != FMBEnmDevice_NONE; devNum = FmbSetNextDev()) { + if (gp_FmbComProperty->lastRequest != FMBEnmReqNothing) { + ASSERT_USR(req == FMBEnmReqNothing || req == gp_FmbComProperty->lastRequest, "Request ?"); + req = gp_FmbComProperty->lastRequest; + } + + gp_FmbComProperty->lastRequest = FMBEnmReqNothing; + } + FmbSetCurDeviceNum(devNum_old); + ASSERT_USR(req != FMBEnmReqNothing, "Request is nothing."); + + FMB_FUNC(FALSE); + + return req; +} diff --git a/fmb_player_apl/src/scr/ScreenError.c b/fmb_player_apl/src/scr/ScreenError.c new file mode 100644 index 0000000..6c94de8 --- /dev/null +++ b/fmb_player_apl/src/scr/ScreenError.c @@ -0,0 +1,104 @@ +/** +* @brief The function of the Error screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Error -> Main menu ]]]\n\ + ~~~~~->Enter\n\ +Factor:%s\n\ +Error information:\n\ +%s\n\ +Reaction:%s\n\ +"; + +static const char validChars[] = "\n"; + + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +///Error screen message +extern struct ErrorScreenMessage g_ErrorScreenMessage; + + +/** +* @brief Initial screen of the error. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitScreenError(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + + FMB_FUNC(TRUE); + + //The screen is displayed. + printOut(_screenStr, + g_ErrorScreenMessage.factor, + g_ErrorScreenMessage.information, + g_ErrorScreenMessage.reaction); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SelMultiDev.c b/fmb_player_apl/src/scr/SelMultiDev.c new file mode 100644 index 0000000..61cf0d3 --- /dev/null +++ b/fmb_player_apl/src/scr/SelMultiDev.c @@ -0,0 +1,190 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + + +static const char *_screenStrTitle = "\ +< Device list >\n\ + 'B'<-~~~~~~~~\n\ +Select following number. (* is current setting)\n\ +\n\ +"; +static const char *_screenStrList = "\ + %d %s /dev/h55fmb%d\n\ +"; + +static const char *_screenCheck_Y = "<*>"; +static const char *_screenCheck_N = "< >"; + + +static const char *_screenStrEnd = "\ +\n\ + o Ok\n\ +\n\ +"; + + +static const char validChars[] = "12345678BbOo"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSelMultiDev(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + //scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + int codecNum; + + FMB_FUNC(TRUE); + + printOut(_screenStrTitle); + for (codecNum=0; codecNum<FmbGetDeviceTotal(); codecNum++) { + char const* check; + + if(FmbIsDevUse(codecNum)) { + check = _screenCheck_Y; + } + else { + check = _screenCheck_N; + } + + printOut(_screenStrList, codecNum +1, check, codecNum); + } + printOut(_screenStrEnd); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + int devNum; + int devCount = 0; + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + devNum = InputCharacterCode - '1'; + if ( (0 <= devNum) && (devNum < FmbGetDeviceTotal())) { + if(FmbIsDevUse(devNum)) { + FmbDisableDevUse(devNum); + } + else { + FmbEnableDevUse(devNum); + } + } + else { + //ASSERT_USR(FALSE, "Invalid character code."); + } + OnShow(); + break; + case 'o': + case 'O': + for (devNum=0; devNum<FmbGetDeviceTotal(); devNum++) { + if(FmbIsDevUse(devNum)) { + devCount++; + } + } + + if (0 < devCount) { + FmbEnableDeviceSel(); + ChangeScreenTo(GetPrevScreen()); + } + else { + OnShow(); + } + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SelRecordDev.c b/fmb_player_apl/src/scr/SelRecordDev.c new file mode 100644 index 0000000..6847287 --- /dev/null +++ b/fmb_player_apl/src/scr/SelRecordDev.c @@ -0,0 +1,228 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + + +static const char *_screenStrTitle = "\ +< Device list >\n\ + 'B'<-~~~~~~~~\n\ +Select following number. (* is current setting)\n\ +\n\ +"; +static const char *_screenStrList = "\ + %d %s /dev/h55fmb%d %s : %s\n\ +"; + +static const char *_screenCheck_Y = "<*>"; +static const char *_screenCheck_N = "< >"; +static const char *_screenLink_Y = "link "; +static const char *_screenLink_N = "no link "; +static const char *_screenDisable = "disable "; + + +static const char *_screenStrEnd = "\ +\n\ + o Ok\n\ +\n\ +"; + + +static const char validChars[] = "12345678BbOo"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSelRecordDev(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + //scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + int codecNum; + int codecNumPerBorad; + + FMB_FUNC(TRUE); + + printOut(_screenStrTitle); + codecNumPerBorad = FmbGetDeviceTotal()/FmbGetBoardTotal(); + ASSERT_USR(codecNumPerBorad*FmbGetBoardTotal() == FmbGetDeviceTotal(), "???"); + + for (codecNum=0; codecNum<FmbGetDeviceTotal(); codecNum++) { + struct CodecIO codecIOInfo; + enum FMBDeviceNumEnum devNum_old; + char const* check; + char const* link; +
+ FmbSetCurMmuxDevNum(codecNum/codecNumPerBorad); + + MmuxGetCodecStatus(FmbGetCurMmuxHd(), codecNum%codecNumPerBorad, &codecIOInfo); + + if (codecIOInfo.fgInputConncet) { + devNum_old = FmbGetCurDeviceNum(); + FmbSetCurDeviceNum(codecNum); + FmbSetVideoFormat(FmbRsltnMmux2Fmb(codecIOInfo.inResolution), FMBEnmFuncModeEnc); + FmbSetCurDeviceNum(devNum_old); + + if (codecIOInfo.fgInputDisable) { + FmbDisableDevUse(codecNum); + link = _screenDisable; + } + else { + link = _screenLink_Y; + } + } + else { + FmbDisableDevUse(codecNum); + link = _screenLink_N; + } + if (FmbIsDevUse(codecNum)) { + check = _screenCheck_Y; + } + else { + check = _screenCheck_N; + } + printOut(_screenStrList, codecNum +1, check, codecNum, + link, MmuxGetResolutionStr(codecIOInfo.inResolution)); + } + printOut(_screenStrEnd); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + int codecNumPerBorad; + + FMB_FUNC(TRUE); + int devNum; + int devCount = 0; + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + codecNumPerBorad = FmbGetDeviceTotal()/FmbGetBoardTotal(); + devNum = InputCharacterCode - '1'; + if ( (0 <= devNum) && (devNum < FmbGetDeviceTotal())) { + FmbSetCurMmuxDevNum(devNum/codecNumPerBorad); + if (MmuxIsCodecSrcConnect(FmbGetCurMmuxHd(), devNum%codecNumPerBorad) \
+ && !MmuxIsCodecSrcDisable(FmbGetCurMmuxHd(), devNum%codecNumPerBorad)) { + if (FmbIsDevUse(devNum)) { + FmbDisableDevUse(devNum); + } + else { + FmbEnableDevUse(devNum); + } + } + } + else { + //ASSERT_USR(FALSE, "Invalid character code."); + } + OnShow(); + break; + case 'o': + case 'O': + for (devNum=0; devNum<FmbGetDeviceTotal(); devNum++) { + if (FmbIsDevUse(devNum)) { + devCount++; + } + } + + if (0 < devCount) { + FmbEnableDeviceSel(); + ChangeScreenTo(GetPrevScreen()); + } + else { + OnShow(); + } + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SelSingleDev.c b/fmb_player_apl/src/scr/SelSingleDev.c new file mode 100644 index 0000000..62a2428 --- /dev/null +++ b/fmb_player_apl/src/scr/SelSingleDev.c @@ -0,0 +1,152 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + + +static const char *_screenStr1 = "\ +< Device list >\n\ +Select following number.\n\ +\n\ +"; +static const char *_screenStr2 = "\ + %d /dev/h55fmb%d\n\ +"; +static const char *_screenStr3 = "\ +\n\ +"; + +static const char validChars[] = "12345678Bb"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSelSingleDev(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + //scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + int i; + + FMB_FUNC(TRUE); + + printOut(_screenStr1); + for (i=0; i<FmbGetDeviceTotal(); i++) { + printOut(_screenStr2, i+1, i); + } + printOut(_screenStr3); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + int devNum; + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + devNum = InputCharacterCode - '1'; + if ( (0 <= devNum) && (devNum < FmbGetDeviceTotal())) { + FmbSetCurDeviceNum(devNum); + FmbEnableDeviceSel(); + } + else { + //ASSERT_USR(FALSE, "Invalid character code."); + } + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + + ChangeScreenTo(GetPrevScreen()); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetAudioBitrateAacEnc.c b/fmb_player_apl/src/scr/SetAudioBitrateAacEnc.c new file mode 100644 index 0000000..aa37932 --- /dev/null +++ b/fmb_player_apl/src/scr/SetAudioBitrateAacEnc.c @@ -0,0 +1,218 @@ +/** +* @brief The function of the audio_bitrate(AAC) setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Audio format -> Audio bitrate ]]]\n\ + 'B'<-~~~~~~~~~~~~~->Enter\n\ +Input bitrate in kbps. \n\ +"; + +static const char *_screenStrCurrentVal[] = { + "Current average bitrate is %dkbps.\n", + "Current peak bitrate is %dkbps.\n" +}; + +static const char *_screenStrPrompts[] = { + "Average ", + "Peak " +}; + +//What bitrate you input is shown now. +static enum ScreenAudioBitrateVbrEnum _currentBitrateType; + +//The prompt is displayed. +static void Prompt(enum ScreenAudioBitrateVbrEnum bitrateType); + +static struct Screen *_me; + +static int _tempBitrates[2]; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the audio_bitrate(AAC) of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetAudioBitrateAacEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + _me = scr; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + setmode = gp_FmbComProperty->setMode; + + _currentBitrateType = ScrEnmAudioBitrateVbrAverage; + + printOut(_screenStr); + + _tempBitrates[ScrEnmAudioBitrateVbrAverage] = gp_FmbProperty[setmode].audioBitrateVbrAverage; + _tempBitrates[ScrEnmAudioBitrateVbrPeak] = gp_FmbProperty[setmode].audioBitrateVbrPeak; + + Prompt(_currentBitrateType); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + int val; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + //The input value that those who operated it intended is requested. + switch(*lineString){ + case '\0': + val = _tempBitrates[_currentBitrateType]; + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + if(_currentBitrateType == ScrEnmAudioBitrateVbrAverage){ + printOut("The input bitrate value is canceled. \n"); + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(ScrEnmSetAudioFormatEnc); + } + else{ + _currentBitrateType --; + Prompt(_currentBitrateType); + } + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + val = StrToUnsignedInt(lineString); + if(val < FMB_MIN_AUDIO_BITRATE_VBR){ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + if(val > FMB_MAX_AUDIO_BITRATE_VBR){ + MsgDispInputErr(FMB_INPUTERR_TOO_LARGE_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + + break; + } + + //The input value is reflected according to a present bitrate type. + switch(_currentBitrateType){ + case ScrEnmAudioBitrateVbrAverage: + _tempBitrates[_currentBitrateType] = val; + _currentBitrateType ++; + Prompt(_currentBitrateType); + break; + case ScrEnmAudioBitrateVbrPeak: + if(_tempBitrates[ScrEnmAudioBitrateVbrAverage] > val){ + MsgDispInputErr(FMB_INPUTERR_TOO_SMALL_VALUE); + break; + } + _tempBitrates[_currentBitrateType] = val; + + gp_FmbProperty[setmode].audioBitrateVbrAverage = _tempBitrates[ScrEnmAudioBitrateVbrAverage]; + gp_FmbProperty[setmode].audioBitrateVbrPeak = _tempBitrates[ScrEnmAudioBitrateVbrPeak]; + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(ScrEnmSetSubMenuEnc); + break; + default: + ASSERT_USR(FALSE, "Invalid bitrate type."); + break; + } + + LogScr("TempVbrAverage\t%d\tTempVbrPeak\t%d\tval\t%d", + _tempBitrates[ScrEnmAudioBitrateVbrAverage], + _tempBitrates[ScrEnmAudioBitrateVbrPeak], + val); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The prompt is displayed. +* @param[in] ScreenAudioBitrateVbrEnum bitrateType +* @return None +* @note None +* @attention None +*/ +static void Prompt(enum ScreenAudioBitrateVbrEnum bitrateType) +{ + FMB_FUNC(TRUE); + + printOut(_screenStrCurrentVal[bitrateType], _tempBitrates[bitrateType]); + _me->prompt = _screenStrPrompts[bitrateType]; + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); +} + diff --git a/fmb_player_apl/src/scr/SetAudioBitrateAc3Enc.c b/fmb_player_apl/src/scr/SetAudioBitrateAc3Enc.c new file mode 100644 index 0000000..eb9d5ea --- /dev/null +++ b/fmb_player_apl/src/scr/SetAudioBitrateAc3Enc.c @@ -0,0 +1,155 @@ +/** +* @brief The function of the audio_bitrate(AC3) setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Audio format -> Audio bitrate ]]]\n\ + 'B'<-~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ +"; + +static int _bitrates[] = { + 128, 160, 192, 224, 256, 320, 384, 448 +}; +static const char validChars[] = "12345678bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the audio_bitrate(AC3) of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetAudioBitrateAc3Enc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + int i; + char selectedMark; + enum FMBFuncModeEnum setmode; + enum FMBAudioFormatEnum afmt; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + afmt = gp_FmbProperty[setmode].audioFmt; + + printOut(_screenStr); + + for(i = 0; i < ArraySizeOf(_bitrates); i++){ + if(_bitrates[i] == gp_FmbProperty[setmode].audioBitrateCbr[afmt]){ + selectedMark = '*'; + } + else{ + selectedMark = ' '; + } + printOut(" %x %c %3d kbps\n", + i +1, + selectedMark, + _bitrates[i]); + } + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + unsigned int i; + char str[2]; + int numofConv; + enum FMBFuncModeEnum setmode; + enum FMBAudioFormatEnum afmt; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + afmt = gp_FmbProperty[setmode].audioFmt; + + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + str[0] = InputCharacterCode; + str[1] = '\0'; + numofConv = sscanf(str, "%x", &i); + ASSERT_USR(numofConv == 1, "hexstring -> value is failure."); + i--; + ASSERT_USR(i < ArraySizeOf(_bitrates), "Buffer over run."); + gp_FmbProperty[setmode].audioBitrateCbr[afmt] = _bitrates[i]; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetAudioFormatEnc); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetAudioBitrateLpcmEnc.c b/fmb_player_apl/src/scr/SetAudioBitrateLpcmEnc.c new file mode 100644 index 0000000..f578fc7 --- /dev/null +++ b/fmb_player_apl/src/scr/SetAudioBitrateLpcmEnc.c @@ -0,0 +1,123 @@ +/** +* @brief The function of the audio_bitrate(MPEG1L2) setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Audio format -> Audio bitrate ]]]\n\ + 'B'<-~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c 1536 kbps (16bit 48KHz stereo) \n\ +"; + +static const char validChars[] = "1bB\n"; + +static int _bitrates[] = { + 1536 +}; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the audio_bitrate(LPCM) of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetAudioBitrateLpcmEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].audioLpcm][FMBEnmAudioLpcm16stereo]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].audioLpcm = InputCharacterCode - '1'; + + gp_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtLpcm] = _bitrates[gp_FmbProperty[setmode].audioLpcm]; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetAudioFormatEnc); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetAudioBitrateMpeg1l2Enc.c b/fmb_player_apl/src/scr/SetAudioBitrateMpeg1l2Enc.c new file mode 100644 index 0000000..db03f43 --- /dev/null +++ b/fmb_player_apl/src/scr/SetAudioBitrateMpeg1l2Enc.c @@ -0,0 +1,142 @@ +/** +* @brief The function of the audio_bitrate(MPEG1L2) setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Audio format -> Audio bitrate ]]]\n\ + 'B'<-~~~~~~~~~~~~~->Enter\n\ +Select following character. (* is current setting)\n\ +"; + +static int _bitrates[] = { + 256 +}; +static const char validChars[] = "1\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the audio_bitrate(MPEG1L2) of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetAudioBitrateMpeg1l2Enc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + int i; + char selectedMark; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr); + + for(i = 0; i < ArraySizeOf(_bitrates); i++){ + if(_bitrates[i] == gp_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtMpeg1l2]){ + selectedMark = '*'; + } + else{ + selectedMark = ' '; + } + printOut(" %x %c %3d kbps\n", + i +1, + selectedMark, + _bitrates[i]); + } + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + unsigned int i; + char str[2]; + int numofConv; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + str[0] = InputCharacterCode; + str[1] = '\0'; + numofConv = sscanf(str, "%x", &i); + ASSERT_USR(numofConv == 1, "hexstring -> value is failure."); + i--; + ASSERT_USR(i < ArraySizeOf(_bitrates), "Buffer over run."); + gp_FmbProperty[setmode].audioBitrateCbr[FMBEnmAudioFmtMpeg1l2] = _bitrates[i]; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetAudioFormatEnc); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetAudioFormatDec.c b/fmb_player_apl/src/scr/SetAudioFormatDec.c new file mode 100644 index 0000000..3f59a5b --- /dev/null +++ b/fmb_player_apl/src/scr/SetAudioFormatDec.c @@ -0,0 +1,160 @@ +/** +* @brief The function of the audio format setting screen of the decoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decode settings - Sub menu -> Audio format ]]]\n\ + 'B'<-~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c MPEG1L2 %s\n\ + 2 %c AC3 %s\n\ + 3 %c AAC %s\n\ + 4 %c LPCM %s\n\ +"; + +static char unsupportStr[FMBEnmAudioFmtMax][AUDIO_FMT_UNSUPPORTED_STR_LEN] ={ + "" , //< FMBEnmAudioFmtMpeg1l2 + "" , //< FMBEnmAudioFmtAc3 + "" , //< FMBEnmAudioFmtAac + "" , //< FMBEnmAudioFmtLpcm +}; + +static char validChars[AUDIO_FMT_VALIDCHAR_LEN] = "1234bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the audio format of the decoding setting. +* @brief Initilize screen +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetAudioFormatDec(struct Screen *scr) +{ + int i; + int vCnt=0; + + FMB_FUNC(TRUE); + + for( i=0 ; i<FMBEnmAudioFmtMax ; i++ ){ + if(g_AudioFormatCheck[i]==FMBEnmAFmtNG){ + strcpy(unsupportStr[i],AUDIO_FMT_UNSUPPORTED_STR); + }else{ + strcpy(unsupportStr[i],""); + validChars[vCnt]= i + '1'; + vCnt++; + } + } + validChars[vCnt]='b'; + validChars[vCnt+1]='B'; + validChars[vCnt+2]='\n'; + validChars[vCnt+3]='\0'; + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].audioFmt][FMBEnmAudioFmtMpeg1l2],unsupportStr[FMBEnmAudioFmtMpeg1l2], + g_selectMarks[gp_FmbProperty[setmode].audioFmt][FMBEnmAudioFmtAc3],unsupportStr[FMBEnmAudioFmtAc3], + g_selectMarks[gp_FmbProperty[setmode].audioFmt][FMBEnmAudioFmtAac],unsupportStr[FMBEnmAudioFmtAac], + g_selectMarks[gp_FmbProperty[setmode].audioFmt][FMBEnmAudioFmtLpcm],unsupportStr[FMBEnmAudioFmtLpcm]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtMpeg1l2; + break; + case '2': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtAc3; + break; + case '3': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtAac; + break; + case '4': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtLpcm; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuDec); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + gp_FmbProperty[setmode].audioFmtReload = g_ReloadAudio[gp_FmbProperty[setmode].audioFmt]; + ChangeScreenTo(ScrEnmSetSubMenuDec); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetAudioFormatEnc.c b/fmb_player_apl/src/scr/SetAudioFormatEnc.c new file mode 100644 index 0000000..7df2f6a --- /dev/null +++ b/fmb_player_apl/src/scr/SetAudioFormatEnc.c @@ -0,0 +1,169 @@ +/** +* @brief The function of the audio format setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Audio format -> Audio bitrate ]]]\n\ + 'B'<-~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c MPEG1L2 %s\n\ +"; + +static char unsupportStr[FMBEnmAudioFmtMax][AUDIO_FMT_UNSUPPORTED_STR_LEN] ={ + "" , //< FMBEnmAudioFmtMpeg1l2 +}; + +static char validChars[AUDIO_FMT_VALIDCHAR_LEN] = "1bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the audio format of the encoding setting. +* @brief Initilize screen +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetAudioFormatEnc(struct Screen *scr) +{ + int i; + int vCnt=0; + + FMB_FUNC(TRUE); + + for( i=0 ; i<FMBEnmAudioFmtMax ; i++ ){ + if(g_AudioFormatCheck[i]==FMBEnmAFmtNG){ + strcpy(unsupportStr[i],AUDIO_FMT_UNSUPPORTED_STR); + }else{ + strcpy(unsupportStr[i],""); + validChars[vCnt]= i + '1'; + vCnt++; + } + } + validChars[vCnt]='b'; + validChars[vCnt+1]='B'; + validChars[vCnt+2]='\n'; + validChars[vCnt+3]='\0'; + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].audioFmt][FMBEnmAudioFmtMpeg1l2],unsupportStr[FMBEnmAudioFmtMpeg1l2]); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtMpeg1l2; + break; + case '2': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtAc3; + break; + case '3': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtAac; + break; + case '4': + gp_FmbProperty[setmode].audioFmt = FMBEnmAudioFmtLpcm; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + gp_FmbProperty[setmode].audioFmtReload = g_ReloadAudio[gp_FmbProperty[setmode].audioFmt]; + + switch(gp_FmbProperty[setmode].audioFmt){ + case FMBEnmAudioFmtMpeg1l2: + nextScr = ScrEnmSetAudioBitrateMpeg1l2Enc; + break; + case FMBEnmAudioFmtAc3: + nextScr = ScrEnmSetAudioBitrateAc3Enc; + break; + case FMBEnmAudioFmtAac: + nextScr = ScrEnmSetAudioBitrateAacEnc; + break; + case FMBEnmAudioFmtLpcm: + nextScr = ScrEnmSetAudioBitrateLpcmEnc; + break; + default: + ASSERT_USR(FALSE, "Invalid audio format."); + break; + } + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetConfigCom.c b/fmb_player_apl/src/scr/SetConfigCom.c new file mode 100644 index 0000000..c95004c --- /dev/null +++ b/fmb_player_apl/src/scr/SetConfigCom.c @@ -0,0 +1,151 @@ +/** +* @brief The function of the file setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Common settings - Sub menu -> Config File ]]]\n\ + 'B'<-~~~~~~~~~~~->Enter\n\ +Input filepath of config file.\n\ +Current filepath is %s.\n\ +Press <Enter> key to save.\n\ +"; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the config file setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetConfigCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + + FMB_FUNC(TRUE); + + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + fprintOut(stdout, _screenStr, + gp_FmbComProperty->configPath); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + size_t len; + enum FMBCharChkResultEnum result; + char filePath[FMB_FIRMPATH_MAX_CHAR]; + + FMB_FUNC(TRUE); + + switch(*lineString){ + case '\0': + strcpy(filePath, gp_FmbComProperty->configPath); + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + len = strlen(lineString); + result = ScrChkCodeStringBuff(lineString, len); + switch(result){ + case FMBEnmNormal: + strcpy(filePath, lineString); + break; + case FMBEnmTooLongCharErr: + MsgDispInputErr(FMB_INPUTERR_TOO_LONG_CHAR); + FMB_FUNC(FALSE); + return TRUE; + break; + case FMBEnmInvalidValueErr: + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + break; + } + + if(!FmbConfigFileOpen(filePath,"w")){ + MsgDispInputErr(FMB_INPUTERR_FILE_PATH); + FMB_FUNC(FALSE); + return TRUE; + } + strcpy(gp_FmbComProperty->configPath, filePath); + + FmbConfigFileSave(); + + FmbConfigFileClose(); + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(ScrEnmMainMenu); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetFile.c b/fmb_player_apl/src/scr/SetFile.c new file mode 100644 index 0000000..0d38f68 --- /dev/null +++ b/fmb_player_apl/src/scr/SetFile.c @@ -0,0 +1,197 @@ +/** +* @brief The function of the file setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr[2] ={"\ +[[[ %s -> File ]]]\n\ + %s ~~~~->Enter\n\ +Input filepath of stream.\n\ +Current filepath is %s.\n\ +" , +"[[[ %s -> File ]]]\n\ + %s ~~~~->Enter\n\ +Input filepath of stream.\n\ +Current filepath is %s.\n\ +" +}; + +static const char *_screenTitle[2][2] = { + {"Encode settings - Sub menu -> Output port", + " "}, + {"Decode settings - Sub menu -> Input port", + " "} +}; + + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the file setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetFile(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = (char*)_screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + enum ScreenSetFileTypeEnum type = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch(GetPrevScreen()){ + case ScrEnmSetOutputPortEnc: + ASSERT_USR(setmode == FMBEnmFuncModeEnc, "Function mode is illegal."); + type = ScrEnmSetFileOutputEnc; + break; + case ScrEnmSetInputPortDec: + case ScrEnmSetFileStartPos: + ASSERT_USR(setmode == FMBEnmFuncModeDec, "Function mode is illegal."); + type = ScrEnmSetFileInputDec; + break; + default: + ASSERT_USR(FALSE, "Invalid prevScreen"); + break; + } + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + switch(type){ + case ScrEnmSetFileOutputEnc: + fprintOut(stdout, _screenStr[0], + _screenTitle[type][0], _screenTitle[type][1], gp_FmbProperty[setmode].outputfile); + break; + case ScrEnmSetFileInputDec: + fprintOut(stdout, _screenStr[1], + _screenTitle[type][0], _screenTitle[type][1], gp_FmbProperty[setmode].inputfile); + break; + default: + break; + } + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + enum FMBFuncModeEnum setmode; + size_t len; + enum FMBCharChkResultEnum result; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch(*lineString){ + case '\0': + break; + default: + len = strlen(lineString); + result = ScrChkCodeStringBuff(lineString, len); + switch(result){ + case FMBEnmNormal: + switch(GetPrevScreen()){ + case ScrEnmSetOutputPortEnc: + strcpy(gp_FmbProperty[setmode].outputfile, lineString); + break; + case ScrEnmSetInputPortDec: + case ScrEnmSetFileStartPos: + if(strcmp(gp_FmbProperty[setmode].inputfile, lineString)){ + FmbSetStrmFilePos(FMBEnmStartPos,0); + } + strcpy(gp_FmbProperty[setmode].inputfile, lineString); + break; + default: + ASSERT_USR(FALSE, "Invalid prevScreen"); + break; + } + break; + case FMBEnmTooLongCharErr: + MsgDispInputErr(FMB_INPUTERR_TOO_LONG_CHAR); + FMB_FUNC(FALSE); + return TRUE; + break; + case FMBEnmInvalidValueErr: + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + break; + } + + switch(setmode){ + case FMBEnmFuncModeEnc: + nextScr = ScrEnmSetSubMenuEnc; + break; + case FMBEnmFuncModeDec: + nextScr = ScrEnmSetFileStartPos; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetFileStartPos.c b/fmb_player_apl/src/scr/SetFileStartPos.c new file mode 100644 index 0000000..4462b95 --- /dev/null +++ b/fmb_player_apl/src/scr/SetFileStartPos.c @@ -0,0 +1,152 @@ +/** +* @brief The function of the file setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr ={ +"[[[ Decode settings - Sub menu -> Input port -> File -> Start position ]]]\n\ + 'B'<-~~~~~~~~~~~~~~->Enter\n\ +Input start position in byte.\n\ +Current value is %llu (Max.%llu)\n\ +" +}; + + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the file start position setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetFileStartPos(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + __off64_t fileSize; + __off64_t fileStartPos; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + fileStartPos = FmbGetStrmFilePos(FMBEnmStartPos); + fileSize = FmbGetFileSize(gp_FmbProperty[setmode].inputfile); + + if(fileStartPos > fileSize){ + fileStartPos = 0; + FmbSetStrmFilePos(FMBEnmStartPos,fileStartPos); + } + + fprintOut(stdout, _screenStr, + (unsigned long long)fileStartPos, + (unsigned long long)fileSize); + + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + __off64_t position=0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch(*lineString){ + case '\0': + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + + default: + position = StrToOff64(lineString); + if(position < 0){ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + if(position > FmbGetFileSize(gp_FmbProperty[setmode].inputfile)){ + MsgDispInputErr(FMB_INPUTERR_TOO_LARGE_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + FmbSetStrmFilePos(FMBEnmStartPos,position); + + break; + } + + nextScr = ScrEnmSetSubMenuDec; + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetFirmCom.c b/fmb_player_apl/src/scr/SetFirmCom.c new file mode 100644 index 0000000..0a3c10e --- /dev/null +++ b/fmb_player_apl/src/scr/SetFirmCom.c @@ -0,0 +1,143 @@ +/** +* @brief The function of the file setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Common settings - Sub menu -> Firm File ]]]\n\ + 'B'<-~~~~~~~~~->Enter\n\ +Input filepath of firm.\n\ +Current filepath is %s.\n\ +"; + + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + + +/** +* @brief Initial screen of the file setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetFirmCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + + FMB_FUNC(TRUE); + + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + fprintOut(stdout, _screenStr, + gp_FmbInfo->firmPath_A); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + size_t len; + enum FMBCharChkResultEnum result; + + FMB_FUNC(TRUE); + + switch(*lineString){ + case '\0': + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + len = strlen(lineString); + result = ScrChkCodeStringBuff(lineString, len); + switch(result){ + case FMBEnmNormal: + if(!FmbIsExistenceFile(lineString)){ + MsgDispInputErr(FMB_INPUTERR_FILE_NOTHING); + FMB_FUNC(FALSE); + return TRUE; + } + strcpy(gp_FmbInfo->firmPath_A, lineString); + break; + case FMBEnmTooLongCharErr: + MsgDispInputErr(FMB_INPUTERR_TOO_LONG_CHAR); + FMB_FUNC(FALSE); + return TRUE; + break; + case FMBEnmInvalidValueErr: + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid return value."); + break; + } + break; + } + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(ScrEnmSetSubMenuCom); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetInOutPidCom.c b/fmb_player_apl/src/scr/SetInOutPidCom.c new file mode 100644 index 0000000..5268ddb --- /dev/null +++ b/fmb_player_apl/src/scr/SetInOutPidCom.c @@ -0,0 +1,149 @@ +/** +* @brief The function of the set PID of Common setting is defined. +* @since +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Common settings - Sub menu -> PID type -> %s ]]]\n\ + 'B'<-%s->Enter\n\ +Current %s is 0x%04x.\n\ +"; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + +///<Current Pid Setting name and character +const char *FmbNamePid[FMBEnmPidMax][3] = { + {"Input Video-PID" , "~~~~~~~~~~~~~~~" }, + {"Input Audio-PID" , "~~~~~~~~~~~~~~~" }, + {"Input PMT-PID" , "~~~~~~~~~~~~~" }, + {"Input SIT-PID" , "~~~~~~~~~~~~~" }, + {"Input PCR-PID" , "~~~~~~~~~~~~~" }, + {"Output Video-PID" , "~~~~~~~~~~~~~~~~" }, + {"Output Audio-PID" , "~~~~~~~~~~~~~~~~" }, + {"Output PMT-PID" , "~~~~~~~~~~~~~~" }, + {"Output SIT-PID" , "~~~~~~~~~~~~~~" }, + {"Output PCR-PID" , "~~~~~~~~~~~~~~" }, +}; + +/** +* @brief Initial screen of the set PID of the Common setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetInOutPidCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ + +static BOOL OnShow(void) +{ + + int val; + + FMB_FUNC(TRUE); + + SetScreenMode(ScrEnmModeKeybuffer); + + val = gp_FmbComProperty->PidValue[gp_FmbComProperty->PidType]; + + printOut(_screenStr, + FmbNamePid[gp_FmbComProperty->PidType][0], + FmbNamePid[gp_FmbComProperty->PidType][1], + FmbNamePid[gp_FmbComProperty->PidType][0], + val); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ + +static BOOL OnLineInput(char *lineString) +{ + int val; + + FMB_FUNC(TRUE); + + + switch(*lineString){ + case '\0': + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(ScrEnmSetPidTypeCom); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + val = StrToUnsignedInt(lineString); + if(val < 0){ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + if(val > FMB_MAX_PID_VALUE){ + MsgDispInputErr(FMB_INPUTERR_TOO_LARGE_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + gp_FmbComProperty->PidValue[gp_FmbComProperty->PidType] = val; + + break; + } + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(ScrEnmSetPidTypeCom); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetInputPortDec.c b/fmb_player_apl/src/scr/SetInputPortDec.c new file mode 100644 index 0000000..cfce15e --- /dev/null +++ b/fmb_player_apl/src/scr/SetInputPortDec.c @@ -0,0 +1,128 @@ +/** +* @brief The function of the input Port setting screen of the decoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decode settings - Sub menu -> Input port ]]]\n\ + 'B'<-~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c File\n\ +"; +static const char validChars[] = "12bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the input Port of the decoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetInputPortDec(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + fprintOut(stdout, _screenStr, + g_selectMarks[gp_FmbProperty[setmode].inputPort][FMBEnmPortFile]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].inputPort = FMBEnmPortFile; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuDec); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + switch(gp_FmbProperty[setmode].inputPort){ + case FMBEnmPortFile: + nextScr = ScrEnmSetFile; + break; + case FMBEnmPortStreamport: + nextScr = ScrEnmSetSubMenuDec; + break; + default: + ASSERT_USR(FALSE, "Invalid input port."); + break; + } + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetOption.c b/fmb_player_apl/src/scr/SetOption.c new file mode 100644 index 0000000..5fe980b --- /dev/null +++ b/fmb_player_apl/src/scr/SetOption.c @@ -0,0 +1,206 @@ +/** +* @brief The function of the screen where the option is set is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Option settings ]]]\n\ +It returns to the former screen when 'Enter' is pressed. \n\ +Select following character. (* is current setting)\n\ + 1 %c Function Trace\n\ + 2 %c MB86 Receive Trace\n\ + 3 %c MB86 Receive Dump Trace\n\ + 4 %c Scenario Trace\n\ + 5 %c MB86 Log\n\ + 6 %c Screen Log\n\ +\n\ + 7 %c Message Filter On\n\ + 8 %c if AV_SYC = 1 then Exit Application\n\ + 9 %c MB86 Event Log\n\ + a %c Screen Event Log\n\ + b %c MB86 Command Log\n\ + c %c if packet size unmatch occurred then Exit Application\n\ + d %c All messages are not received. \n\ +"; + + +static const char validChars[] = "123456789aAbBcCdDhHmMrR\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +//Event function when fmb-request is complete. +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req); + +/** +* @brief Initial screen of the option setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetOption(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + scr->OnFmbRequestCompleteFunc = OnFmbRequestComplete; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + (void)SetScreenMode(ScrEnmMode1key); + + printOut(_screenStr, + g_selectMarks[0][!g_dbg.isFuncTrace], + g_selectMarks[0][!g_dbg.isRecvTrace], + g_selectMarks[0][!g_dbg.isRecvDumpTrace], + g_selectMarks[0][!g_dbg.isSceTrace], + g_selectMarks[0][!g_dbg.isFmbLog], + g_selectMarks[0][!g_dbg.isScrLog], + g_selectMarks[0][!g_dbg.isMessageFilterOn], + g_selectMarks[0][!g_dbg.isAV_SYNC_Exit], + g_selectMarks[0][!g_dbg.isFmbLogEvent], + g_selectMarks[0][!g_dbg.isScrEventLog], + g_selectMarks[0][!g_dbg.isFmbLogCmd], + g_selectMarks[0][!g_dbg.isTS_PSIZE_Exit], + g_selectMarks[0][!g_dbg.isNotRecMessages] + ); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + HANDLE hScet; + + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + g_dbg.isFuncTrace = ! g_dbg.isFuncTrace; /* pgr2711 */ //Function Trace + if(g_dbg.isFuncTrace){ + SetFuncTraceCallDepth(gp_FmbComProperty->deviceNum, 3, 0, 3, 0, 0); + } + break; + case '2': + g_dbg.isRecvTrace = ! g_dbg.isRecvTrace; /* pgr2711 */ //MB86 Receive Trace + break; + case '3': + g_dbg.isRecvDumpTrace = ! g_dbg.isRecvDumpTrace; /* pgr2711 */ //MB86 Receive Dump Trace + break; + case '4': + g_dbg.isSceTrace = ! g_dbg.isSceTrace; /* pgr2711 */ //Scenario Trace + break; + case '5': + g_dbg.isFmbLog = ! g_dbg.isFmbLog; /* pgr2711 */ //MB86 Log + break; + case '6': + g_dbg.isScrLog = ! g_dbg.isScrLog; /* pgr2711 */ //ScrLog + break; + case '7': + g_dbg.isMessageFilterOn = ! g_dbg.isMessageFilterOn; /* pgr2711 */ //System Message Filter Off + hScet = gp_FmbComProperty->hEmptyScet; + DrvSetIsNotify(hScet, g_dbg.isMessageFilterOn); + break; + case '8': + g_dbg.isAV_SYNC_Exit = ! g_dbg.isAV_SYNC_Exit; /* pgr2711 */ //if AV_SYC = 1 then exit. + break; + case '9': + g_dbg.isFmbLogEvent = ! g_dbg.isFmbLogEvent; /* pgr2711 */ + break; + case 'a': + case 'A': + g_dbg.isScrEventLog = ! g_dbg.isScrEventLog; /* pgr2711 */ + break; + case 'b': + case 'B': + g_dbg.isFmbLogCmd = ! g_dbg.isFmbLogCmd; /* pgr2711 */ //MB86 command + break; + case 'c': + case 'C': + g_dbg.isTS_PSIZE_Exit = ! g_dbg.isTS_PSIZE_Exit; /* pgr2711 */ //if TS_SIZE unmatch exit + break; + case 'd': + case 'D': + g_dbg.isNotRecMessages = ! g_dbg.isNotRecMessages; /* pgr2711 */ + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ReturnToAnotherScreenMode(ScrEnmNormalMode); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when fmb-request is complete. +* @param[in] req Kind of completed request +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnFmbRequestComplete(enum FMBRequestEnum req) +{ + + FMB_FUNC(TRUE); + + switch(req){ + case FMBEnmReqAutoStop: + ChangePrevScreenTo(ScrEnmNormalMode, ScrEnmEndOfPlay); + break; + default: + ASSERT_USR(FALSE, "Invalid request mode."); + break; + }; + + printOut("\n"); + SetInputEnabled(TRUE); + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetOutputPortEnc.c b/fmb_player_apl/src/scr/SetOutputPortEnc.c new file mode 100644 index 0000000..efae621 --- /dev/null +++ b/fmb_player_apl/src/scr/SetOutputPortEnc.c @@ -0,0 +1,128 @@ +/** +* @brief The function of the output Port setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Output port ]]]\n\ + 'B'<-~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c File\n\ +"; +static const char validChars[] = "1bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the output Port of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetOutputPortEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + fprintOut(stdout, _screenStr, + g_selectMarks[gp_FmbProperty[setmode].outputPort][FMBEnmPortFile]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].outputPort = FMBEnmPortFile; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + switch(gp_FmbProperty[setmode].outputPort){ + case FMBEnmPortFile: + nextScr = ScrEnmSetFile; + break; + case FMBEnmPortStreamport: + nextScr = ScrEnmSetSubMenuEnc; + break; + default: + ASSERT_USR(FALSE, "Invalid output port."); + break; + } + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetPidTypeCom.c b/fmb_player_apl/src/scr/SetPidTypeCom.c new file mode 100644 index 0000000..384a3c5 --- /dev/null +++ b/fmb_player_apl/src/scr/SetPidTypeCom.c @@ -0,0 +1,143 @@ +/** +* @brief The function of the setting PID type of Common setting is defined. +* @since +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Common settings - Sub menu -> PID type ]]]\n\ + 'B'<-~~~~~~~~\n\ +Select following character. (Current settings)\n\ + 1 Input Video-PID (0x%04x)\n\ + 2 Input Audio-PID (0x%04x)\n\ + 3 Input PMT-PID (0x%04x)\n\ + 4 Input SIT-PID (0x%04x)\n\ + 5 Input PCR-PID (0x%04x)\n\ + 6 Output Video-PID (0x%04x)\n\ + 7 Output Audio-PID (0x%04x)\n\ + 8 Output PMT-PID (0x%04x)\n\ + 9 Output SIT-PID (0x%04x)\n\ + a Output PCR-PID (0x%04x)\n\ +"; + +static const char validChars[] = "123456789aAbB"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the sub menu of the decoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetPidTypeCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ + +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + printOut(_screenStr, + gp_FmbComProperty->PidValue[FMBEnmInputVideoPid], + gp_FmbComProperty->PidValue[FMBEnmInputAudioPid], + gp_FmbComProperty->PidValue[FMBEnmInputPmtPid], + gp_FmbComProperty->PidValue[FMBEnmInputSitPid], + gp_FmbComProperty->PidValue[FMBEnmInputPcrPid], + gp_FmbComProperty->PidValue[FMBEnmOutputVideoPid], + gp_FmbComProperty->PidValue[FMBEnmOutputAudioPid], + gp_FmbComProperty->PidValue[FMBEnmOutputPmtPid], + gp_FmbComProperty->PidValue[FMBEnmOutputSitPid], + gp_FmbComProperty->PidValue[FMBEnmOutputPcrPid]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + unsigned int i; + char str[2]; + int numofConv; + + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'a': + case 'A': + str[0] = InputCharacterCode; + str[1] = 0; + numofConv = sscanf(str, "%x", &i); + ASSERT_USR(numofConv == 1, "hexstring -> value is failure."); + i--; + gp_FmbComProperty->PidType = i; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuCom); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetInOutPidCom); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetSubMenuCom.c b/fmb_player_apl/src/scr/SetSubMenuCom.c new file mode 100644 index 0000000..af3a3b8 --- /dev/null +++ b/fmb_player_apl/src/scr/SetSubMenuCom.c @@ -0,0 +1,117 @@ +/** +* @brief The function of the sub menu screen of the common setting is defined. +* @since +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Common settings - Sub menu >\n\ + 'B'<-~~~~~~~~\n\ +Select following number.\n\ +\n\ + 1 TS packet size setting\n\ + 2 PID setting\n\ + 3 Firm file setting\n\ + 4 Config file saving\n\ +\n\ +"; + +static const char validChars[] = "1234bB"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the sub menu of the Common setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetSubMenuCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ + +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + printOut(_screenStr); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + ChangeScreenTo(ScrEnmSetTsTypeCom); + break; + case '2': + ChangeScreenTo(ScrEnmSetPidTypeCom); + break; + case '3': + ChangeScreenTo(ScrEnmSetFirmCom); + break; + case '4': + ChangeScreenTo(ScrEnmSetConfigCom); + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetSubMenuDec.c b/fmb_player_apl/src/scr/SetSubMenuDec.c new file mode 100644 index 0000000..1437ae1 --- /dev/null +++ b/fmb_player_apl/src/scr/SetSubMenuDec.c @@ -0,0 +1,130 @@ +/** +* @brief The function of the sub menu screen of the decoding setting is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Decode settings - Sub menu >\n\ + 'B'<-~~~~~~~~\n\ +Select following number. (Current settings)\n\ +\n\ + 1 Input port setting (%s%s)\n\ + 2 Video resolution setting(%s)\n\ + 3 Audio format setting (%s)\n\ +\n\ +"; + +static const char validChars[] = "123bB"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the sub menu of the decoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetSubMenuDec(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; + scr->childScreen = ScrEnmSelSingleDev; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + char inputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + gp_FmbComProperty->setMode = FMBEnmFuncModeDec; + setmode = gp_FmbComProperty->setMode; + + FmbApplySettingGpioVideoFormat(); + + ScrEditFilePathString(FMBEnmInPort, inputfilepath, sizeof(inputfilepath)); + + //The screen is displayed. + printOut(_screenStr, + g_FmbNamePort[gp_FmbProperty[setmode].inputPort], + inputfilepath, + g_FmbNameVideoRsltn[gp_FmbProperty[setmode].videoRsltn], + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + ChangeScreenTo(ScrEnmSetInputPortDec); + break; + case '2': + ChangeScreenTo(ScrEnmSetVideoRsltnDec); + break; + case '3': + ChangeScreenTo(ScrEnmSetAudioFormatDec); + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetSubMenuEnc.c b/fmb_player_apl/src/scr/SetSubMenuEnc.c new file mode 100644 index 0000000..0355c2e --- /dev/null +++ b/fmb_player_apl/src/scr/SetSubMenuEnc.c @@ -0,0 +1,164 @@ +/** +* @brief The function of the sub menu screen of the encoding setting is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Encode settings - Sub menu >\n\ + 'B'<-~~~~~~~~\n\ +Select following number. (Current settings)\n\ +\n\ + 1 Output port setting (%s%s)\n\ + 2 Video resolution setting(%s)\n\ + 3 Video bitrate setting (%s, %s)\n\ + 4 Audio format (%s%s)\n\ +\n\ +"; + +static const char validChars[] = "1234bB"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the sub menu of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetSubMenuEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + scr->IsShowChildFunc = FmbIsNotDeviceSelecting; + scr->childScreen = ScrEnmSelSingleDev; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + char video_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char audio_bitrate[FMB_BITRATE_MAX_CHAR]={0}; + char outputfilepath[FMB_FILEPATH_MAX_CHAR+1]={0}; + enum FMBFuncModeEnum setmode; +#ifdef USE_MMUX // [ USE_MMUX + enum MMUX_RESOLUTION resolution; + int codecNumPerBorad; + int codecNum; +#endif // USE_MMUX ] + + FMB_FUNC(TRUE); + + gp_FmbComProperty->setMode = FMBEnmFuncModeEnc; + setmode = gp_FmbComProperty->setMode; + +#ifdef USE_MMUX // [ USE_MMUX + codecNumPerBorad = FmbGetDeviceTotal()/FmbGetBoardTotal(); + codecNum = FmbGetCurDeviceNum(); + FmbSetCurMmuxDevNum(codecNum/codecNumPerBorad); + + resolution = MmuxGetCodecSrcResolution(FmbGetCurMmuxHd(), FmbGetCurDevNumOnBoard()); + FmbSetVideoFormat(FmbRsltnMmux2Fmb(resolution), setmode); +#endif // USE_MMUX ] + + FmbApplySettingGpioVideoFormat(); + + + (void)FmbCalcVideoBitrateParam(&gp_FmbProperty[gp_FmbComProperty->setMode].videoBitrateProp, + gp_FmbProperty[gp_FmbComProperty->setMode].videoFrm, + gp_FmbProperty[gp_FmbComProperty->setMode].audioFmt); + + ScrEditVideoBitrateString(video_bitrate, sizeof(video_bitrate)); + + ScrEditAudioBitrateString(audio_bitrate, sizeof(audio_bitrate)); + + ScrEditFilePathString(FMBEnmOutPort, outputfilepath, sizeof(outputfilepath)); + + //The screen is displayed. + printOut(_screenStr, + g_FmbNamePort[gp_FmbProperty[setmode].outputPort], + outputfilepath, + g_FmbNameVideoRsltn[gp_FmbProperty[setmode].videoRsltn], + g_FmbNameVideoRateCtls[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl], + video_bitrate, + g_FmbNameAudioFmts[gp_FmbProperty[setmode].audioFmt], + audio_bitrate, + gp_FmbProperty[setmode].videoBitrateProp.systemMuxRate, + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateParam.muxRate); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + ChangeScreenTo(ScrEnmSetOutputPortEnc); + break; + case '2': + ChangeScreenTo(ScrEnmSetVideoRsltnEnc); + break; + case '3': + ChangeScreenTo(ScrEnmSetVideoRatecontrol); + break; + case '4': + ChangeScreenTo(ScrEnmSetAudioFormatEnc); + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetSystemBitrate.c b/fmb_player_apl/src/scr/SetSystemBitrate.c new file mode 100644 index 0000000..e44ff49 --- /dev/null +++ b/fmb_player_apl/src/scr/SetSystemBitrate.c @@ -0,0 +1,154 @@ +/** +* @brief The function of the system bitrate setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ %s -> System bitrate ]]]\n\ + %s 'B'<-~~~~~~~~~~~~~~->Enter\n\ +Input bitrate in kbps.\n\ +Current value is %dkbps.\n\ +"; + +///Kind of the sub menu setting screen. +extern const char *_screenSubmenuTitle[3][2]; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the system bitrate setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetSystemBitrate(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + enum ScreenSetSubMenuTypeEnum type = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + switch(setmode){ + case FMBEnmFuncModeEnc: + type = ScrEnmSetSubMenuEncType; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + fprintOut(stdout, _screenStr, + _screenSubmenuTitle[type][0], _screenSubmenuTitle[type][1], + gp_FmbProperty[setmode].videoBitrateProp.systemMuxRate); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + int val; + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR( ((gp_FmbComProperty->setMode == FMBEnmFuncModeEnc) ), + "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(*lineString){ + case '\0': + gp_FmbProperty[setmode].videoBitrateProp.bitrateCalckind = FMBEnmBitrateCalcSystembase; + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + val = StrToUnsignedInt(lineString); + if(val < 0){ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + if((val & 0xFFFF0000) != 0){ + MsgDispInputErr(FMB_INPUTERR_TOO_LARGE_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + gp_FmbProperty[setmode].videoBitrateProp.systemMuxRate = val; + gp_FmbProperty[setmode].videoBitrateProp.bitrateCalckind = FMBEnmBitrateCalcSystembase; + break; + } + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetTsPacketCom.c b/fmb_player_apl/src/scr/SetTsPacketCom.c new file mode 100644 index 0000000..634cee6 --- /dev/null +++ b/fmb_player_apl/src/scr/SetTsPacketCom.c @@ -0,0 +1,131 @@ +/** +* @brief The function of the TS Pacekt size of Common setting is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Common settings - Sub menu -> TS packet size -> %s]]]\n\ + 'B'<-%s->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c %s\n\ + 2 %c %s\n\ + 3 %c %s\n\ +"; + +static const char validChars[] = "123bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +///<Current TS Packet Type name and character +const char *FmbNameTs[2][2] = { + {"Input TS packet size" , "~~~~~~~~~~~~~~~~~~~~" }, + {"Output TS packet size" , "~~~~~~~~~~~~~~~~~~~~~" }, +}; + +/** +* @brief Initial screen of the sub menu of the Common setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetTsPacketCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ + +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + printOut(_screenStr, + FmbNameTs[gp_FmbComProperty->TsType][0], + FmbNameTs[gp_FmbComProperty->TsType][1], + g_selectMarks[gp_FmbComProperty->tsFormat[gp_FmbComProperty->TsType]][FMBEnmTsFormat188], + g_FmbNamePacketSize[0], + g_selectMarks[gp_FmbComProperty->tsFormat[gp_FmbComProperty->TsType]][FMBEnmTsFormat192], + g_FmbNamePacketSize[1], + g_selectMarks[gp_FmbComProperty->tsFormat[gp_FmbComProperty->TsType]][FMBEnmTsFormat192e], + g_FmbNamePacketSize[2] + ); + + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + gp_FmbComProperty->tsFormat[gp_FmbComProperty->TsType] = FMBEnmTsFormat188; + break; + case '2': + gp_FmbComProperty->tsFormat[gp_FmbComProperty->TsType] = FMBEnmTsFormat192; + break; + case '3': + gp_FmbComProperty->tsFormat[gp_FmbComProperty->TsType] = FMBEnmTsFormat192e; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetTsTypeCom); + FMB_FUNC(FALSE); + return TRUE; + break; + case '\n': + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuCom); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetTsTypeCom.c b/fmb_player_apl/src/scr/SetTsTypeCom.c new file mode 100644 index 0000000..22d1c54 --- /dev/null +++ b/fmb_player_apl/src/scr/SetTsTypeCom.c @@ -0,0 +1,112 @@ +/** +* @brief The function of the setting TS packet type of Common setting is defined. +* @since +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Common settings - Sub menu -> TS packet size ]]]\n\ + 'B'<-~~~~~~~~~~~~~~\n\ +Select following number. (Current settings)\n\ + 1 Input TS packet size (%s)\n\ + 2 Output TS packet size (%s)\n\ +"; +static const char validChars[] = "12bB"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the setting TS packet type of the common setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetTsTypeCom(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ + +static BOOL OnShow(void) +{ + FMB_FUNC(TRUE); + + printOut(_screenStr, + g_FmbNamePacketSize[gp_FmbComProperty->tsFormat[FMBEnmInputTsPacket]], + g_FmbNamePacketSize[gp_FmbComProperty->tsFormat[FMBEnmOutputTsPacket]] + ); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + + FMB_FUNC(TRUE); + switch(InputCharacterCode){ + case '1': + gp_FmbComProperty->TsType = FMBEnmInputTsPacket; + break; + case '2': + gp_FmbComProperty->TsType = FMBEnmOutputTsPacket; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuCom); + FMB_FUNC(FALSE); + return TRUE; + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetTsPacketCom); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVedioOut.c b/fmb_player_apl/src/scr/SetVedioOut.c new file mode 100644 index 0000000..afff451 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVedioOut.c @@ -0,0 +1,151 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Device list >\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ +\n\ + 1 %c Video Input 0\n\ + 2 %c Video Input 1\n\ + 3 %c Video Input 2\n\ + 4 %c Video Input 3\n\ + 5 %c Codec 0\n\ + 6 %c Codec 1\n\ + 7 %c Codec 2\n\ + 8 %c Codec 3\n\ +\n\ +"; + +static const char validChars[] = "bB12345678"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoOut(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum MMUX_OUTPUT_SRC outputSrc; + + FMB_FUNC(TRUE); +
+ outputSrc = MmuxGetOutputSrc(FmbGetCurMmuxHd(), 0);
+
+ printOut(_screenStr, + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_0], + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_1], + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_2], + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_3], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_0], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_1], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_2], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_3]); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetVideoInOut); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + MmuxSetOutputSrc(FmbGetCurMmuxHd(), 0, InputCharacterCode-1); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + ChangeScreenTo(ScrEnmSetVideoInOut); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetVideoBitrateCbr.c b/fmb_player_apl/src/scr/SetVideoBitrateCbr.c new file mode 100644 index 0000000..0e194da --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoBitrateCbr.c @@ -0,0 +1,164 @@ +/** +* @brief The function of the CBR video bitrate setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ %s -> Video ratecontrol -> Video bitrate ]]]\n\ + %s 'B'<-~~~~~~~~~~~~~->Enter\n\ +Input bitrate in kbps. (%s)\n\ +Current value is %dkbps.\n\ +"; + +///Kind of the sub menu setting screen. +extern const char *_screenSubmenuTitle[3][2]; + +extern const char *_videoBitrateRanges[]; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the CBR video bitrate setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoBitrateCbr(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + enum ScreenSetSubMenuTypeEnum type = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + switch(setmode){ + case FMBEnmFuncModeEnc: + type = ScrEnmSetSubMenuEncType; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + fprintOut(stdout, _screenStr, + _screenSubmenuTitle[type][0], _screenSubmenuTitle[type][1], + _videoBitrateRanges[gp_FmbProperty[setmode].videoFmt], + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateCbr); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + int val; + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch(*lineString){ + case '\0': + gp_FmbProperty[setmode].videoBitrateProp.bitrateCalckind = FMBEnmBitrateCalcVideobase; + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + val = StrToUnsignedInt(lineString); + if(val < 0){ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + if(val > FMB_MAX_BITRATE_CBR){ + MsgDispInputErr(FMB_INPUTERR_TOO_LARGE_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateCbr = val; + gp_FmbProperty[setmode].videoBitrateProp.bitrateCalckind = FMBEnmBitrateCalcVideobase; + break; + } + + switch(setmode){ + case FMBEnmFuncModeEnc: + nextScr = ScrEnmSetSubMenuEnc; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetVideoBitrateVbr.c b/fmb_player_apl/src/scr/SetVideoBitrateVbr.c new file mode 100644 index 0000000..3ddfdd7 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoBitrateVbr.c @@ -0,0 +1,242 @@ +/** +* @brief The function of the VBR video bitrate setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <string.h> + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ %s -> Video ratecontrol -> Video bitrate ]]]\n\ + %s 'B'<-~~~~~~~~~~~~~->Enter\n\ +Input bitrate in kbps. (%s)\n\ +"; + +///Kind of the sub menu setting screen. +extern const char *_screenSubmenuTitle[3][2]; + +static const char *_screenStrCurrentVal[] = { + "Current average bitrate is %dkbps.\n", + "Current peak bitrate is %dkbps.\n" +}; + +static const char *_screenStrPrompts[] = { + "Average ", + "Peak " +}; + +extern const char *_videoBitrateRanges[]; + +//What bitrate you input is shown now. +static enum ScreenVideoBitrateVbrEnum _currentBitrateType; + +//The prompt is displayed. +static void Prompt(enum ScreenVideoBitrateVbrEnum bitrateType); + +static struct Screen *_me; + +static int _tempBitrates[2]; + +//Event function when 1-line is input. +static BOOL OnLineInput(char *lineString); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the VBR video bitrate setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoBitrateVbr(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->displayString = _screenStr; + scr->OnLineInputFunc = OnLineInput; + scr->OnShowFunc = OnShow; + + _me = scr; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + enum ScreenSetSubMenuTypeEnum type = 0; + + FMB_FUNC(TRUE); + + //Set screen mode + SetScreenMode(ScrEnmModeKeybuffer); + + setmode = gp_FmbComProperty->setMode; + + switch(setmode){ + case FMBEnmFuncModeEnc: + type = ScrEnmSetSubMenuEncType; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + _currentBitrateType = ScrEnmVideoBitrateVbrAverage; + + printOut(_screenStr, + _screenSubmenuTitle[type][0], _screenSubmenuTitle[type][1], + _videoBitrateRanges[gp_FmbProperty[setmode].videoFmt]); + + _tempBitrates[ScrEnmVideoBitrateVbrAverage] = gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrAverage; + _tempBitrates[ScrEnmVideoBitrateVbrPeak] = gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrPeak; + + Prompt(_currentBitrateType); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when 1-line is input. +* @param[in] lineString Input line +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnLineInput(char *lineString) +{ + int val; + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + //The input value that those who operated it intended is requested. + switch(*lineString){ + case '\0': + val = _tempBitrates[_currentBitrateType]; + break; + case 'b': + case 'B': + if(lineString[1] == '\0'){ + if(_currentBitrateType == ScrEnmVideoBitrateVbrAverage){ + printOut("The input bitrate value is canceled. \n"); + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(GetPrevScreen()); + } + else{ + _currentBitrateType --; + Prompt(_currentBitrateType); + } + } + else{ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + } + FMB_FUNC(FALSE); + return TRUE; + break; + default: + val = StrToUnsignedInt(lineString); + if(val < 0){ + MsgDispInputErr(FMB_INPUTERR_INVALID_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + if(val > FMB_MAX_BITRATE_VBR){ + MsgDispInputErr(FMB_INPUTERR_TOO_LARGE_VALUE); + FMB_FUNC(FALSE); + return TRUE; + } + + break; + } + + //The input value is reflected according to a present bitrate type. + switch(_currentBitrateType){ + case ScrEnmVideoBitrateVbrAverage: + _tempBitrates[_currentBitrateType] = val; + _currentBitrateType ++; + Prompt(_currentBitrateType); + break; + case ScrEnmVideoBitrateVbrPeak: + if(_tempBitrates[ScrEnmVideoBitrateVbrAverage] > val){ + MsgDispInputErr(FMB_INPUTERR_TOO_SMALL_VALUE); + break; + } + _tempBitrates[_currentBitrateType] = val; + + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrAverage = _tempBitrates[ScrEnmVideoBitrateVbrAverage]; + gp_FmbProperty[setmode].videoBitrateProp.videoBitrateVbrPeak = _tempBitrates[ScrEnmVideoBitrateVbrPeak]; + gp_FmbProperty[setmode].videoBitrateProp.bitrateCalckind = FMBEnmBitrateCalcVideobase; + + switch(setmode){ + case FMBEnmFuncModeEnc: + nextScr = ScrEnmSetSubMenuEnc; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + SetScreenMode(ScrEnmMode1key); + ChangeScreenTo(nextScr); + break; + default: + ASSERT_USR(FALSE, "Invalid bitrate type."); + break; + } + + LogScr("TempVbrAverage\t%d\tTempVbrPeak\t%d\tval\t%d", + _tempBitrates[ScrEnmVideoBitrateVbrAverage], + _tempBitrates[ScrEnmVideoBitrateVbrPeak], + val); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief The prompt is displayed. +* @param[in] ScreenVideoBitrateVbrEnum bitrateType +* @return None +* @note None +* @attention None +*/ +static void Prompt(enum ScreenVideoBitrateVbrEnum bitrateType) +{ + FMB_FUNC(TRUE); + + printOut(_screenStrCurrentVal[bitrateType], _tempBitrates[bitrateType]); + _me->prompt = _screenStrPrompts[bitrateType]; + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); +} diff --git a/fmb_player_apl/src/scr/SetVideoFormatDec.c b/fmb_player_apl/src/scr/SetVideoFormatDec.c new file mode 100644 index 0000000..ed40e4f --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoFormatDec.c @@ -0,0 +1,131 @@ +/** +* @brief The function of the video format setting screen of the decoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decode settings - Sub menu -> Video format ]]]\n\ + 'B'<-~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c 1920x1080\n\ + 2 %c 1440x1080\n\ + 3 %c 1280x720\n\ + 4 %c 720x480\n\ + 5 %c 720x576\n\ +"; + +static const char validChars[] = "12345bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video format of the decoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoFormatDec(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt1920x1080], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt1440x1080], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt1280x720], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt720x480], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt720x576]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + gp_FmbProperty[setmode].videoFmt = InputCharacterCode - '1'; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuDec); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuDec); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoFormatEnc.c b/fmb_player_apl/src/scr/SetVideoFormatEnc.c new file mode 100644 index 0000000..f3c1bd1 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoFormatEnc.c @@ -0,0 +1,130 @@ +/** +* @brief The function of the video format setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Video format ]]]\n\ + 'B'<-~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c 1920x1080 (6000kbps -- 24000kbps(I) or 30000kbps(P))\n\ + 2 %c 1440x1080 (5000kbps -- 24000kbps)\n\ + 3 %c 1280x720 (4000kbps -- 24000kbps)\n\ + 4 %c 720x480 (2000kbps -- 10000kbps)\n\ + 5 %c 720x576 (2000kbps -- 10000kbps)\n\ +"; +static const char validChars[] = "12345bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video format of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoFormatEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt1920x1080], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt1440x1080], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt1280x720], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt720x480], + g_selectMarks[gp_FmbProperty[setmode].videoFmt][FMBEnmVideoFmt720x576]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + gp_FmbProperty[setmode].videoFmt = InputCharacterCode - '1'; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoFrameDec.c b/fmb_player_apl/src/scr/SetVideoFrameDec.c new file mode 100644 index 0000000..e780554 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoFrameDec.c @@ -0,0 +1,130 @@ +/** +* @brief The function of the video frame rate setting screen of the decoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decode settings - Sub menu -> Video framerate ]]]\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c 60p \n\ + 2 %c 59.94p \n\ + 3 %c 50p \n\ + 4 %c 60i \n\ + 5 %c 59.94i \n\ + 6 %c 50i \n\ +"; +static const char validChars[] = "123456bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video frame rate of the decoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoFrameDec(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_60p], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_5994p], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_50p], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_60i], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_5994i], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_50i]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + gp_FmbProperty[setmode].videoFrm = InputCharacterCode - '1'; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuDec); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuDec); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoFrameEnc.c b/fmb_player_apl/src/scr/SetVideoFrameEnc.c new file mode 100644 index 0000000..87e6ab9 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoFrameEnc.c @@ -0,0 +1,130 @@ +/** +* @brief The function of the video frame rate setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Video framerate ]]]\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c 60p \n\ + 2 %c 59.94p \n\ + 3 %c 50p \n\ + 4 %c 60i \n\ + 5 %c 59.94i \n\ + 6 %c 50i \n\ +"; +static const char validChars[] = "123456bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video format of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoFrameEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_60p], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_5994p], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_50p], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_60i], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_5994i], + g_selectMarks[gp_FmbProperty[setmode].videoFrm][FMBEnmVideoFrm_50i]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + gp_FmbProperty[setmode].videoFrm = InputCharacterCode - '1'; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoInOut.c b/fmb_player_apl/src/scr/SetVideoInOut.c new file mode 100644 index 0000000..4a95597 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoInOut.c @@ -0,0 +1,152 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright ICP Electronics (C) 2010 * + *===============================================*/ +/*-----------------------------------------------* + $Author: Kenneth $ + $Date: $ + $Revision: $ + *-----------------------------------------------*/ +/* + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + + +static const char *_screenStrTitle = "\ +< Device list >\n\ +Select following character.\n\ +\n\ +"; + +static const char *_screenStrItem = "\ + %d Video output [%s]\n\ +"; +static const char *_screenStrEnd = "\ +\n\ +"; + +static const char validChars[] = "bB12"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoIO(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->displayString = _screenStrTitle; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + char const *srcOutput; + int boardTotal; + int boardNum; + + FMB_FUNC(TRUE); + + + printOut(_screenStrTitle); + + boardTotal = FmbGetBoardTotal(); + for (boardNum=0; boardNum<boardTotal; boardNum++) { + FmbSetCurMmuxDevNum(boardNum); + srcOutput = MmuxGetOutputSrcStr(MmuxGetOutputSrc(FmbGetCurMmuxHd(), 0)); + + printOut(_screenStrItem, boardNum +1, srcOutput); + } + + printOut(_screenStrEnd); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + int devNum; + int boardTotal; + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmMainMenu); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + boardTotal = FmbGetBoardTotal(); + devNum = InputCharacterCode - '1'; + if (devNum < boardTotal) { + FmbSetCurMmuxDevNum(devNum); + ChangeScreenTo(ScrEnmSetVideoOutMode); + } + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetVideoOutBypass.c b/fmb_player_apl/src/scr/SetVideoOutBypass.c new file mode 100644 index 0000000..2d85b48 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoOutBypass.c @@ -0,0 +1,139 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Device list >\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ +\n\ + 1 %c Input 0\n\ + 2 %c Input 1\n\ + 3 %c Input 2\n\ + 4 %c Input 3\n\ +\n\ +"; + +static const char validChars[] = "bB1234"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoOutBypass(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum MMUX_OUTPUT_SRC outputSrc; + + FMB_FUNC(TRUE); +
+ outputSrc = MmuxGetOutputSrc(FmbGetCurMmuxHd(), 0);
+
+ printOut(_screenStr, + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_0], + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_1], + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_2], + g_selectMarks[outputSrc][MMUX_OUT_SRC_IN_3]); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetVideoOutMode); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + case '3': + case '4': + MmuxSetOutputSrc(FmbGetCurMmuxHd(), 0, InputCharacterCode -1); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + ChangeScreenTo(ScrEnmSetVideoInOut); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetVideoOutH264.c b/fmb_player_apl/src/scr/SetVideoOutH264.c new file mode 100644 index 0000000..7c20856 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoOutH264.c @@ -0,0 +1,139 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Device list >\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ +\n\ + 1 %c Codec chip 0\n\ + 2 %c Codec chip 1\n\ + 3 %c Codec chip 2\n\ + 4 %c Codec chip 3\n\ +\n\ +"; + +static const char validChars[] = "bB1234"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoOutH264(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum MMUX_OUTPUT_SRC outputSrc; + + FMB_FUNC(TRUE); +
+ outputSrc = MmuxGetOutputSrc(FmbGetCurMmuxHd(), 0);
+
+ printOut(_screenStr, + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_0], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_1], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_2], + g_selectMarks[outputSrc][MMUX_OUT_SRC_CODEC_3]); + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetVideoOutMode); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + case '2': + case '3': + case '4': + MmuxSetOutputSrc(FmbGetCurMmuxHd(), 0, InputCharacterCode +3); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + ChangeScreenTo(ScrEnmSetVideoInOut); + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetVideoOutMode.c b/fmb_player_apl/src/scr/SetVideoOutMode.c new file mode 100644 index 0000000..147a65d --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoOutMode.c @@ -0,0 +1,136 @@ +/*================================================
+ * *************** *
+ * ** \ | / ** *
+ * * **** **** ****** * *
+ * * ---**---**-|-**--**--** * *
+ * * ** ** | * ** ** * *
+ * *-----**--**--o-----****----* *
+ * * ** ** | ** * *
+ * * ---**---**-|--*--**---- * *
+ * * **** **** **** * *
+ * ** / | \ ** *
+ * ************** *
+ * Copyright ICP Electronics (C) 2010 *
+ *===============================================*/
+/*-----------------------------------------------*
+ $Author: Kenneth $
+ $Date: $
+ $Revision: $
+ *-----------------------------------------------*/
+/*
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +< Device list >\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ +\n\ + 1 %c Bypass Mode\n\ + 2 %c H.264 Mode\n\ +\n\ +"; + +static const char validChars[] = "bB12"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the main menu. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoOutMode(struct Screen *scr) +{ + FMB_FUNC(TRUE); + + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->displayString = _screenStr; + scr->validChars = validChars; + + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum MMUX_OUTPUT_MODE outputMode;
+
+ FMB_FUNC(TRUE);
+
+ outputMode = MmuxGetOutputMode(FmbGetCurMmuxHd(), 0);
+
+ printOut(_screenStr, + g_selectMarks[outputMode][MMUX_OUT_MODE_BYPASS], + g_selectMarks[outputMode][MMUX_OUT_MODE_H264]); + + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + FMB_FUNC(TRUE); + + switch (InputCharacterCode) { + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetVideoInOut); + FMB_FUNC(FALSE); + return TRUE; + break; + case '1': + ChangeScreenTo(ScrEnmSetVideoOutBypass); + break; + case '2': + ChangeScreenTo(ScrEnmSetVideoOutH264); + break; + default: + ASSERT_USR(FALSE, "Invalid character code."); + break; + } + + FMB_FUNC(FALSE); + return TRUE; +} + diff --git a/fmb_player_apl/src/scr/SetVideoRatecontrol.c b/fmb_player_apl/src/scr/SetVideoRatecontrol.c new file mode 100644 index 0000000..d8fc9f5 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoRatecontrol.c @@ -0,0 +1,150 @@ +/** +* @brief The function of the video rate control setting screen is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ %s -> Video ratecontrol -> Video bitrate ]]]\n\ + %s 'B'<-~~~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c CBR\n\ + 2 %c VBR\n\ +"; + +static const char validChars[] = "12bB\n"; + +///Kind of the sub menu setting screen. +extern const char *_screenSubmenuTitle[3][2]; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video rate control setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoRatecontrol(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + enum ScreenSetSubMenuTypeEnum type = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch(setmode){ + case FMBEnmFuncModeEnc: + type = ScrEnmSetSubMenuEncType; + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + + fprintOut(stdout, _screenStr, + _screenSubmenuTitle[type][0], _screenSubmenuTitle[type][1], + g_selectMarks[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl][FMBEnmVideoRateCtlCbr], + g_selectMarks[gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl][FMBEnmVideoRateCtlVbr]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + enum ScreenEnum nextScr = 0; + + FMB_FUNC(TRUE); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl = FMBEnmVideoRateCtlCbr; + break; + case '2': + gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl = FMBEnmVideoRateCtlVbr; + break; + case 'b': + case 'B': + switch(setmode){ + case FMBEnmFuncModeEnc: + ChangeScreenTo(ScrEnmSetSubMenuEnc); + break; + default: + ASSERT_USR(FALSE, "Function mode is illegal."); + break; + } + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + switch(gp_FmbProperty[setmode].videoBitrateProp.videoRateCtl){ + case FMBEnmVideoRateCtlCbr: + nextScr = ScrEnmSetVideoBitrateCbr; + break; + case FMBEnmVideoRateCtlVbr: + nextScr = ScrEnmSetVideoBitrateVbr; + break; + default: + ASSERT_USR(FALSE, "Invalid rate control."); + break; + } + ChangeScreenTo(nextScr); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoResolutionDec.c b/fmb_player_apl/src/scr/SetVideoResolutionDec.c new file mode 100644 index 0000000..086674b --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoResolutionDec.c @@ -0,0 +1,213 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright ICP Electronics (C) 2010 * + *===============================================*/ +/*-----------------------------------------------* + $Author: Kenneth $ + $Date: $ + $Revision: $ + *-----------------------------------------------*/ +/* + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Decode settings - Sub menu -> Video resolution ]]]\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c %s\n\ + 2 %c %s\n\ + 3 %c %s\n\ + 4 %c %s\n\ + 5 %c %s\n\ + 6 %c %s\n\ + 7 %c %s\n\ + 8 %c %s\n\ + 9 %c %s\n\ + i %c %s\n\ + j %c %s\n\ + k %c %s\n\ + l %c %s\n\ + m %c %s\n\ + n %c %s\n\ +"; + + +static const char validChars[] = "123456789iIjJkKlLmMnNbB\n"; + + + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video resolution of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoResolutionDec(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_60p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_60p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_59p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_59p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_50p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_50p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_60i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_60i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_59i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_59i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_50i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_50i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1440_1080_60i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1440_1080_60i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1440_1080_59i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1440_1080_59i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1440_1080_50i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1440_1080_50i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1280_720_60p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1280_720_60p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1280_720_59p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1280_720_59p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1280_720_50p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1280_720_50p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_720_480_60i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_720_480_60i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_720_480_59i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_720_480_59i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_720_576_50i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_720_576_50i]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + enum FMBVideoResolutionEnum resolution_Fmb; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeDec, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + resolution_Fmb = InputCharacterCode - '1' + FMBEnmVideoRsltn_1920_1080_60p; + FmbSetVideoFormat(resolution_Fmb, setmode); + break; + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + resolution_Fmb = InputCharacterCode - 'i' + FMBEnmVideoRsltn_1280_720_60p; + FmbSetVideoFormat(resolution_Fmb, setmode); + break; + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + resolution_Fmb = InputCharacterCode - 'I' + FMBEnmVideoRsltn_1280_720_60p; + FmbSetVideoFormat(resolution_Fmb, setmode); + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuDec); + FMB_FUNC(FALSE); + return TRUE; + case '\n': + OnShow(); + break; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuDec); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoResolutionEnc.c b/fmb_player_apl/src/scr/SetVideoResolutionEnc.c new file mode 100644 index 0000000..a7279ff --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoResolutionEnc.c @@ -0,0 +1,255 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright ICP Electronics (C) 2010 * + *===============================================*/ +/*-----------------------------------------------* + $Author: Kenneth $ + $Date: $ + $Revision: $ + *-----------------------------------------------*/ +/* + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +#ifdef USE_MMUX // [ USE_MMUX +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Video resolution ]]]\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. \n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + %c %s\n\ + (* is current setting)\n\ + Please change the input source resolution if you \n\ + want to use select others. Then press \"Enter\"\n\ + to reload.\n\ +"; + +static const char validChars[] = "bB\n"; +#else // USE_MMUX ] [ !USE_MMUX +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Video resolution ]]]\n\ + 'B'<-~~~~~~~~~~~~~~~->Enter\n\ +Select following number. \n\ + 1 %c %s\n\ + 2 %c %s\n\ + 3 %c %s\n\ + 4 %c %s\n\ + 5 %c %s\n\ + 6 %c %s\n\ + 7 %c %s\n\ + 8 %c %s\n\ + 9 %c %s\n\ + i %c %s\n\ + j %c %s\n\ + k %c %s\n\ + l %c %s\n\ + m %c %s\n\ + n %c %s\n\ +"; + +static const char validChars[] = "123456789iIjJkKlLmMnNbB"; +#endif // !USE_MMUX ] + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video resolution of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoResolutionEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; +#ifdef USE_MMUX // [ USE_MMUX + enum MMUX_RESOLUTION resolution; +#endif // USE_MMUX ] + + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + + setmode = gp_FmbComProperty->setMode; + +#ifdef USE_MMUX // [ USE_MMUX + resolution = MmuxGetCodecSrcResolution(FmbGetCurMmuxHd(), FmbGetCurDevNumOnBoard()); + FmbSetVideoFormat(FmbRsltnMmux2Fmb(resolution), setmode); +#endif // USE_MMUX ] + + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_60p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_60p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_59p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_59p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_50p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_50p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_60i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_60i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_59i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_59i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1920_1080_50i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1920_1080_50i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1440_1080_60i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1440_1080_60i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1440_1080_59i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1440_1080_59i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1440_1080_50i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1440_1080_50i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1280_720_60p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1280_720_60p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1280_720_59p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1280_720_59p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_1280_720_50p], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_1280_720_50p], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_720_480_60i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_720_480_60i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_720_480_59i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_720_480_59i], + g_selectMarks[gp_FmbProperty[setmode].videoRsltn][FMBEnmVideoRsltn_720_576_50i], + g_FmbNameVideoRsltn[FMBEnmVideoRsltn_720_576_50i]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; +#ifndef USE_MMUX // [ !USE_MMUX + enum FMBVideoResolutionEnum resolution_Fmb; +#endif // !USE_MMUX ] + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + FMB_FUNC(FALSE); + return TRUE; +#ifdef USE_MMUX // [ USE_MMUX + case '\n': + OnShow(); + break; +#else // USE_MMUX ] [ !USE_MMUX + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + resolution_Fmb = InputCharacterCode - '1' + FMBEnmVideoRsltn_1920_1080_60p; + FmbSetVideoFormat(resolution_Fmb, setmode); + break; + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + resolution_Fmb = InputCharacterCode - 'i' + FMBEnmVideoRsltn_1280_720_60p; + FmbSetVideoFormat(resolution_Fmb, setmode); + break; + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + resolution_Fmb = InputCharacterCode - 'I' + FMBEnmVideoRsltn_1280_720_60p; + FmbSetVideoFormat(resolution_Fmb, setmode); + break; +#endif // !USE_MMUX ] + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/scr/SetVideoScalerEnc.c b/fmb_player_apl/src/scr/SetVideoScalerEnc.c new file mode 100644 index 0000000..3787837 --- /dev/null +++ b/fmb_player_apl/src/scr/SetVideoScalerEnc.c @@ -0,0 +1,115 @@ +/** +* @brief The function of the video frame rate setting screen of the encoding is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "FmbCmn.h" +#include "Screen.h" +#include "FmbAp.h" + +static const char *_screenStr = "\ +[[[ Encode settings - Sub menu -> Video scaler ]]]\n\ + 'B'<-~~~~~~~~~~~~->Enter\n\ +Select following number. (* is current setting)\n\ + 1 %c Not Use \n\ +"; +static const char validChars[] = "1bB\n"; + +//Event function when key is input. +static BOOL OnKeyHit(char InputCharacterCode); + +//Event function when show the screen. +static BOOL OnShow(void); + +/** +* @brief Initial screen of the video format of the encoding setting. +* @param[out] scr Screen property +* @return None +* @note None +* @attention None +*/ +void InitSetVideoScalerEnc(struct Screen *scr) +{ + FMB_FUNC(TRUE); + scr->displayString = _screenStr; + scr->OnKeyFunc = OnKeyHit; + scr->OnShowFunc = OnShow; + scr->validChars = validChars; + FMB_FUNC(FALSE); +} + +/** +* @brief Screen display event +* @param[in] None +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnShow(void) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + printOut(_screenStr, + g_selectMarks[gp_FmbProperty[setmode].videoScalerEnc][FMBEnmVideoSclEnc_NotUse]); + + SetInputEnabled(TRUE); + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Event function when key is input. +* @param[in] InputCharacterCode Input character-code +* @return TRUE Application execution continuance +* @return FALSE Application end +* @note None +* @attention None +*/ +static BOOL OnKeyHit(char InputCharacterCode) +{ + enum FMBFuncModeEnum setmode; + + FMB_FUNC(TRUE); + + ASSERT_USR(gp_FmbComProperty->setMode == FMBEnmFuncModeEnc, "Function mode is illegal."); + + setmode = gp_FmbComProperty->setMode; + + switch(InputCharacterCode){ + case '1': + gp_FmbProperty[setmode].videoScalerEnc = InputCharacterCode - '1'; + break; + case 'b': + case 'B': + ChangeScreenTo(ScrEnmSetSubMenuEnc); + FMB_FUNC(FALSE); + return TRUE; + default: + //'\n' + ASSERT_USR(InputCharacterCode=='\n', "Invalid character code."); + break; + }; + + ChangeScreenTo(ScrEnmSetSubMenuEnc); + + FMB_FUNC(FALSE); + return TRUE; +} diff --git a/fmb_player_apl/src/util/Debug.c b/fmb_player_apl/src/util/Debug.c new file mode 100644 index 0000000..0c66ab0 --- /dev/null +++ b/fmb_player_apl/src/util/Debug.c @@ -0,0 +1,596 @@ +/** +* @brief The function for debugging is defined. +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include <stdarg.h> +#include <sys/types.h> +#include <linux/unistd.h> +#include <errno.h> +#include <unistd.h> +#include <time.h> +#include <sys/time.h> + +#include "CmdUtil.h" + +struct DbgInfo g_dbg; + +struct FuncTraceProperty{ + const char *escStart; + const char *header; + const char *escEnd; + pid_t threadId; + int callDepth; + int num; +}; + +#define TRAC_MAX_DEV_NUM 8 +static struct FuncTraceProperty _ftraceMain; +static struct FuncTraceProperty _ftraceRecv[TRAC_MAX_DEV_NUM]; +static struct FuncTraceProperty _ftraceRecvStream[TRAC_MAX_DEV_NUM]; +static struct FuncTraceProperty _ftraceSendStream[TRAC_MAX_DEV_NUM]; +static struct FuncTraceProperty _ftraceBoot[TRAC_MAX_DEV_NUM]; + + +pid_t gettid(void) \ +{\ + return syscall(__NR_gettid);\ +} + +inline void logFmbTime(void); + +/** +* @brief Option Format 0x??SSHHCC (SS:Screen Debug, HH:MB86 Debug, CC:Common) +* @param[in] dbgOption Debugging option specified in command line. +* @return None +* @note None +* @attention None +*/ +void InitDbg(char *dbgOption) +{ + int opt = 0; + + sscanf(dbgOption, "%x", &opt); + + if(opt & 0x00000001){ + g_dbg.isFuncTrace = TRUE; + } + else{ + g_dbg.isFuncTrace = FALSE; + } + + if(opt & 0x00000100){ + g_dbg.isRecvTrace = TRUE; + } + else{ + g_dbg.isRecvTrace = FALSE; + } + + if(opt & 0x00000200){ + g_dbg.isSceTrace = TRUE; + } + else{ + g_dbg.isSceTrace = FALSE; + } + + if(opt & 0x00000400){ + g_dbg.isRecvDumpTrace = TRUE; + } + else{ + g_dbg.isRecvDumpTrace = FALSE; + } + + if(opt & 0x00001000){ + g_dbg.isFmbLog = TRUE; + } + else{ + g_dbg.isFmbLog = FALSE; + } + + if(opt & 0x00002000){ + g_dbg.isFmbLogCmd = TRUE; + } + else{ + g_dbg.isFmbLogCmd = FALSE; + } + + if(opt & 0x00100000){ + g_dbg.isScrLog = TRUE; + } + else{ + g_dbg.isScrLog = FALSE; + } + + if(opt & 0x00000010){ + g_dbg.isFmbLogEvent = TRUE; + } + else{ + g_dbg.isFmbLogEvent = FALSE; + } + + if(opt & 0x00000020){ + g_dbg.isScrEventLog = TRUE; + } + else{ + g_dbg.isScrEventLog = FALSE; + } + + g_dbg.isMessageFilterOn = TRUE; + g_dbg.isAV_SYNC_Exit = FALSE; + g_dbg.isTS_PSIZE_Exit = FALSE; + g_dbg.isNotRecMessages = FALSE; + + memset(&_ftraceMain, 0, sizeof(_ftraceMain)); + memset(&_ftraceRecv, 0, sizeof(_ftraceMain)); + memset(&_ftraceRecvStream, 0, sizeof(_ftraceMain)); + memset(&_ftraceSendStream, 0, sizeof(_ftraceMain)); + memset(&_ftraceBoot, 0, sizeof(_ftraceMain)); + InitFuncTraceMain(); +} + +/** +* @brief The function trace function for the main thread is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitFuncTraceMain() +{ + _ftraceMain.escStart = ""; + _ftraceMain.escEnd = ""; + _ftraceMain.header = "MCallTree"; + _ftraceMain.callDepth = 0; + _ftraceMain.threadId = gettid(); + _ftraceMain.num = -1; +} + +/** +* @brief The function trace function for the receive thread is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitFuncTraceRecv(int num) +{ + ASSERT_USR(num < TRAC_MAX_DEV_NUM , "Failed num!"); + _ftraceRecv[num].escStart = "\x1b[33m"; + _ftraceRecv[num].escEnd = "\x1b[m"; + _ftraceRecv[num].header = "RCallTree"; + _ftraceRecv[num].callDepth = 0; + _ftraceRecv[num].threadId = gettid(); + _ftraceRecv[num].num = num; +} + +/** +* @brief The function trace function for the receive thread is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitFuncTraceRecvStream(int num) +{ + ASSERT_USR(num < TRAC_MAX_DEV_NUM , "Failed num!"); + _ftraceRecvStream[num].escStart = "\x1b[34m"; + _ftraceRecvStream[num].escEnd = "\x1b[m"; + _ftraceRecvStream[num].header = "RSCallTree"; + _ftraceRecvStream[num].callDepth = 0; + _ftraceRecvStream[num].threadId = gettid(); + _ftraceRecvStream[num].num = num; +} +/** +* @brief The function trace function for the receive thread is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitFuncTraceSendStream(int num) +{ + ASSERT_USR(num < TRAC_MAX_DEV_NUM , "Failed num!"); + _ftraceSendStream[num].escStart = "\x1b[35m"; + _ftraceSendStream[num].escEnd = "\x1b[m"; + _ftraceSendStream[num].header = "SSCallTree"; + _ftraceSendStream[num].callDepth = 0; + _ftraceSendStream[num].threadId = gettid(); + _ftraceSendStream[num].num = num; +} +/** +* @brief The function trace function for the boot thread is initialized. +* @param[in] None +* @return None +* @note None +* @attention None +*/ +void InitFuncTraceBoot(int num) +{ + ASSERT_USR(num < TRAC_MAX_DEV_NUM , "Failed num!"); + _ftraceBoot[num].escStart = "\x1b[36m"; + _ftraceBoot[num].escEnd = "\x1b[m"; + _ftraceBoot[num].header = "SSCallTree"; + _ftraceBoot[num].callDepth = 0; + _ftraceBoot[num].threadId = gettid(); + _ftraceBoot[num].num = num; +} + +/** +* @brief The attribute of the trace of the function of a call thread is acquired. +* @param[in] None +* @return The attribute of the trace of the function of the thread is returned. +* @note None +* @attention None +*/ +static struct FuncTraceProperty *GetFuncTraceProperty(void) +{ + pid_t threadId; + int i; + + threadId = gettid(); + + if(_ftraceMain.threadId == threadId){ + return &_ftraceMain; + } + for (i=0;i<TRAC_MAX_DEV_NUM; i++) { + if(_ftraceRecv[i].threadId == threadId){ + return &_ftraceRecv[i]; + } + } + for (i=0;i<TRAC_MAX_DEV_NUM; i++) { + if(_ftraceRecvStream[i].threadId == threadId){ + return &_ftraceRecvStream[i]; + } + } + for (i=0;i<TRAC_MAX_DEV_NUM; i++) { + if(_ftraceSendStream[i].threadId == threadId){ + return &_ftraceSendStream[i]; + } + } + for (i=0;i<TRAC_MAX_DEV_NUM; i++) { + if(_ftraceBoot[i].threadId == threadId){ + return &_ftraceBoot[i]; + } + } + + ASSERT_USR(FALSE, "Unknown thread"); + + return NULL; +} + +/** +* @brief The depth of the call of the function trace is set. +* @param[in] callDepthMain Depth of Main thread +* @param[in] callDepthRecv Depth of Recive thread +* @param[in] callDepthRecSt Depth of Recive Stream thread +* @param[in] callDepthSndSt Depth of Send Stream thread +* @return None +* @note None +* @attention None +*/ +void SetFuncTraceCallDepth(int num, int callDepthMain, int callDepthRecv, + int callDepthRecSt, int callDepthSndSt, int callDepthBoot) +{ + ASSERT_USR(num < TRAC_MAX_DEV_NUM , "Failed num!"); + _ftraceMain.callDepth = callDepthMain; + _ftraceRecv[num].callDepth = callDepthRecv; + _ftraceRecvStream[num].callDepth = callDepthRecSt; + _ftraceSendStream[num].callDepth = callDepthSndSt; + _ftraceBoot[num].callDepth = callDepthBoot; +} + +/** +* @brief The function trace is output to the standard error output. +* @param[in] isIn TRUE:Function in. FALSE:Function out. +* @param[in] fileName Source file name +* @param[in] funcName Function name +* @return None +* @note None +* @attention None +*/ +void TraceFunc( BOOL isIn, + const char *fileName, + const char *funcName) +{ + int i; + struct FuncTraceProperty *prop; + + prop = GetFuncTraceProperty(); + + if(isIn){ + EnterEx(); + + logFmbTime(); + + fprintOut(stderr, prop->escStart); + + if (prop->num != -1) { + fprintOut(stderr, "%s_%d\t", prop->header, prop->num); + } + else { + fprintOut(stderr, "%s\t", prop->header); + } + for(i = 0; i < prop->callDepth; i ++){ + fputs("|", stderr); + } + + fprintOut(stderr, "+%s\t%s%s\n", fileName, funcName, prop->escEnd); + ExitEx(); + } + + if(isIn){ + prop->callDepth ++; + } + else{ + prop->callDepth --; + } +} + +/** +* @brief Reception trace +* @param[in] format, ... Format for printf +* @return None +* @note None +* @attention None +*/ +void TraceRecv(int num, char *format, ...) +{ + va_list ap; + + if(g_dbg.isRecvTrace){ + EnterEx(); + + logFmbTime(); + + fprintOut(stderr, _ftraceRecv[num].escStart); + va_start( ap, format); /* pgr0039 */ + vfprintOut( stderr, format, ap ); + va_end(ap); + fprintOut(stderr, _ftraceRecv[num].escEnd); + fprintOut(stderr, "\n"); + + ExitEx(); + } + +} + +/** +* @brief Reception trace. The specified buffer is dumped. +* @param[in] head Trace header string. +* @param[in] rcvs[] Buffer address. +* @param[in] size Size of buffer. +* @return None +* @note None +* @attention None +*/ +void TraceRecvDump(int num, char *head, unsigned short rcvs[], int size) +{ + int i; + + if(g_dbg.isRecvDumpTrace){ + EnterEx(); + + logFmbTime(); + + fprintOut(stderr, "%s%s", _ftraceRecv[num].escStart, head); + for(i = 0; i < (size >>1); i++){ + fprintOut(stderr, "%04x\t", rcvs[i]); + } + fprintOut(stderr, _ftraceRecv[num].escEnd); + fprintOut(stderr, "\n"); + + ExitEx(); + } +} + +/** +* @brief Log for the MB86 module. +* @param[in] format, ... Format for printf(). +* @return None +* @note None +* @attention None +*/ +void LogFmb(char *format, ...) +{ + va_list ap; + struct FuncTraceProperty *prop; + + + if(g_dbg.isFmbLog){ + prop = GetFuncTraceProperty(); + EnterEx(); + + logFmbTime(); + + fprintOut(stderr, prop->escStart); + + va_start( ap, format); /* pgr0039 */ + + if (prop->num != -1) { + fprintOut( stderr, "FmbTrace_%d\t", prop->num); + } + else { + fprintOut( stderr, "FmbTrace\t"); + } + vfprintOut( stderr, format, ap ); + fprintOut(stderr, prop->escEnd); + fprintOut( stderr, "\n"); + + va_end(ap); + ExitEx(); + } + +} + +/** +* @brief Log for MB86 command. +* @param[in] format, ... Format for printf(). +* @return None +* @note None +* @attention None +*/ +void LogFmbCmd(char *format, ...) +{ + va_list ap; + + if(g_dbg.isFmbLogCmd){ + EnterEx(); + + logFmbTime(); + + va_start( ap, format); /* pgr0039 */ + + fprintOut( stderr, "FmbCmd\t"); + vfprintOut( stderr, format, ap ); + fprintOut( stderr, "\n"); + + va_end(ap); + ExitEx(); + } + +} + +/** +* @brief Trace for scenario. +* @param[in] format, ... Format for printf(). +* @return None +* @note None +* @attention None +*/ +void TraceSce(char *format, ...) +{ + va_list ap; + + if(g_dbg.isSceTrace){ + EnterEx(); + + logFmbTime(); + + va_start( ap, format); /* pgr0039 */ + + fprintOut( stderr, "FmbSce\t"); + vfprintOut( stderr, format, ap ); + fprintOut( stderr, "\n"); + + va_end(ap); + ExitEx(); + } + +} + +/** +* @brief Log for screen modules. +* @param[in] format, ... Format for printf(). +* @return None +* @note None +* @attention None +*/ +void LogScr(char *format, ...) +{ + va_list ap; + + if(g_dbg.isScrLog){ + EnterEx(); + + logFmbTime(); + + va_start( ap, format); /* pgr0039 */ + fprintOut( stderr, "SCRN\t"); + vfprintOut( stderr, format, ap ); + fprintOut( stderr, "\n"); + va_end(ap); + ExitEx(); + } +} + +/** +* @brief Log for screen modules event. +* @param[in] format, ... Format for printf(). +* @return None +* @note None +* @attention None +*/ +void LogScrEvent(char *format, ...) +{ + va_list ap; + + if(g_dbg.isScrEventLog){ + EnterEx(); + + logFmbTime(); + + va_start( ap, format); /* pgr0039 */ + fprintOut( stderr, "ScreenEvent\t"); + vfprintOut( stderr, format, ap ); + fprintOut( stderr, "\n"); + va_end(ap); + ExitEx(); + } +} + +/** +* @brief Log for MB86 event. +* @param[in] evnt Array of event information. +* @return num Number of event information. +* @note None +* @attention None +*/ +void LogFmbEvent(int evnt[], int num) +{ + int i; + + if(!g_dbg.isFmbLogEvent){ + return; + } + + EnterEx(); + + logFmbTime(); + + fprintOut( stderr, "FmbEvent"); + for(i = 0; i < num; i++){ + fprintOut( stderr, "\t%d", evnt[i]); + } + fprintOut( stderr, "\n"); + + ExitEx(); +} +/** +* @brief Log for Time stamp. +* @param[in] None. +* @return None. +* @note None +* @attention None +*/ +inline void logFmbTime(void) +{ + //time_t t=0; + int res; + struct timeval tv={0}; + struct tm *tm_time; + + res = gettimeofday(&tv,NULL); + if(res!=0)return; + tm_time = localtime(&tv.tv_sec); + + fprintOut(stderr,"%d-%02d-%02d %02d:%02d:%02d.%06d ", + tm_time->tm_year+1900, + tm_time->tm_mon+1, + tm_time->tm_mday, + tm_time->tm_hour, + tm_time->tm_min, + tm_time->tm_sec, + (int)tv.tv_usec + ); + +} diff --git a/fmb_player_apl/src/util/Utility.c b/fmb_player_apl/src/util/Utility.c new file mode 100644 index 0000000..5edc18d --- /dev/null +++ b/fmb_player_apl/src/util/Utility.c @@ -0,0 +1,324 @@ +/** +* @brief +* @since 2009/01/08 +* @note None +* @attention None +* <B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B> +*/ + +/* + * 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. + */ + +#include "CmdUtil.h" +#include <stdlib.h> +#include <limits.h> +#include <errno.h> +#include <pthread.h> +#include <stdarg.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <fcntl.h> +#include <sys/stat.h> + +static FILE* _fp = NULL; +static FILE* _fp_g = NULL; + +static pthread_mutex_t _mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP ; + +/** +* @brief Rounds up below the decimal point, and converts to the integer type. +* @param[in] value Value that contains fraction part. +* @return Integer value. +* @note None +* @attention None +*/ +unsigned int RoundUpDouble(double value) +{ + unsigned int intVal; + double doubleVal; + + FMB_FUNC(TRUE); + + intVal = (unsigned int)value; + doubleVal = (double)intVal; + if(doubleVal < value){ + intVal ++; + } + + FMB_FUNC(FALSE); + return intVal; +} + +/** +* @brief Converted to the integer of the sign none from the character string. +* @param[in] str Character string of conversion. +* @return Conversion result. +* @note None +* @attention None +*/ +int StrToUnsignedInt(char *str) +{ + int base = 0; + char *endptr; + long val; + + FMB_FUNC(TRUE); + + errno = 0; /* To distinguish success/failure after call */ + val = strtol(str, &endptr, base); + + /* Check for various possible errors */ + if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) + || (errno != 0 && val == 0)) { + return -1; + } + + if (endptr == str) { + return -1; + } + + //Whether everything is converted is checked. + if (*endptr != '\0'){ + return -1; + } + + FMB_FUNC(FALSE); + return val; /* pgr0539 */ +} + +/** +* @brief Converted to the long long integer of the sign none from the character string. +* @param[in] str Character string of conversion. +* @return Conversion result. +* @note None +* @attention None +*/ +__off64_t StrToOff64(char *str) +{ + int base = 0; + char *endptr; + __off64_t val; + + FMB_FUNC(TRUE); + + errno = 0; /* To distinguish success/failure after call */ + val = (__off64_t)strtoull(str, &endptr, base); + + /* Check for various possible errors */ + if ((errno == ERANGE) || (errno != 0 && val == 0)) { + return -1; + } + + if (endptr == str) { + return -1; + } + + //Whether everything is converted is checked. + if (*endptr != '\0'){ + return -1; + } + + FMB_FUNC(FALSE); + return val; +} + + +/** +* @brief Lock the mutex for thread. +* @param[in] none +* @return none +* @note None +* @attention None +*/ +void EnterEx(void) +{ + int rc; + rc = pthread_mutex_lock(&_mutex); + ASSERT_SYS(rc == 0, "pthread_mutex_lock"); +} + +/** +* @brief Unlock the mutex for thread. +* @param[in] none +* @return none +* @note None +* @attention None +*/ +void ExitEx(void) +{ + int rc; + + rc = pthread_mutex_unlock(&_mutex); + + ASSERT_SYS(rc == 0, "pthread_mutex_unlock"); +} + +/** +* @brief Open a Log file. +* @param[in] filepth file path name +* @return TRUE Normal end +* @return FALSE Not Save +* @note None +* @attention None +*/ +BOOL StartLogFile(char* filepath ,char* att) +{ + + char* err_cause; + + FMB_FUNC(TRUE); + + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + + _fp = fopen(filepath , att); + + if(_fp == NULL){ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",filepath ,errno, err_cause); + FMB_FUNC(FALSE); + return FALSE; + } + + FMB_FUNC(FALSE); + return TRUE; +} +/** +* @brief Close a Log file. +* @param[in] none. +* @return TRUE Normal end +* @return FALSE Abnormal end +* @note None +* @attention None +*/ +BOOL StopLogFile(void) +{ + + FMB_FUNC(TRUE); + + if(_fp != NULL){ + fclose(_fp); + _fp = NULL; + } + + FMB_FUNC(FALSE); + return TRUE; +} + +/** +* @brief Open a Gop file. +* @param[in] filepth file path name +* @return TRUE Normal end +* @return FALSE Not Save +* @note None +* @attention None +*/ +BOOL StartGopFile(char* filepath ,char* att) +{ + + char* err_cause; + + FMB_FUNC(TRUE); + + if(_fp_g != NULL){ + fclose(_fp_g); + _fp_g = NULL; + } + + _fp_g = fopen(filepath , att); + + if(_fp_g == NULL){ + err_cause = strerror(errno); + LogFmb("%s stat info:(%d)-%s",filepath ,errno, err_cause); + FMB_FUNC(FALSE); + return FALSE; + } + + FMB_FUNC(FALSE); + return TRUE; +} +/** +* @brief Close a Gop file. +* @param[in] none. +* @return TRUE Normal end +* @return FALSE Abnormal end +* @note None +* @attention None +*/ +BOOL StopGopFile(void) +{ + + FMB_FUNC(TRUE); + + if(_fp_g != NULL){ + fclose(_fp_g); + _fp_g = NULL; + } + + FMB_FUNC(FALSE); + return TRUE; +} + +void fprintOut( FILE *stream,const char *formatPtr, ...) +{ + va_list arg_list; + va_start( arg_list, formatPtr ); /* pgr0039 */ + vfprintf(stream,formatPtr, arg_list ); + va_end( arg_list ); + + if( _fp != NULL ){ + va_start( arg_list, formatPtr ); /* pgr0039 */ + vfprintf(_fp, formatPtr, arg_list ); + va_end( arg_list ); + } + + return ; +} + +void gprintOut( const char *formatPtr, ...) +{ + va_list arg_list; + + if( _fp_g != NULL ){ + va_start( arg_list, formatPtr ); /* pgr0039 */ + vfprintf(_fp_g, formatPtr, arg_list ); + va_end( arg_list ); + } + + return ; +} + +void printOut( const char *formatPtr, ...) +{ + va_list arg_list; + va_start( arg_list, formatPtr ); /* pgr0039 */ + vprintf(formatPtr, arg_list ); + va_end( arg_list ); + + if( _fp != NULL ){ + va_start( arg_list, formatPtr ); /* pgr0039 */ + vfprintf(_fp, formatPtr, arg_list ); + va_end( arg_list ); + } + + return ; +} + +void vfprintOut (FILE *stream, __const char *formatPtr,_G_va_list arg_list) +{ + vfprintf(stream,formatPtr, arg_list ); + + if( _fp != NULL ){ + vfprintf(_fp, formatPtr, arg_list ); + } + + return ; + +} diff --git a/hdcapture b/hdcapture new file mode 100755 index 0000000..4e30c30 --- /dev/null +++ b/hdcapture @@ -0,0 +1,132 @@ +#!/bin/sh +#----------------------------------------------------------- +# S99h55fmb --- Restart script for the MB86H55 driver +#----------------------------------------------------------- + +KERN_RELEASE=`uname -r` +LIBDIR="/lib/modules/$KERN_RELEASE/$MDIR" +FIRM_PATH="/usr/local/etc/mb86h55.bin" + +module="h55fmb" +device_num="0 1 2 3 4 5 6 7" +device="/dev/h55fmb" + +mmux_module="media_mux" +mmux_device_num="0 1" +mmux_device="/dev/media_mux" + + +# +# Check root account +# +uid=`id | sed 's/uid=//' | sed 's/(.*//'` +if [ $uid != 0 ]; then + echo "ERROR: You are not root.!!" + exit +fi + + +#........................................................... + +# +# Unload old driver module +# +grep $module /proc/modules > /dev/null +if [ $? = 0 ];then + echo -n "Unloading old MB86H55 device driver... " + /sbin/rmmod $module + echo "done." +fi + +# +# Remove old device special files +# +for i in $device_num; do + rm -f $device$i + #echo $device$i +done + +# +# Load new driver module +# +if [ -e $LIBDIR/$module.ko ]; then + echo -n "Loading new MB86H55 device driver... " + /sbin/insmod $LIBDIR/$module.ko +elif [ -e ./$module.ko ]; then + echo -n "Loading new MB86H55 device driver... " + /sbin/insmod ./$module.ko +else + echo "ERROR: Can't find $LIBDIR/$module.ko" + exit +fi +# /sbin/insmod $LIBDIR/$module.ko msg_lvl=1023 +# /sbin/insmod $LIBDIR/$module.ko msg_lvl=511 +echo "done." + +# +# Get major number from /proc/devices +# +major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices) + +# +# Create device special files +# + +for i in $device_num; do + if [ ! -e $device$i ];then + mknod $device$i c $major $i + chmod 666 $device$i + fi +done + + +#........................................................... + +# +# Unload old driver module +# +grep $mmux_module /proc/modules > /dev/null +if [ $? = 0 ];then + echo -n "Unloading old media_mux device driver... " + /sbin/rmmod $mmux_module + echo "done." +fi + +# +# Remove old device special files +# +for i in $mmux_device_num; do + rm -f $mmux_device$i + #echo $mmux_device$i +done + +# +# Load new driver module +# +echo -n "Loading new media_mux device driver... " +if [ -e $LIBDIR/$mmux_module.ko ];then + /sbin/insmod $LIBDIR/$mmux_module.ko + echo "done." +elif [ -e ./$mmux_module.ko ];then + /sbin/insmod ./$mmux_module.ko + echo "done." +else + echo "ERROR: Cat'n find $mmux_module.ko !" + exit +fi + +# +# Get major number from /proc/devices +# +major=$(awk "\$2==\"$mmux_module\" {print \$1}" /proc/devices) + +# +# Create device special files +# +for i in $mmux_device_num; do + if [ ! -e $mmux_device$i ];then + mknod $mmux_device$i c $major $i + chmod 666 $mmux_device$i + fi +done + diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..a9ede55 --- /dev/null +++ b/install.sh @@ -0,0 +1,60 @@ +#!/bin/sh +#------------------------------------------------------------------ +# install.sh --- Instal script for the MB86H55 reffernce software +#------------------------------------------------------------------ + +APL_INST_DIR="/usr/local/bin" +FIRM_INST_DIR="/usr/local/etc" +FIRM_NAME="mb86h56.bin" +module="hdcapture" +exe="hdcapture" + +echo "Installation start." + +# +# Make & install fmb_player_apl +# +echo -n "Making fmb_player_apl... " +(cd fmb_player_apl/Release; make clean > /dev/null; make > /dev/null 2>&1) +echo "done." + +echo -n "Installing fmb_player_apl... " +(cd fmb_player_apl/Release; \cp -p fmb_player_apl $APL_INST_DIR/$exe) +echo "done." + +echo -n "Installing firm... " +(cd firm; chmod 644 $FIRM_NAME; \cp -p $FIRM_NAME $FIRM_INST_DIR) +echo "done." + +echo -n "Making fmb_driver... " +(cd fmb_driver; make clean > /dev/null; make > /dev/null 2>&1; make install >/dev/null) +echo "done." + +echo -n "Making mmux_driver... " +(cd mmux_driver; make clean > /dev/null; make > /dev/null 2>&1; make install >/dev/null) +echo "done." + +# +# Make & install fmb_driver +# +#(cd fmb_driver; chmod 744 install.sh; ./install.sh) +(cp $module /etc/init.d/; chmod 755 /etc/init.d/$module) + +#if [ -e /etc/init.d/$module ] ; then +# cd /etc/rc3.d/ +# ln -s ../init.d/$module S99$module +#else +# echo "?" +#fi + +# +# Edit /etc/rc.d/rc.local +# +grep $module /etc/rc.local > /dev/null +if [ $? != 0 ];then + echo "/etc/init.d/$module" >> /etc/rc.local +fi + +/etc/init.d/$module + +echo "Installation completed." diff --git a/mmux_driver/.cproject b/mmux_driver/.cproject new file mode 100644 index 0000000..231012e --- /dev/null +++ b/mmux_driver/.cproject @@ -0,0 +1,317 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?fileVersion 4.0.0?> + +<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> +<storageModule moduleId="org.eclipse.cdt.core.settings"> +<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1885650886"> +<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1885650886" moduleId="org.eclipse.cdt.core.settings" name="Default"> +<externalSettings/> +<extensions> +<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> +<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> +</extensions> +</storageModule> +<storageModule moduleId="scannerConfiguration"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.debug.491753243;cdt.managedbuild.config.gnu.exe.debug.491753243.;cdt.managedbuild.tool.gnu.c.compiler.exe.debug.48553586;cdt.managedbuild.tool.gnu.c.compiler.input.180307762"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.2084776873;cdt.managedbuild.config.gnu.exe.release.2084776873.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1614106589;cdt.managedbuild.tool.gnu.c.compiler.input.254965440"> +<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="makefileGenerator"> +<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> +<buildOutputProvider> +<openAction enabled="true" filePath=""/> +<parser enabled="true"/> +</buildOutputProvider> +<scannerInfoProvider id="specsFile"> +<runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> +<parser enabled="true"/> +</scannerInfoProvider> +</profile> +</scannerConfigBuildInfo> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<configuration artifactName="mmux_driver" buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.1885650886" name="Default" parent="org.eclipse.cdt.build.core.emptycfg"> +<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1885650886.592829962" name="/" resourcePath=""> +<toolChain id="cdt.managedbuild.toolchain.gnu.base.1344217087" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base"> +<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1435620640" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> +<builder id="cdt.managedbuild.target.gnu.builder.base.738175616" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/> +<tool id="cdt.managedbuild.tool.gnu.archiver.base.1129025932" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/> +<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.255162938" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/> +<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1063771309" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"> +<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.756788579" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> +</tool> +<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1094267371" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"> +<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.2021421216" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> +<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> +<additionalInput kind="additionalinput" paths="$(LIBS)"/> +</inputType> +</tool> +<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1358083165" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/> +<tool id="cdt.managedbuild.tool.gnu.assembler.base.1127020130" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"> +<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1006480189" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> +</tool> +</toolChain> +</folderInfo> +</configuration> +</storageModule> +<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> +<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/> +<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> +<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"> +<buildTargets> +<target name="modules" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildTarget>modules</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder"> +<buildCommand>make</buildCommand> +<buildTarget>clean</buildTarget> +<stopOnError>true</stopOnError> +<useDefaultCommand>true</useDefaultCommand> +<runAllBuilders>true</runAllBuilders> +</target> +</buildTargets> +</storageModule> +</cconfiguration> +</storageModule> +<storageModule moduleId="cdtBuildSystem" version="4.0.0"> +<project id="mmux_driver.null.1870095234" name="mmux_driver"/> +</storageModule> +</cproject> diff --git a/mmux_driver/.project b/mmux_driver/.project new file mode 100644 index 0000000..ce99a3d --- /dev/null +++ b/mmux_driver/.project @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>mmux_driver</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <triggers>clean,full,incremental,</triggers> + <arguments> + <dictionary> + <key>?name?</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.append_environment</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.autoBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildArguments</key> + <value></value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.buildCommand</key> + <value>make</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.cleanBuildTarget</key> + <value>clean</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.contents</key> + <value>org.eclipse.cdt.make.core.activeConfigSettings</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableAutoBuild</key> + <value>false</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableCleanBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.enableFullBuild</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.fullBuildTarget</key> + <value>all</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.stopOnError</key> + <value>true</value> + </dictionary> + <dictionary> + <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key> + <value>true</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/mmux_driver/Makefile b/mmux_driver/Makefile new file mode 100644 index 0000000..9eb669a --- /dev/null +++ b/mmux_driver/Makefile @@ -0,0 +1,33 @@ + +DEVICENAME=media_mux + +$(DEVICENAME)-objs := mmux.o + +KERN_RELEASE := $(shell uname -r) +DEST := /lib/modules/$(KERN_RELEASE)/$(MDIR) + + +ifneq ($(KERNELRELEASE),) + obj-m := $(DEVICENAME).o + +else + + KERNELDIR ?= /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) + + inst-m := $(DEVICENAME).ko + +modules: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +install:: +# strip --strip-debug $(inst-m) + -su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); /sbin/depmod -a" + +uninstall:: + -su -c "rm $(DEST)/$(inst-m); /sbin/depmod -a" + +endif + +clean: + $(RM) -r *.o *.ko *.mod.c .modules.* .*.cmd .tmp_versions diff --git a/mmux_driver/media-mux b/mmux_driver/media-mux new file mode 100755 index 0000000..d66508a --- /dev/null +++ b/mmux_driver/media-mux @@ -0,0 +1,71 @@ +#!/bin/sh + +module="media_mux" + +device_num="0 1" +device="/dev/media_mux" + + +KERN_RELEASE=`uname -r` +LIBDIR="/lib/modules/$KERN_RELEASE/$MDIR" + +# +# Check root account +# +uid=`id | sed 's/uid=//' | sed 's/(.*//'` +if [ $uid != 0 ]; then + echo "ERROR: You are not root.!!" + exit +fi + +# +# Unload old driver module +# +grep $module /proc/modules > /dev/null +if [ $? = 0 ];then + echo -n "Unloading old media_mux device driver... " + /sbin/rmmod $module + echo "done." +fi + +# +# Remove old device special files +# +for i in $device_num; do + rm -f $device$i + #echo $device$i +done + +# +# Load new driver module +# +echo -n "Loading new media_mux device driver... " +if [ -e ./$module.ko ];then + echo -n "(./$module.ko) " + /sbin/insmod ./$module.ko + echo "done." +elif [ -e $LIBDIR/$module.ko ];then + echo -n "($LIBDIR/$module.ko) " + /sbin/insmod $LIBDIR/$module.ko + echo "done." +else + echo + echo "ERROR: Cat'n find $module.ko !" + exit +fi + +# +# Get major number from /proc/devices +# +major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices) + +# +# Create device special files +# + +for i in $device_num; do + if [ ! -e $device$i ];then + mknod $device$i c $major $i + chmod 666 $device$i + fi +done diff --git a/mmux_driver/mmux.c b/mmux_driver/mmux.c new file mode 100644 index 0000000..cec7fa1 --- /dev/null +++ b/mmux_driver/mmux.c @@ -0,0 +1,604 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright (C) 2009 ~ 2010 * + *===============================================*/ +/*-----------------------------------------------* + $Author: Kenneth $ + $Date$ + $Revision$ + *-----------------------------------------------*/ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/cdev.h> +#include <linux/pci.h> +#include <linux/fs.h> +#include <linux/ioport.h> +#include <asm/uaccess.h> +#include <linux/spinlock.h> + +#include "mmux.h" + +#define MMUX_DRIVER_NAME "media_mux" +//KERN_DEBUG KERN_WARNING +#define MSG(fmt, arg...) printk(KERN_DEBUG MMUX_DRIVER_NAME":" fmt"\n", ##arg) +#define ERR(fmt, arg...) printk(KERN_WARNING MMUX_DRIVER_NAME":" fmt"\n", ##arg) + + +#define MMUX_CARD_MAX 2 +#define MMXU_VERSION "0.0.1.1" + +#define MMUX_VENDOR_ID 0x1172 +#define MMUX_DEVICE_ID 0x0008 + +#define MMUX_CPLD_VERSION 0x0304C008 +#define MMUX_FPGA_VERSION 0x0304E008 +#define MMUX_MCU_VERSION 0x8051A101 + +#define REGISTER_REGION_NO 0 + + +#define REG_FG_READ 0x01 +#define REG_FG_WRITE 0x02 + + + +struct tMmux_private_data { + struct pci_dev* pDev; + struct cdev cdev; + unsigned int input_ch_total; + unsigned int output_ch_total; + unsigned int codec_chip_total; + int minor; + unsigned int reg_base; + unsigned int reg_length; + spinlock_t lock; +}; + + + +struct tag_MMUX_REG { + unsigned long offset; + unsigned long mask; + unsigned long shift; + unsigned long fg; //[1:0] w|r. +}; + + + +//===============================================================================// +static const struct tag_MMUX_REG gt_Reg_A[MMUX_INFO_MAX] = { + {0x00, 0x00000003, 0, REG_FG_READ|REG_FG_WRITE}, //CODEC_0_SRC, + {0x04, 0x00000003, 0, REG_FG_READ|REG_FG_WRITE}, //CODEC_1_SRC, + {0x08, 0x00000003, 0, REG_FG_READ|REG_FG_WRITE}, //CODEC_2_SRC, + {0x0C, 0x00000003, 0, REG_FG_READ|REG_FG_WRITE}, //CODEC_3_SRC, + {0x10, 0x00000007, 0, REG_FG_READ|REG_FG_WRITE}, //VIDEO_OUT_MODE, + {0x60, 0x0000001F, 0, REG_FG_READ }, //CODEC_0_SRC_RESOLUTION, + {0x64, 0x0000001F, 0, REG_FG_READ }, //CODEC_1_SRC_RESOLUTION, + {0x68, 0x0000001F, 0, REG_FG_READ }, //CODEC_2_SRC_RESOLUTION, + {0x6C, 0x0000001F, 0, REG_FG_READ }, //CODEC_3_SRC_RESOLUTION, + {0x60, 0x00000100, 8, REG_FG_READ }, //CODEC_0_SRC_HOTPLUG, + {0x64, 0x00000100, 8, REG_FG_READ }, //CODEC_1_SRC_HOTPLUG, + {0x68, 0x00000100, 8, REG_FG_READ }, //CODEC_2_SRC_HOTPLUG, + {0x6C, 0x00000100, 8, REG_FG_READ }, //CODEC_3_SRC_HOTPLUG, + {0x60, 0x00001000, 12, REG_FG_READ }, //CODEC_0_SRC_SCDT, + {0x64, 0x00001000, 12, REG_FG_READ }, //CODEC_1_SRC_SCDT, + {0x68, 0x00001000, 12, REG_FG_READ }, //CODEC_2_SRC_SCDT, + {0x6C, 0x00001000, 12, REG_FG_READ }, //CODEC_3_SRC_SCDT, + {0x60, 0x00010000, 12, REG_FG_READ }, //CODEC_0_SRC_DISABLE, + {0x64, 0x00010000, 12, REG_FG_READ }, //CODEC_1_SRC_DISABLE, + {0x68, 0x00010000, 12, REG_FG_READ }, //CODEC_2_SRC_DISABLE, + {0x6C, 0x00010000, 12, REG_FG_READ }, //CODEC_3_SRC_DISABLE, + {0x70, 0x0000001F, 0, REG_FG_WRITE}, //VIDEO_OUT_RESOLUTION, + + {0xF0, 0xFFFFFFFF, 0, REG_FG_READ }, //CPLD_VER, + {0xF4, 0xFFFFFFFF, 0, REG_FG_READ }, //FPGA_VER, + {0xEC, 0xFFFFFFFF, 0, REG_FG_READ }, //MCU_VER, + +}; + +static const struct tag_MMUX_REG gtc_IsBusy = { + 0xF8, 0x01, 0x0 +}; +static const struct tag_MMUX_REG gtc_Refresh = { + 0xFC, 0xFF, 0x0 +}; + +static const int gicRetryNum = 5; + +static int giMmux_card_num = 0; + + +//===============================================================================// +struct tMmux_private_data *gptPrivate_data[MMUX_CARD_MAX]; + +static dev_t gtMmux_dev_no; + + + +//===============================================================================// +static int Mmux_InterfaceIsBusy(struct tMmux_private_data *ptPrivate) +{ + unsigned long data; + + data = inl(ptPrivate->reg_base + gtc_IsBusy.offset); + data = (data & gtc_IsBusy.mask) >> gtc_IsBusy.shift; + //MSG("IsBusy: offset=0x%lx, data=0x%lx", + // gtc_IsBusy.offset, data); + + return (data == 0 ? 0 : 1); +} + +static int Mmux_WaitInterfaceFree(struct tMmux_private_data *ptPrivate) +{ + int i; + int ret = -EBUSY; + + for (i=0; i<gicRetryNum; i++) + { + if (!Mmux_InterfaceIsBusy(ptPrivate)) { + MSG("WaitInterfaceFree: (%d).", i); + ret = 0; + break; + } + } + + return ret; +} + +static int Mmux_Refresh(struct tMmux_private_data *ptPrivate, unsigned long offset) +{ + int ret = 0; + unsigned long data; + + //MSG("Refresh: start"); + MSG("Refresh: offset=0x%lx", offset); + + if (Mmux_InterfaceIsBusy(ptPrivate)) { + ret = -EBUSY; + } + else { + data = (offset & gtc_Refresh.mask) >> gtc_Refresh.shift; + outl(data, ptPrivate->reg_base + gtc_Refresh.offset); + ret = Mmux_WaitInterfaceFree(ptPrivate); + } + + MSG("Refresh: end(%d)", ret); + + return ret; +} + +//===============================================================================// +static int Mmux_IoGetReg(struct tMmux_private_data *ptPrivate, unsigned long arg ) +{ + struct MMUX_REG_INFO reg_info; + + + MSG("IoGetReg: start"); + + if (copy_from_user(®_info, (void*)arg, sizeof(struct MMUX_REG_INFO))) { + ERR( "Failed in a copy from user's area."); + return -EFAULT; + } + + if ((ptPrivate->reg_length >>2 <<2) < reg_info.reg_add || + (reg_info.reg_add >>2 <<2) != reg_info.reg_add ) { + ERR("Failed reg_add:0x%lx", reg_info.reg_add); + return -EINVAL; + } + + if (Mmux_Refresh(ptPrivate, reg_info.reg_add) != 0) { + return -EBUSY; + } + + reg_info.reg_data = inl(ptPrivate->reg_base + reg_info.reg_add); + MSG("reg_base: 0x%x, offset: 0x%lx, data:0x%lx", + ptPrivate->reg_base, reg_info.reg_add, reg_info.reg_data); + + if ( copy_to_user((void*)arg, ®_info, sizeof(struct MMUX_REG_INFO)) ) { + ERR("Failed in a copy to user's area."); + return -EFAULT; + } + + MSG("IoGetReg: success"); + + + return 0; +} + +static int Mmux_IoSetReg(struct tMmux_private_data *ptPrivate, unsigned long arg ) +{ + struct MMUX_REG_INFO reg_info; + int ret; + + MSG("IoSetReg: start"); + + ret = Mmux_WaitInterfaceFree(ptPrivate); + if (ret != 0) { + return ret; + } + + if (copy_from_user(®_info, (void*)arg, sizeof(struct MMUX_REG_INFO))) { + ERR( "Failed in a copy from user's area."); + return -EFAULT; + } + + if ((ptPrivate->reg_length >>2 <<2) < reg_info.reg_add || + (reg_info.reg_add >>2 <<2) != reg_info.reg_add ) { + ERR("Failed reg_add:0x%lx", reg_info.reg_add); + return -EINVAL; + } + + outl(reg_info.reg_data, ptPrivate->reg_base + reg_info.reg_add); + MSG("reg_base: 0x%x, offset: 0x%lx, data:0x%lx", + ptPrivate->reg_base, reg_info.reg_add, reg_info.reg_data); + + MSG("IoSetReg: success"); + + + return 0; +} + +static int Mmux_IoGetParam(struct tMmux_private_data *ptPrivate, unsigned long arg) +{ + struct MMUX_PARAM_INFO param_info; + unsigned long offset; + unsigned long data; + int ret; + + MSG("IoGetParam: start"); + + if (copy_from_user(¶m_info, (void*)arg, sizeof(struct MMUX_PARAM_INFO))) { + ERR( "Failed in a copy from user's area."); + return -EFAULT; + } + + if (param_info.id < 0 || MMUX_INFO_MAX <= param_info.id) { + ERR( "Failed parameter id!"); + return -EFAULT; + } + + if (!(gt_Reg_A[param_info.id ].fg | REG_FG_READ)) { + ERR( "Parameter Can't read!"); + return -EFAULT; + } + + offset = gt_Reg_A[param_info.id].offset; + + ret = Mmux_Refresh(ptPrivate, offset); + if (ret != 0) { + return ret; + } + + data = inl(ptPrivate->reg_base + offset); + MSG("id:0x%x data: 0x%lx, mask: 0x%lx, shift:0x%lx", + param_info.id, data, gt_Reg_A[param_info.id].mask, gt_Reg_A[param_info.id].shift); + param_info.data = (data & gt_Reg_A[param_info.id].mask) >> gt_Reg_A[param_info.id].shift; + MSG("reg_base: 0x%x, offset: 0x%lx, data:0x%lx", + ptPrivate->reg_base, offset, param_info.data); + + if ( copy_to_user((void*)arg, ¶m_info, sizeof(struct MMUX_PARAM_INFO)) ) { + ERR("Failed in a copy to user's area."); + return -EFAULT; + } + + MSG("IoGetParam: success"); + + return 0; +} + +static int Mmux_IoSetParam(struct tMmux_private_data *ptPrivate, unsigned long arg) +{ + struct MMUX_PARAM_INFO param_info; + unsigned long offset; + unsigned long data; + int ret; + + MSG("IoSetParam: start"); + + ret = Mmux_WaitInterfaceFree(ptPrivate); + if (ret != 0) { + return ret; + } + + if (copy_from_user(¶m_info, (void*)arg, sizeof(struct MMUX_PARAM_INFO))) { + ERR( "Failed in a copy from user's area."); + return -EFAULT; + } + + if (param_info.id < 0 || MMUX_INFO_MAX <= param_info.id) { + ERR( "Failed parameter id!"); + return -EFAULT; + } + + if (!(gt_Reg_A[param_info.id ].fg | REG_FG_WRITE)) { + ERR( "Parameter Can't write!"); + return -EFAULT; + } + + offset = gt_Reg_A[param_info.id].offset; + data = inl(ptPrivate->reg_base + offset); + data &= !gt_Reg_A[param_info.id].mask; + data |= (param_info.data << gt_Reg_A[param_info.id].shift) & gt_Reg_A[param_info.id].mask; + + outl(data, ptPrivate->reg_base +offset); + MSG("reg_base: 0x%x, offset: 0x%lx, data:0x%lx", + ptPrivate->reg_base, offset, data); + + MSG("IoSetParam: success"); + + return 0; +} + +static int Mmux_IoGetVersion(struct tMmux_private_data *ptPrivate, unsigned long arg) +{ + struct MMUX_VERSION_INFO version_info; + char *pVersion; + + MSG("IoGetVersion: start"); + + if (copy_from_user(&version_info, (void*)arg, sizeof(struct MMUX_VERSION_INFO))) { + ERR( "Failed in a copy from user's area."); + return -EFAULT; + } + + pVersion = MMXU_VERSION; + if ( copy_to_user(version_info.driver_ver, pVersion, sizeof(MMXU_VERSION)) ) { + ERR("Failed in a copy to user's area."); + return -EFAULT; + } + + if ( copy_to_user((void*)arg, &version_info, sizeof(struct MMUX_VERSION_INFO)) ) { + ERR("Failed in a copy to user's area."); + return -EFAULT; + } + + MSG("IoGetVersion: success"); + + return 0; +} + +//===============================================================================// +static int mmux_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + struct tMmux_private_data *ptPrivate; + int ret = 0; + + ptPrivate = filp->private_data; + + switch (cmd) { + case MMUX_IOCG_REG: + ret = Mmux_IoGetReg(ptPrivate, arg); + break; + case MMUX_IOCS_REG: + ret = Mmux_IoSetReg(ptPrivate, arg); + break; + case MMUX_IOCG_PARAM: + ret = Mmux_IoGetParam(ptPrivate, arg); + break; + case MMUX_IOCS_PARAM: + ret = Mmux_IoSetParam(ptPrivate, arg); + break; + case MMUX_IOCG_VERSION: + ret = Mmux_IoGetVersion(ptPrivate, arg); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int mmux_open(struct inode *inode, struct file *filp) +{ + struct tMmux_private_data *ptPrivate; + + MSG("Open: start"); + + ptPrivate = container_of(inode->i_cdev, struct tMmux_private_data, cdev); + filp->private_data = ptPrivate; + + MSG("minor: %d, private_data:%p", ptPrivate->minor, filp->private_data); + + MSG("Open: end"); + + return 0; +} + +static int mmux_release(struct inode *inode, struct file *filp) +{ + + MSG("Release: start"); + + MSG("Release: end"); + + return 0; +} + +static int Mmux_private_data_init(struct tMmux_private_data **ppPrivate, + struct pci_dev* pDev) +{ + struct tMmux_private_data *ptPrivate; + + MSG("private data init: start"); + + ptPrivate = kmalloc(sizeof(struct tMmux_private_data), GFP_KERNEL); + if (ptPrivate == NULL) { + ERR("kmalloc failed:(%d)", sizeof(struct tMmux_private_data)); + return -ENOMEM; + } + + ptPrivate->minor = giMmux_card_num; + giMmux_card_num++; + + ptPrivate->input_ch_total = 4; + ptPrivate->output_ch_total = 1; + ptPrivate->codec_chip_total = 4; + ptPrivate->pDev = pDev; + + ptPrivate->reg_base = pci_resource_start(pDev, REGISTER_REGION_NO); + ptPrivate->reg_length = pci_resource_len(pDev, REGISTER_REGION_NO); + MSG("base: 0x%x, len: 0x%x", ptPrivate->reg_base, ptPrivate->reg_length); + + if( !request_region(ptPrivate->reg_base, ptPrivate->reg_length, MMUX_DRIVER_NAME)) { + ERR("Request region failed"); + kfree(ptPrivate); + + return -EBUSY; + } + + spin_lock_init(&ptPrivate->lock); + + MSG("Region %d: 0x%x 0x%x 0x%x 0x%x 0x%x", + REGISTER_REGION_NO, inl(ptPrivate->reg_base), + inl(ptPrivate->reg_base +4), inl(ptPrivate->reg_base +8), + inl(ptPrivate->reg_base +12), inl(ptPrivate->reg_base +16) ); + + gptPrivate_data[ptPrivate->minor] = ptPrivate; + *ppPrivate = ptPrivate; + + MSG("private data init: success"); + + return 0; +} + +static void Mmux_private_data_release(struct tMmux_private_data *ptPrivate) +{ + gptPrivate_data[ptPrivate->minor] = NULL; + + release_region(ptPrivate->reg_base, ptPrivate->reg_length); + + + kfree(ptPrivate); +} + +static struct file_operations mmux_fops = +{ + .owner = THIS_MODULE, + .ioctl = mmux_ioctl, + .open = mmux_open, + .release = mmux_release, +}; + + +//===============================================================================// +static struct pci_device_id mmux_tbl[] __devinitdata = { + {MMUX_VENDOR_ID, MMUX_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { 0,}, +}; +MODULE_DEVICE_TABLE(pci, mmux_tbl); + +static int __devinit mmux_probe(struct pci_dev* pDev, const struct pci_device_id* pId) +{ + int result; + struct tMmux_private_data *ptPrivate; + dev_t dev_no; + + MSG("Probe: start"); + + result = pci_enable_device(pDev); + if(result != 0){ + ERR("pci_enable_device() error: %d", result); + return result; + } + + result = Mmux_private_data_init(&ptPrivate, pDev); + if (result < 0) { + ERR("private data init failed (%d)", result); + pci_disable_device(pDev); + return result; + } + + pci_set_master(ptPrivate->pDev); + pci_set_drvdata(ptPrivate->pDev, ptPrivate); + + cdev_init( &ptPrivate->cdev, &mmux_fops); + dev_no = MKDEV(MAJOR(gtMmux_dev_no), ptPrivate->minor); + ptPrivate->cdev.owner = THIS_MODULE; + ptPrivate->cdev.ops = &mmux_fops; + result = cdev_add(&ptPrivate->cdev, dev_no, 1); + if (result < 0) { + ERR("failed to add cdev (%d)", result); + return result; + } + + MSG("Probe: success"); + return 0; +} + +static void __devexit mmux_remove(struct pci_dev* pDev) +{ + struct tMmux_private_data *ptPrivate; + + MSG("Remove: start"); + + ptPrivate = pci_get_drvdata(pDev); + + pci_disable_device(pDev); + + cdev_del(&ptPrivate->cdev); + Mmux_private_data_release(ptPrivate); + + MSG("Remove: end"); +} + +static struct pci_driver mmux_driver = { + .name = MMUX_DRIVER_NAME, + .id_table = mmux_tbl, + .probe = mmux_probe, + .remove = __devexit_p(mmux_remove), +}; + +//===============================================================================// +static int __init mmux_init(void) +{ + int result; + + MSG("Module Init: start"); + + result = alloc_chrdev_region(>Mmux_dev_no, 0, MMUX_CARD_MAX, MMUX_DRIVER_NAME); + if (result < 0) { + ERR("Failed to alloc chrdev:(%d)", result); + return result; + } + + result = pci_register_driver(&mmux_driver); + + if (result < 0) { + ERR("Register pci driver faildd: %d",result); + unregister_chrdev_region(gtMmux_dev_no, MMUX_CARD_MAX); + return result; + } + + MSG("Module Init: Success"); + + return result; +} + +static void __exit mmux_exit(void) +{ + MSG("Module exit: start"); + + unregister_chrdev_region(gtMmux_dev_no, MMUX_CARD_MAX); + pci_unregister_driver(&mmux_driver); + + MSG("Module exit: End"); +} + +MODULE_LICENSE("GPL"); +MODULE_VERSION(MMXU_VERSION); + +module_init(mmux_init); +module_exit(mmux_exit); diff --git a/mmux_driver/mmux.h b/mmux_driver/mmux.h new file mode 100644 index 0000000..bfb8881 --- /dev/null +++ b/mmux_driver/mmux.h @@ -0,0 +1,87 @@ +/*================================================ + * *************** * + * ** \ | / ** * + * * **** **** ****** * * + * * ---**---**-|-**--**--** * * + * * ** ** | * ** ** * * + * *-----**--**--o-----****----* * + * * ** ** | ** * * + * * ---**---**-|--*--**---- * * + * * **** **** **** * * + * ** / | \ ** * + * ************** * + * Copyright (C) 2009 ~ 2010 * + *===============================================*/ +/*-----------------------------------------------* + $Author: Kenneth $ + $Date$ + $Revision$ + *-----------------------------------------------*/ +#ifndef _MUX_H_ +#define _MUX_H_ + + +//===============================================================================// +#define MMUX_TOTAL_CODEC 4 + +#define MMUX_VER_LEN 8 + + +enum enum_MMUX_PARAM_ID { + CODEC_0_SRC, + CODEC_1_SRC, + CODEC_2_SRC, + CODEC_3_SRC, + VIDEO_OUT_MODE, + CODEC_0_SRC_RESOLUTION, + CODEC_1_SRC_RESOLUTION, + CODEC_2_SRC_RESOLUTION, + CODEC_3_SRC_RESOLUTION, + CODEC_0_SRC_HOTPLUG, + CODEC_1_SRC_HOTPLUG, + CODEC_2_SRC_HOTPLUG, + CODEC_3_SRC_HOTPLUG, + CODEC_0_SRC_SCDT, + CODEC_1_SRC_SCDT, + CODEC_2_SRC_SCDT, + CODEC_3_SRC_SCDT, + CODEC_0_SRC_DISABLE, + CODEC_1_SRC_DISABLE, + CODEC_2_SRC_DISABLE, + CODEC_3_SRC_DISABLE, + VIDEO_OUT_RESOLUTION, + + CPLD_VER, + FPGA_VER, + MCU_VER, + + MMUX_INFO_MAX +}; + + +struct MMUX_REG_INFO { + unsigned long reg_add; + unsigned long reg_data; +}; + +struct MMUX_PARAM_INFO { + int id; // enum_MMUX_PARAM_ID. + unsigned long data; +}; + +struct MMUX_VERSION_INFO { + char* driver_ver; +}; + + +#define MMUX_IOC_MAGIC 0xC2 + +#define MMUX_IOCG_REG _IOR(MMUX_IOC_MAGIC, 1, struct MMUX_REG_INFO) +#define MMUX_IOCS_REG _IOW(MMUX_IOC_MAGIC, 2, struct MMUX_REG_INFO) +#define MMUX_IOCG_PARAM _IOR(MMUX_IOC_MAGIC, 3, struct MMUX_PARAM_INFO) +#define MMUX_IOCS_PARAM _IOW(MMUX_IOC_MAGIC, 4, struct MMUX_PARAM_INFO) +#define MMUX_IOCG_VERSION _IOR(MMUX_IOC_MAGIC, 5, struct MMUX_VERSION_INFO) + + + +#endif // _MUX_H_ ] |