mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
Created inteno-packages-broadcom repo for the following packages:
asterisk, bcmhotproxy, bcmkernel, brcm-h, brcm_fw_tool, brcminfo, dectmngr, dectmngr2, endptctl, natalie-dect, peripheral_manager, questd, teliasafety-misc, wl-anyfi.
This commit is contained in:
parent
4a670745ca
commit
6badb49fd9
101 changed files with 0 additions and 18526 deletions
|
|
@ -1,803 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2008-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=asterisk18-mod
|
||||
PKG_VERSION:=1.8.10.1
|
||||
|
||||
PKG_SOURCE_VERSION:=8d5a855296f61391d0166b66b11e4e6055fd86c6
|
||||
PKG_SOURCE_PROTO:=git
|
||||
ifeq ($(CONFIG_BCM_OPEN),y)
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/asterisk-aa
|
||||
else
|
||||
PKG_SOURCE_URL:=git@ihgsp.inteno.se:asterisk-aa
|
||||
endif
|
||||
|
||||
PKG_RELEASE:=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)-$(PKG_RELEASE).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/ltqtapi.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/asterisk18-mod/Default
|
||||
SUBMENU:=Telephony
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
URL:=http://www.asterisk.org/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/Default/description
|
||||
Asterisk is a complete PBX in software. It provides all of the features
|
||||
you would expect from a PBX and more. Asterisk does voice over IP in three
|
||||
protocols, and can interoperate with almost all standards-based telephony
|
||||
equipment using relatively inexpensive hardware.
|
||||
endef
|
||||
|
||||
|
||||
define Package/asterisk18-mod
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Complete open source PBX, v1.8x
|
||||
MENU:=1
|
||||
DEPENDS:= +natalie-dect-h +PACKAGE_bcmkernel:bcmkernel +PACKAGE_bcmopen:bcmopen +libopenssl +libncurses +libpopt +libpthread +uci +ubus +zlib @!TARGET_avr32
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Sound files
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains sound files for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-voicemail
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Voicemail support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-voicemail/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains voicemail related modules for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-transfer
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Call transfer support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-transfer/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains the call transfer support module for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-softhangup
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=SoftHangup application
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-softhangup/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains the SoftHangup support module for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=conferencing support
|
||||
DEPENDS:= asterisk18-mod +dahdi-tools-libtonezone +dahdi
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the MeetMe application driver Conferencing support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=IAX support
|
||||
DEPENDS:= asterisk18-mod +asterisk18-res-crypto
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides IAX support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=CDR support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides Call Detail Record support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=MOH support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides Music On Hold support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-voice
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Voice client/pbx support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-voice/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides Voice Client/pbx support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-srtp
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=SRTP support
|
||||
DEPENDS:= asterisk18-mod libsrtp +asterisk18-mod-res-crypto
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-srtp/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides SRTP support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-stun
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=STUN support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-queue
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Queue support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=GTalk support
|
||||
DEPENDS:= asterisk18-mod +libiksemel
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_gtalk and res_jabber for GTalk
|
||||
support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Mobile channel support
|
||||
DEPENDS:= asterisk18-mod +bluez-libs
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_mobile support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-timerfd
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:= Timerfd Timing Interface
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-pthread
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:= pthread Timing Interface
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Generic FAX Resource for FAX technology resource modules
|
||||
DEPENDS:= asterisk18-mod +asterisk18-mod-res-timing-pthread
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax-spandsp
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Spandsp T.38 and G.711 FAX Resource
|
||||
DEPENDS:= asterisk18-mod +asterisk18-mod-res-fax +libspandsp
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=MGCP channel support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_mgcp support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Skinny channel support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_skinny support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Broadcom channel support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_brcm support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-curl
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=CURL support
|
||||
DEPENDS:= asterisk18-mod +libcurl
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-curl/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides CURL
|
||||
support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=MySQL support
|
||||
DEPENDS:= asterisk18-mod +PACKAGE_asterisk18-mysql:libmysqlclient
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides MySQL
|
||||
support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Lantiq TAPI support
|
||||
DEPENDS:= asterisk18-mod $(LTQ_TAPI_DEPENDS)
|
||||
URL:=http://git.nanl.de/?p=asterisk_channel_lantiq.git
|
||||
MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_lantiq support to Asterisk.
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-inotify
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-app-meetme),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-dahdi="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-dahdi
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-chan-gtalk),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-gnutls="$(STAGING_DIR)/usr" \
|
||||
--with-iksemel="$(STAGING_DIR)/usr"
|
||||
SITE_VARS+= \
|
||||
ac_cv_lib_iksemel_iks_start_sasl=yes \
|
||||
ac_cv_lib_gnutls_gnutls_bye=yes
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-gnutls \
|
||||
--without-iksemel
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-curl),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-curl="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-curl
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-mysql),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-mysqlclient="$(STAGING_DIR)/usr/bin"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-mysqlclient
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-res-fax-spandsp),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-spandsp="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-spandsp
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-chan-mobile),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-bluetooth="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-bluetooth
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-res-srtp),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-srtp="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-srtp
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TARGET_IBOARDID),"D301")
|
||||
EXTRA_CFLAGS += -DNTR_SUPPORT
|
||||
endif
|
||||
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-curses \
|
||||
--with-gsm=internal \
|
||||
--without-cap \
|
||||
--without-gtk \
|
||||
--without-gtk2 \
|
||||
--without-isdnnet \
|
||||
--without-kde \
|
||||
--without-misdn \
|
||||
--without-nbs \
|
||||
--with-ncurses="$(STAGING_DIR)/usr" \
|
||||
--without-netsnmp \
|
||||
--without-newt \
|
||||
--without-odbc \
|
||||
--without-ogg \
|
||||
--without-osptk \
|
||||
--with-popt="$(STAGING_DIR)/usr" \
|
||||
--without-pri \
|
||||
--without-qt \
|
||||
--without-radius \
|
||||
--without-sdl \
|
||||
--without-suppserv \
|
||||
--without-tds \
|
||||
--without-termcap \
|
||||
--without-tinfo \
|
||||
--without-vorbis \
|
||||
--without-vpb \
|
||||
--with-z="$(STAGING_DIR)/usr" \
|
||||
--with-sounds-cache="$(DL_DIR)" \
|
||||
--disable-xmldoc
|
||||
|
||||
EXTRA_CFLAGS+= $(TARGET_CPPFLAGS)
|
||||
EXTRA_LDFLAGS+= $(TARGET_LDFLAGS)
|
||||
|
||||
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
ifneq ($(CONFIG_TARGET_lantiq),)
|
||||
$(CP) ./src-lantiq/* $(PKG_BUILD_DIR)/
|
||||
endif
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
-rm $(PKG_BUILD_DIR)/menuselect.makeopts
|
||||
$(call Build/Configure/Default,,$(SITE_VARS))
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)" \
|
||||
include/asterisk/version.h \
|
||||
include/asterisk/buildopts.h defaults.h \
|
||||
makeopts.embed_rules
|
||||
ASTCFLAGS="$(EXTRA_CFLAGS) -DLOW_MEMORY" \
|
||||
ASTLDFLAGS="$(EXTRA_LDFLAGS)" \
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)" \
|
||||
ASTVARLIBDIR="/usr/lib/asterisk" \
|
||||
ASTDATADIR="/usr/lib/asterisk" \
|
||||
ASTKEYDIR="/usr/lib/asterisk" \
|
||||
ASTDBDIR="/usr/lib/asterisk" \
|
||||
NOISY_BUILD="1" \
|
||||
DEBUG="" \
|
||||
OPTIMIZE="" \
|
||||
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||
all install samples
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/asterisk-1.8/include/asterisk/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/asterisk/*.h $(1)/usr/include/asterisk-1.8/include/asterisk/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/asterisk.h $(1)/usr/include/asterisk-1.8/include/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/conffiles
|
||||
/etc/asterisk/asterisk.conf
|
||||
/etc/asterisk/modules.conf
|
||||
/etc/asterisk/extensions.conf
|
||||
/etc/asterisk/sip.conf
|
||||
/etc/asterisk/sip_notify.conf
|
||||
/etc/asterisk/features.conf
|
||||
/etc/asterisk/indications.conf
|
||||
/etc/asterisk/logger.conf
|
||||
/etc/asterisk/manager.conf
|
||||
/etc/asterisk/rtp.conf
|
||||
/etc/default/asterisk
|
||||
/etc/init.d/asterisk
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk/ssl
|
||||
for f in asterisk extensions features \
|
||||
indications logger manager modules \
|
||||
sip sip_notify rtp; do \
|
||||
$(CP) $(PKG_INSTALL_DIR)/etc/asterisk/$$$$f.conf $(1)/etc/asterisk/ ; \
|
||||
done
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
for f in app_dial app_echo app_playback app_macro \
|
||||
chan_sip res_rtp_asterisk res_rtp_multicast \
|
||||
codec_ulaw codec_gsm \
|
||||
format_gsm format_pcm format_wav format_wav_gsm \
|
||||
pbx_config \
|
||||
func_strings func_timeout func_callerid func_logic; do \
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/$$$$f.so $(1)/usr/lib/asterisk/modules/ ; \
|
||||
done
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/asterisk $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/default
|
||||
$(INSTALL_DATA) ./files/asterisk.default $(1)/etc/default/asterisk
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/sounds/en/* $(1)/usr/lib/asterisk/sounds/
|
||||
rm -f $(1)/usr/lib/asterisk/sounds/vm-*
|
||||
rm -f $(1)/usr/lib/asterisk/sounds/conf-*
|
||||
endef
|
||||
|
||||
|
||||
define Package/asterisk18-mod-voicemail/conffiles
|
||||
/etc/asterisk/voicemail.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-voicemail/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/voicemail.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/*voicemail.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_adsi.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_smdi.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/sounds/en/vm-*.gsm $(1)/usr/lib/asterisk/sounds/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme/conffiles
|
||||
/etc/asterisk/meetme.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/meetme.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_meetme.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/sounds/en/conf-*.gsm $(1)/usr/lib/asterisk/sounds/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2/conffiles
|
||||
/etc/asterisk/iax.conf
|
||||
/etc/asterisk/iaxprov.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr/conffiles
|
||||
/etc/asterisk/cdr.conf
|
||||
/etc/asterisk/cdr_custom.conf
|
||||
/etc/asterisk/cdr_manager.conf
|
||||
/etc/asterisk/cdr_odbc.conf
|
||||
/etc/asterisk/cdr_pgsql.conf
|
||||
/etc/asterisk/cdr_tds.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold/conffiles
|
||||
/etc/asterisk/musiconhold.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/iax.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/iaxprov.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_iax2.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/cdr*.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/*cdr*.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/musiconhold.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_musiconhold.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-voice/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_voice.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk/conffiles
|
||||
/etc/asterisk/gtalk.conf
|
||||
/etc/asterisk/jabber.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/gtalk.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/jabber.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_gtalk.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_jabber.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile/conffiles
|
||||
/etc/asterisk/chan_mobile.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/chan_mobile.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_mobile.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-timerfd/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_timing_timerfd.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-pthread/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_timing_pthread.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax/conffiles
|
||||
/etc/asterisk/res_fax.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/res_fax.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_fax.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax-spandsp/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_fax_spandsp.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp/conffiles
|
||||
/etc/asterisk/mgcp.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/mgcp.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_mgcp.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny/conffiles
|
||||
/etc/asterisk/skinny.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/skinny.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_skinny.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm/conffiles
|
||||
/etc/asterisk/brcm.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/brcm.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_brcm.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-curl/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/func_curl.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_curl.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-transfer/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_transfer.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-softhangup/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_softhangup.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql/conffiles
|
||||
/etc/asterisk/app_mysql.conf
|
||||
/etc/asterisk/res_config_mysql.conf
|
||||
/etc/asterisk/cdr_mysql.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/app_mysql.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/res_config_mysql.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/cdr_mysql.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_mysql.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/cdr_mysql.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_config_mysql.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq/conffiles
|
||||
/etc/asterisk/lantiq.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/lantiq.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_lantiq.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-srtp/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_srtp.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-stun/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_stun_monitor.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-queue/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_queue.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Buildasterisk18-modModuleTemplate
|
||||
|
||||
define Package/asterisk18-mod-$(subst _,-,$(1))
|
||||
$$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=$(2) support
|
||||
DEPENDS:= asterisk18-mod $(4)
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-$(subst _,-,$(1))/description
|
||||
$$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides support $(3) in Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-$(subst _,-,$(1))/install
|
||||
$(INSTALL_DIR) $$(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/$(1).so $$(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
$$(eval $$(call BuildPackage,asterisk18-mod-$(subst _,-,$(1))))
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,asterisk18-mod))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-voicemail))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-sounds))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-meetme))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-transfer))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-softhangup))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-iax2))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-cdr))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-musiconhold))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-voice))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-gtalk))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-mobile))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-fax))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-fax-spandsp))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-timing-timerfd))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-timing-pthread))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-mgcp))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-skinny))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-brcm))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-curl))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-mysql))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-lantiq))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-srtp))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-stun))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-queue))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_authenticate,Authenticate,support for executing arbitrary authenticate commands))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_chanisavail,Channel availability check,support for checking if a channel is available))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_chanspy,Channel listen in,support for listening in on any channel))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_directed_pickup,Directed call pickup,support for directed call pickup))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_exec,Exec application,support for application execution))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_minivm,Minimal voicemail system,a voicemail system in small building blocks working together based on the Comedian Mail voicemail system))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_readexten,Extension to variable,a trivial application to read an extension into a variable))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_read,Variable read,a trivial application to read a variable))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_sayunixtime,Say Unix time,an application to say Unix time))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_sms,SMS,SMS support (ETSI ES 201 912 protocol 1)))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_stack,Stack applications, stack applications Gosub Return etc., +asterisk18-res-agi))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_system,System exec,support for executing system commands))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_talkdetect,File playback with audio detect,for file playback with audio detect))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_waituntil,Sleep,support sleeping until the given epoch))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_while,While loop,a while loop implementation))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,chan_agent,Agents proxy channel, an implementation of agents proxy channel))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,chan_local,Local proxy channel, an implementation of local proxy channel))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_alaw,Signed linear to alaw translation,translation between signed linear and alaw codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_ulaw,Signed linear to ulaw translation,translation between signed linear and ulaw codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_a_mu,Alaw to ulaw translation,translation between alaw and ulaw codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_g722,G.722,a high bit rate 48/56/64Kbps ITU standard codec))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_g726,Signed linear to G.726 translation,translation between signed linear and ITU G.726-32kbps codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_ilbc,iLBC,internet Low Bitrate Codec))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_gsm,GSM,GSM codec))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_g726,G.726,support for headerless G.726 16/24/32/40kbps data format))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_g729,G.729,support for raw headerless G729 data))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_sln,Raw slinear format,support for raw slinear format))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_sln16,Raw slinear 16 format,support for Raw slinear 16 format))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_db,Database interaction,functions for interaction with the database))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_devstate,Blinky lights control,functions for manually controlled blinky lights))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_vmcount,vmcount dialplan,a vmcount dialplan function))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_extstate,Hinted extension state,retrieving the state of a hinted extension for dialplan control))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_global,Global variable,global variable dialplan functions))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_shell,Shell,support for shell execution))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,pbx_ael,Asterisk Extension Logic,support for symbolic Asterisk Extension Logic))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_ael_share,Shareable AEL code,support for shareable AEL code mainly between internal and external modules))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,pbx_spool,Call Spool,outgoing call spool support))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_agi,Asterisk Gateway Interface,support for the Asterisk Gateway Interface extension))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_crypto,Provide Crypto,Cryptographic Signature capability))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_alarmreceiver,Alarm receiver,Central Station Alarm receiver for Ademco Contact ID))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_setcallerid,Set callerid,support for setting callerid))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_verbose,Verbose logging,Verbose logging application))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_channel,Channel info,Channel info dialplan function))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_blacklist,Blacklist on callerid,looking up the callerid number and see if it is blacklisted))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_originate,Originate a call,originating an outbound call and connecting it to a specified extension or application))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_uri,URI encoding and decoding,Encodes and decodes URI-safe strings))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_disa,Direct Inward System Access,Direct Inward System Access))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_senddtmf,Send DTMF digits,Sends arbitrary DTMF digits))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_cut,CUT function,CUT function))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_clioriginate,Calls via CLI,Originate calls via the CLI))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_mixmonitor,Record a call and mix the audio,record a call and mix the audio during the recording))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_playtones,Playtones application,play a tone list))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_record,Record sound file,to record a sound file))
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
## startup options for /etc/init.d/asterisk
|
||||
|
||||
ENABLE_ASTERISK="yes"
|
||||
OPTIONS=""
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=98
|
||||
STOP=10
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=asterisk
|
||||
PROG=/usr/sbin/asterisk
|
||||
DEFAULT=/etc/default/asterisk
|
||||
|
||||
init_asterisk() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
[ -d /var/run/asterisk ] || mkdir -p /var/run/asterisk
|
||||
[ -d /var/log/asterisk ] || mkdir -p /var/log/asterisk
|
||||
[ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
|
||||
|
||||
# does the board have a fxs relay?
|
||||
local fxsRelayGpio=$(db -q get hw.board.fxsRelayGpio)
|
||||
if [ "$fxsRelayGpio" != "" ]; then
|
||||
/sbin/brcm_fw_tool set -x $fxsRelayGpio -p 1
|
||||
fi
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger voice_client
|
||||
}
|
||||
|
||||
start_service() {
|
||||
init_asterisk
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" -f
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
# service_start /usr/sbin/asterisk
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
asterisk -rx "core reload"
|
||||
asterisk -rx "dialplan reload"
|
||||
asterisk -rx "brcm reload"
|
||||
}
|
||||
|
||||
restart() {
|
||||
reload
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
service_stop /usr/sbin/asterisk
|
||||
}
|
||||
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2009 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=bcmhotproxy
|
||||
PKG_RELEASE:=13
|
||||
|
||||
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/bcmhotproxy
|
||||
SECTION:=utils
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Daemon That feeds broadcom driver calls to hotplug2
|
||||
endef
|
||||
|
||||
define Package/bcmhotproxy/description
|
||||
This package contains a Daemon that will listen to link events from broadcoms adsl driver and etherent driver and proxy them to hotplug
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
$(CP) ./files/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
|
||||
define Package/bcmhotproxy/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/etc/init.d/* $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bcmhotproxy $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bcmhotproxy))
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=15
|
||||
STOP=95
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=bcmhotproxy
|
||||
PROG=/sbin/bcmhotproxy
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /sbin/bcmhotproxy
|
||||
}
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
CC = gcc
|
||||
CFLAGS += -Wall
|
||||
|
||||
obj = bcmhotproxy.o brcmdaemon.o
|
||||
|
||||
bcmhotproxy: $(obj) $(obj.$(TARGET))
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
/*
|
||||
* bcmhotproxy -- a proxy to send messages from broadcom drivers to userspace
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: Strhuan Blomquist
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
#include "bcmhotproxy.h"
|
||||
|
||||
int netlink_init() {
|
||||
int sock_fd;
|
||||
sock_fd=socket(PF_NETLINK, SOCK_RAW, NETLINK_BRCM_MONITOR);
|
||||
if(sock_fd<0)
|
||||
return -1;
|
||||
return sock_fd;
|
||||
}
|
||||
int hotplug_call(struct hotplug_arg arg)
|
||||
{
|
||||
char str[512];
|
||||
int ret;
|
||||
memset(str, '\0', sizeof(512));
|
||||
syslog(LOG_INFO, "ACTION=%s INTERFACE=%s /sbin/hotplug-call %s", arg.action,arg.inteface,arg.subsystem);
|
||||
sprintf(str, "ACTION=%s INTERFACE=%s /sbin/hotplug-call %s",arg.action,arg.inteface,arg.subsystem);
|
||||
ret=system(str);
|
||||
return ret;
|
||||
}
|
||||
hotplug_arg createargumetstruct(char *hotplugmsg)
|
||||
{
|
||||
hotplug_arg arg;
|
||||
char argumets[3][20];
|
||||
char * pch;
|
||||
int x=0;
|
||||
pch = strtok (hotplugmsg," ");
|
||||
while (pch != NULL){
|
||||
strcpy(argumets[x],pch);
|
||||
pch = strtok (NULL, " ");
|
||||
x++;
|
||||
}
|
||||
strncpy(arg.action,argumets[0],sizeof(arg.action));
|
||||
strncpy(arg.inteface,argumets[1],sizeof(arg.action));
|
||||
strncpy(arg.subsystem,argumets[2],sizeof(arg.action));
|
||||
|
||||
return arg;
|
||||
|
||||
}
|
||||
|
||||
int netlink_bind(int sock_fd) {
|
||||
|
||||
struct sockaddr_nl src_addr;
|
||||
memset(&src_addr, 0, sizeof(src_addr));
|
||||
src_addr.nl_family = AF_NETLINK;
|
||||
src_addr.nl_pid = getpid(); /* self pid */
|
||||
src_addr.nl_groups = 1; //multicast Group
|
||||
|
||||
bind(sock_fd, (struct sockaddr*)&src_addr,sizeof(src_addr));
|
||||
|
||||
if (bind(sock_fd, (struct sockaddr*)&src_addr,sizeof(src_addr))) {
|
||||
close(sock_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sock_fd;
|
||||
}
|
||||
|
||||
int dispatcher() {
|
||||
struct sockaddr_nl dest_addr;
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
struct iovec iov;
|
||||
struct msghdr msg;
|
||||
hotplug_arg arg;
|
||||
int sock_fd;
|
||||
/* Initlize the netlink socket */
|
||||
sock_fd=netlink_init();
|
||||
if (sock_fd == -1) {
|
||||
fprintf(stderr, "Unable to Intitlize netlink socket.\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Bind the netlink socket */
|
||||
sock_fd=netlink_bind(sock_fd);
|
||||
if (sock_fd == -1) {
|
||||
fprintf(stderr, "Unable to Listen to netlink socket.\n");
|
||||
exit(1);
|
||||
}
|
||||
/* destination address to listen to */
|
||||
nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));
|
||||
memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));
|
||||
nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);
|
||||
nlh->nlmsg_pid = getpid();
|
||||
nlh->nlmsg_flags = 0;
|
||||
|
||||
/* Fill the netlink message header */
|
||||
iov.iov_base = (void *)nlh;
|
||||
iov.iov_len = nlh->nlmsg_len;
|
||||
msg.msg_name = (void *)&dest_addr;
|
||||
msg.msg_namelen = sizeof(dest_addr);
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
|
||||
|
||||
/* Read message from kernel */
|
||||
while(1){
|
||||
recvmsg(sock_fd, &msg, 0);
|
||||
switch (nlh->nlmsg_type)
|
||||
{
|
||||
case MSG_NETLINK_BRCM_WAKEUP_MONITOR_TASK:
|
||||
case MSG_NETLINK_BRCM_LINK_STATUS_CHANGED:
|
||||
/*process the message */
|
||||
fprintf(stderr, "No Handle\n");
|
||||
break;
|
||||
case MSG_NETLINK_BRCM_LINK_HOTPLUG:
|
||||
arg=createargumetstruct((char *)NLMSG_DATA(nlh));
|
||||
if(hotplug_call(arg)){
|
||||
fprintf(stderr, "Unable to call hotplug.\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown type\n");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
close(sock_fd);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef BCMHOTPROXY_H
|
||||
#define BCMHOTPROXY_H 1
|
||||
#include <sys/socket.h>
|
||||
#include <linux/netlink.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#define MSG_NETLINK_BRCM_WAKEUP_MONITOR_TASK 0X1000
|
||||
|
||||
#define MSG_NETLINK_BRCM_LINK_STATUS_CHANGED 0X2000
|
||||
|
||||
#define MSG_NETLINK_BRCM_LINK_HOTPLUG 0X3000
|
||||
#define MAX_PAYLOAD 1024 /* maximum payload size*/
|
||||
#ifndef NETLINK_BRCM_MONITOR
|
||||
#define NETLINK_BRCM_MONITOR 25
|
||||
#endif
|
||||
typedef struct hotplug_arg hotplug_arg;
|
||||
|
||||
struct hotplug_arg
|
||||
{
|
||||
char action[20];
|
||||
char inteface[20];
|
||||
char subsystem[20];
|
||||
|
||||
};
|
||||
#endif
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
#include "brcmdaemon.h"
|
||||
|
||||
/**************************************************************************
|
||||
Function: Print Usage
|
||||
|
||||
Description:
|
||||
Output the command-line options for this daemon.
|
||||
|
||||
Params:
|
||||
@argc - Standard argument count
|
||||
@argv - Standard argument array
|
||||
|
||||
Returns:
|
||||
returns void always
|
||||
**************************************************************************/
|
||||
void PrintUsage(int argc, char *argv[]) {
|
||||
if (argc >=1) {
|
||||
printf("Usage: %s -h -n\n", argv[0]);
|
||||
printf(" Options: \n");
|
||||
printf(" -ntDon't fork off as a daemon.\n");
|
||||
printf(" -htShow this help screen.\n");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Function: signal_handler
|
||||
|
||||
Description:
|
||||
This function handles select signals that the daemon may
|
||||
receive. This gives the daemon a chance to properly shut
|
||||
down in emergency situations. This function is installed
|
||||
as a signal handler in the 'main()' function.
|
||||
|
||||
Params:
|
||||
@sig - The signal received
|
||||
|
||||
Returns:
|
||||
returns void always
|
||||
**************************************************************************/
|
||||
void signal_handler(int sig) {
|
||||
|
||||
switch(sig) {
|
||||
case SIGHUP:
|
||||
syslog(LOG_WARNING, "Received SIGHUP signal.");
|
||||
break;
|
||||
case SIGTERM:
|
||||
syslog(LOG_WARNING, "Received SIGTERM signal.");
|
||||
break;
|
||||
default:
|
||||
syslog(LOG_WARNING, "Unhandled signal (%d) %s", strsignal(sig));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Function: main
|
||||
|
||||
Description:
|
||||
The c standard 'main' entry point function.
|
||||
|
||||
Params:
|
||||
@argc - count of command line arguments given on command line
|
||||
@argv - array of arguments given on command line
|
||||
|
||||
Returns:
|
||||
returns integer which is passed back to the parent process
|
||||
**************************************************************************/
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#if defined(DEBUG)
|
||||
int daemonize = 0;
|
||||
#else
|
||||
int daemonize = 0;
|
||||
#endif
|
||||
|
||||
// Setup signal handling before we start
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
|
||||
int c;
|
||||
while( (c = getopt(argc, argv, "nh|help")) != -1) {
|
||||
switch(c){
|
||||
case 'h':
|
||||
PrintUsage(argc, argv);
|
||||
exit(0);
|
||||
break;
|
||||
case 'n':
|
||||
daemonize = 0;
|
||||
break;
|
||||
default:
|
||||
PrintUsage(argc, argv);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "%s daemon starting up", DAEMON_NAME);
|
||||
|
||||
// Setup syslog logging - see SETLOGMASK(3)
|
||||
#if defined(DEBUG)
|
||||
setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
openlog(DAEMON_NAME, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID, LOG_USER);
|
||||
#else
|
||||
setlogmask(LOG_UPTO(LOG_INFO));
|
||||
openlog(DAEMON_NAME, LOG_CONS, LOG_USER);
|
||||
#endif
|
||||
|
||||
/* Our process ID and Session ID */
|
||||
pid_t pid, sid;
|
||||
|
||||
if (daemonize) {
|
||||
syslog(LOG_INFO, "starting the daemonizing process");
|
||||
|
||||
/* Fork off the parent process */
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* If we got a good PID, then
|
||||
we can exit the parent process. */
|
||||
if (pid > 0) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Change the file mode mask */
|
||||
umask(0);
|
||||
|
||||
/* Create a new SID for the child process */
|
||||
sid = setsid();
|
||||
if (sid < 0) {
|
||||
/* Log the failure */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Change the current working directory */
|
||||
if ((chdir("/")) < 0) {
|
||||
/* Log the failure */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Close out the standard file descriptors */
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
}
|
||||
|
||||
dispatcher();
|
||||
syslog(LOG_INFO, "%s daemon exiting", DAEMON_NAME);
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#ifndef BRCMDAEMON_H
|
||||
#define BRCMDAEMON_H 1
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define DAEMON_NAME "brcmnetlink"
|
||||
#define PID_FILE "/var/run/brcmnetlink.pid"
|
||||
#endif
|
||||
|
|
@ -1,231 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
# update this based on the Broadcom SDK version, 4.14L.04 -> 414040
|
||||
BRCM_SDK_VERSION:=414040
|
||||
|
||||
ifeq ($(CONFIG_BCM_OPEN),y)
|
||||
$(error "OPEN SDK compile not tested with this kernel!")
|
||||
endif
|
||||
|
||||
PKG_NAME:=bcmkernel-3.4
|
||||
PKG_VERSION:=$(BRCM_SDK_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.14L.04
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
PKG_SOURCE_VERSION:=8216815ced065e527681a079ad0e17fbb007baec
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(BRCM_SDK_VERSION)
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
export CONFIG_BCM_KERNEL_PROFILE
|
||||
export CONFIG_SECURE_BOOT_CFE
|
||||
|
||||
|
||||
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
|
||||
BCM_KERNEL_VERSION:=3.4.11-rt19
|
||||
BCM_SDK_VERSION:=bcm963xx
|
||||
RSTRIP:=true
|
||||
|
||||
|
||||
define Package/bcmkernel/removevoice
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
|
||||
define Package/bcmkernel/removevoice
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/bcmkernel/removei2c
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_I2C),y)
|
||||
define Package/bcmkernel/removei2c
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/install
|
||||
$(INSTALL_DIR) $(1)/lib/bcm
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/adsl
|
||||
$(INSTALL_DIR) $(1)/etc/wlan
|
||||
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
|
||||
|
||||
# Install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
|
||||
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
|
||||
|
||||
# create symlink to kernel build directory
|
||||
rm -f $(BUILD_DIR)/bcmkernel
|
||||
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
|
||||
|
||||
# Install binaries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
|
||||
|
||||
rm -f $(1)/usr/sbin/dhcp6c
|
||||
rm -f $(1)/usr/sbin/dhcp6s
|
||||
rm -f $(1)/usr/sbin/dhcpc
|
||||
rm -f $(1)/usr/sbin/dhcpd
|
||||
rm -f $(1)/usr/sbin/dnsproxy
|
||||
rm -f $(1)/usr/sbin/httpd
|
||||
rm -f $(1)/usr/sbin/openssl
|
||||
rm -f $(1)/usr/sbin/racoon
|
||||
rm -f $(1)/usr/sbin/ripd
|
||||
rm -f $(1)/usr/sbin/send_cms_msg
|
||||
rm -f $(1)/usr/sbin/sshd
|
||||
rm -f $(1)/usr/sbin/ssk
|
||||
rm -f $(1)/usr/sbin/telnetd
|
||||
rm -f $(1)/usr/sbin/tr64c
|
||||
rm -f $(1)/usr/sbin/tr69c
|
||||
rm -f $(1)/usr/sbin/ubi*
|
||||
rm -f $(1)/usr/sbin/udhcpd
|
||||
rm -f $(1)/usr/sbin/upnp
|
||||
rm -f $(1)/usr/sbin/upnpd
|
||||
rm -f $(1)/usr/sbin/vodsl
|
||||
rm -f $(1)/usr/sbin/wlmngr
|
||||
rm -f $(1)/usr/sbin/zebra
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
|
||||
|
||||
# Install libraries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
|
||||
|
||||
mv $(1)/usr/lib/ld-uClibc.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libc.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libdl.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libgcc_s.so.1 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libpthread.so.0 $(1)/lib/bcm/
|
||||
|
||||
rm -f $(1)/usr/lib/libcrypt.so.0
|
||||
rm -f $(1)/usr/lib/libm.so.0
|
||||
rm -f $(1)/usr/lib/libutil.so.0
|
||||
rm -f $(1)/usr/lib/libcms_boardctl.so
|
||||
rm -f $(1)/usr/lib/libcms_msg.so
|
||||
rm -f $(1)/usr/lib/libcms_util.so
|
||||
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libssl.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libnvram.so
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
|
||||
|
||||
rm -rf $(1)/usr/lib/modules
|
||||
rm -rf $(1)/usr/lib/private
|
||||
rm -rf $(1)/usr/lib/public
|
||||
rm -rf $(1)/usr/lib/gpl
|
||||
|
||||
# Install kernel modules
|
||||
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
|
||||
mkdir -p $(1)/lib/
|
||||
mkdir -p $(1)/lib/modules/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/*_map.bin $(1)/etc/wlan
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
|
||||
|
||||
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
|
||||
|
||||
# bootloader nor
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
|
||||
|
||||
# ram part of the bootloader for nand boot
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
|
||||
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
|
||||
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
|
||||
|
||||
$(call Package/bcmkernel/removevoice,$(1))
|
||||
$(call Package/bcmkernel/removei2c,$(1))
|
||||
endef
|
||||
|
||||
|
|
@ -1,266 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
# update this based on the Broadcom SDK version, 4.16L.02 -> 416020
|
||||
# 4.16L.02A -> 416021
|
||||
BRCM_SDK_VERSION:=416021
|
||||
|
||||
ifeq ($(CONFIG_BCM_OPEN),y)
|
||||
$(error "OPEN SDK compile not tested with this kernel!")
|
||||
endif
|
||||
|
||||
PKG_NAME:=bcmkernel-3.4
|
||||
PKG_VERSION:=$(BRCM_SDK_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.02A
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
PKG_SOURCE_VERSION:=00e673bd751d19059cb3ed5fd2dbf3831a7e0401
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(BRCM_SDK_VERSION)
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
export CONFIG_BCM_KERNEL_PROFILE
|
||||
export CONFIG_SECURE_BOOT_CFE
|
||||
|
||||
|
||||
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
|
||||
BCM_KERNEL_VERSION:=3.4.11-rt19
|
||||
BCM_SDK_VERSION:=bcm963xx
|
||||
RSTRIP:=true
|
||||
|
||||
|
||||
define Package/bcmkernel/removevoice
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
|
||||
define Package/bcmkernel/removevoice
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removesound
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
endef
|
||||
|
||||
ifeq ($(BCM_USBSOUND_MODULES),y)
|
||||
define Package/bcmkernel/removesound
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/bcmkernel/removei2c
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_I2C),y)
|
||||
define Package/bcmkernel/removei2c
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removebluetooth
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bnep.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/btusb.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/rfcomm.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/hci_uart.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_BLUETOOTH),y)
|
||||
define Package/bcmkernel/removebluetooth
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko etc...
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/adsl
|
||||
$(INSTALL_DIR) $(1)/etc/wlan
|
||||
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
|
||||
|
||||
# Install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
|
||||
|
||||
# create symlink to kernel build directory
|
||||
rm -f $(BUILD_DIR)/bcmkernel
|
||||
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
|
||||
|
||||
# Install binaries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
|
||||
|
||||
rm -f $(1)/usr/sbin/dhcp6c
|
||||
rm -f $(1)/usr/sbin/dhcp6s
|
||||
rm -f $(1)/usr/sbin/dhcpc
|
||||
rm -f $(1)/usr/sbin/dhcpd
|
||||
rm -f $(1)/usr/sbin/dnsproxy
|
||||
rm -f $(1)/usr/sbin/httpd
|
||||
rm -f $(1)/usr/sbin/openssl
|
||||
rm -f $(1)/usr/sbin/racoon
|
||||
rm -f $(1)/usr/sbin/ripd
|
||||
rm -f $(1)/usr/sbin/send_cms_msg
|
||||
rm -f $(1)/usr/sbin/sshd
|
||||
rm -f $(1)/usr/sbin/ssk
|
||||
rm -f $(1)/usr/sbin/telnetd
|
||||
rm -f $(1)/usr/sbin/tr64c
|
||||
rm -f $(1)/usr/sbin/tr69c
|
||||
rm -f $(1)/usr/sbin/ubi*
|
||||
rm -f $(1)/usr/sbin/udhcpd
|
||||
rm -f $(1)/usr/sbin/upnp
|
||||
rm -f $(1)/usr/sbin/upnpd
|
||||
rm -f $(1)/usr/sbin/vodsl
|
||||
rm -f $(1)/usr/sbin/wlmngr
|
||||
rm -f $(1)/usr/sbin/zebra
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
|
||||
|
||||
# Install libraries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
|
||||
|
||||
rm -f $(1)/usr/lib/ld-uClibc.so.0
|
||||
rm -f $(1)/usr/lib/libc.so.0
|
||||
rm -f $(1)/usr/lib/libdl.so.0
|
||||
rm -f $(1)/usr/lib/libgcc_s.so.1
|
||||
rm -f $(1)/usr/lib/libpthread.so.0
|
||||
rm -f $(1)/usr/lib/libm.so.0
|
||||
rm -f $(1)/usr/lib/libutil.so.0
|
||||
rm -f $(1)/usr/lib/libcms_boardctl.so
|
||||
rm -f $(1)/usr/lib/libcms_msg.so
|
||||
rm -f $(1)/usr/lib/libcms_util.so
|
||||
rm -f $(1)/usr/lib/libnvram.so
|
||||
rm -f $(1)/usr/lib/libcrypt.so.0
|
||||
|
||||
rm -f $(1)/usr/lib/libcrypto.so
|
||||
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so
|
||||
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libssl.so
|
||||
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so
|
||||
rm -f $(1)/usr/lib/libssl.so.0.9.7
|
||||
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so.0.9.7
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
|
||||
|
||||
rm -rf $(1)/usr/lib/modules
|
||||
rm -rf $(1)/usr/lib/private
|
||||
rm -rf $(1)/usr/lib/public
|
||||
rm -rf $(1)/usr/lib/gpl
|
||||
|
||||
# Install kernel modules
|
||||
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
|
||||
mkdir -p $(1)/lib/
|
||||
mkdir -p $(1)/lib/modules/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
|
||||
|
||||
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
|
||||
|
||||
# bootloader nor
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
|
||||
|
||||
# ram part of the bootloader for nand boot
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
|
||||
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
|
||||
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
|
||||
|
||||
$(call Package/bcmkernel/removevoice,$(1))
|
||||
$(call Package/bcmkernel/removesound,$(1))
|
||||
# $(call Package/bcmkernel/removei2c,$(1))
|
||||
endef
|
||||
|
||||
|
|
@ -1,278 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
# update this based on the Broadcom SDK version, 4.16L.03 -> 416030
|
||||
BRCM_SDK_VERSION:=416030
|
||||
|
||||
ifneq ($(CONFIG_BCM_OPEN),y)
|
||||
PKG_NAME:=bcmkernel-3.4
|
||||
PKG_VERSION:=$(BRCM_SDK_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.03
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
PKG_SOURCE_VERSION:=205c1d7bdd24388e0bae8c2883ac83ca0b1e5458
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
endif
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(BRCM_SDK_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
export CONFIG_BCM_CFE_PASSWORD
|
||||
export CONFIG_BCM_KERNEL_PROFILE
|
||||
export CONFIG_SECURE_BOOT_CFE
|
||||
|
||||
|
||||
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
|
||||
BCM_KERNEL_VERSION:=3.4.11-rt19
|
||||
BCM_SDK_VERSION:=bcm963xx
|
||||
RSTRIP:=true
|
||||
|
||||
|
||||
define Package/bcmkernel/removevoice
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
|
||||
define Package/bcmkernel/removevoice
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removesound
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
endef
|
||||
|
||||
ifeq ($(BCM_USBSOUND_MODULES),y)
|
||||
define Package/bcmkernel/removesound
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/bcmkernel/removei2c
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_I2C),y)
|
||||
define Package/bcmkernel/removei2c
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removebluetooth
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bnep.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/btusb.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/rfcomm.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/hci_uart.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_BLUETOOTH),y)
|
||||
define Package/bcmkernel/removebluetooth
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko etc...
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/adsl
|
||||
$(INSTALL_DIR) $(1)/etc/wlan
|
||||
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
|
||||
|
||||
# Install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
|
||||
ifneq ($(CONFIG_BCM_OPEN),y)
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
endif
|
||||
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
|
||||
|
||||
# create symlink to kernel build directory
|
||||
rm -f $(BUILD_DIR)/bcmkernel
|
||||
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
|
||||
|
||||
# Install binaries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
|
||||
|
||||
rm -f $(1)/usr/sbin/dhcp6c
|
||||
rm -f $(1)/usr/sbin/dhcp6s
|
||||
rm -f $(1)/usr/sbin/dhcpc
|
||||
rm -f $(1)/usr/sbin/dhcpd
|
||||
rm -f $(1)/usr/sbin/dnsproxy
|
||||
rm -f $(1)/usr/sbin/httpd
|
||||
rm -f $(1)/usr/sbin/openssl
|
||||
rm -f $(1)/usr/sbin/racoon
|
||||
rm -f $(1)/usr/sbin/ripd
|
||||
rm -f $(1)/usr/sbin/send_cms_msg
|
||||
rm -f $(1)/usr/sbin/sshd
|
||||
rm -f $(1)/usr/sbin/ssk
|
||||
rm -f $(1)/usr/sbin/telnetd
|
||||
rm -f $(1)/usr/sbin/tr64c
|
||||
rm -f $(1)/usr/sbin/tr69c
|
||||
rm -f $(1)/usr/sbin/ubi*
|
||||
rm -f $(1)/usr/sbin/udhcpd
|
||||
rm -f $(1)/usr/sbin/upnp
|
||||
rm -f $(1)/usr/sbin/upnpd
|
||||
rm -f $(1)/usr/sbin/vodsl
|
||||
rm -f $(1)/usr/sbin/wlmngr
|
||||
rm -f $(1)/usr/sbin/zebra
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/init.d/bcm-base-drivers.sh $(1)/lib/
|
||||
if [ -a $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/rdpa_init.sh ]; then $(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/rdpa_init.sh $(1)/etc/; fi;
|
||||
|
||||
|
||||
# Install libraries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
|
||||
|
||||
rm -f $(1)/usr/lib/ld-uClibc.so.0
|
||||
rm -f $(1)/usr/lib/libc.so.0
|
||||
rm -f $(1)/usr/lib/libdl.so.0
|
||||
rm -f $(1)/usr/lib/libgcc_s.so.1
|
||||
rm -f $(1)/usr/lib/libpthread.so.0
|
||||
rm -f $(1)/usr/lib/libm.so.0
|
||||
rm -f $(1)/usr/lib/libutil.so.0
|
||||
rm -f $(1)/usr/lib/libcms_boardctl.so
|
||||
rm -f $(1)/usr/lib/libcms_msg.so
|
||||
rm -f $(1)/usr/lib/libcms_util.so
|
||||
rm -f $(1)/usr/lib/libnvram.so
|
||||
rm -f $(1)/usr/lib/libcrypt.so.0
|
||||
rm -f $(1)/usr/lib/libbcm_crc.so
|
||||
rm -f $(1)/usr/lib/libbcm_flashutil.so
|
||||
|
||||
rm -f $(1)/usr/lib/libcrypto.so
|
||||
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so
|
||||
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libssl.so
|
||||
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so
|
||||
rm -f $(1)/usr/lib/libssl.so.0.9.7
|
||||
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so.0.9.7
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
|
||||
$(CP) --remove-destination $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
|
||||
|
||||
rm -rf $(1)/usr/lib/modules
|
||||
rm -rf $(1)/usr/lib/private
|
||||
rm -rf $(1)/usr/lib/public
|
||||
rm -rf $(1)/usr/lib/gpl
|
||||
|
||||
# Install kernel modules
|
||||
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
|
||||
mkdir -p $(1)/lib/modules/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
#cp -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
|
||||
|
||||
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
|
||||
|
||||
# Alternative DECT modules taken from the Natalie package and if that is not selected, no DECT modules should be loaded
|
||||
rm -f $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/dect.ko
|
||||
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
|
||||
|
||||
# bootloader nor
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
|
||||
|
||||
# ram part of the bootloader for nand boot
|
||||
if [ -a $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin ]; then cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001; fi;
|
||||
if [ -a $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID)ram.bin ]; then cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID)ram.bin $(KDIR)/cferam.001; fi;
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
|
||||
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
|
||||
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
|
||||
|
||||
$(call Package/bcmkernel/removevoice,$(1))
|
||||
$(call Package/bcmkernel/removesound,$(1))
|
||||
# $(call Package/bcmkernel/removei2c,$(1))
|
||||
endef
|
||||
|
||||
|
|
@ -1,268 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
# update this based on the Broadcom SDK version, 4.16L.04 -> 416040
|
||||
BRCM_SDK_VERSION:=416040
|
||||
|
||||
ifneq ($(CONFIG_BCM_OPEN),y)
|
||||
PKG_NAME:=bcmkernel-3.4
|
||||
PKG_VERSION:=$(BRCM_SDK_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
PKG_SOURCE_VERSION:=963801c26cf4c86c53952a28e806cc233e5b62be
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(BRCM_SDK_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
endif
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(BRCM_SDK_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
export CONFIG_BCM_CFE_PASSWORD
|
||||
export CONFIG_BCM_KERNEL_PROFILE
|
||||
export CONFIG_SECURE_BOOT_CFE
|
||||
|
||||
|
||||
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
|
||||
BCM_KERNEL_VERSION:=3.4.11-rt19
|
||||
BCM_SDK_VERSION:=bcm963xx
|
||||
RSTRIP:=true
|
||||
|
||||
|
||||
define Package/bcmkernel/removevoice
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
|
||||
define Package/bcmkernel/removevoice
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removesound
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
endef
|
||||
|
||||
ifeq ($(BCM_USBSOUND_MODULES),y)
|
||||
define Package/bcmkernel/removesound
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/bcmkernel/removei2c
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_I2C),y)
|
||||
define Package/bcmkernel/removei2c
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removebluetooth
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bnep.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/btusb.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/rfcomm.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/hci_uart.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_BLUETOOTH),y)
|
||||
define Package/bcmkernel/removebluetooth
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bluetooth.ko etc...
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/install
|
||||
$(INSTALL_DIR) $(1)/lib
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/adsl
|
||||
$(INSTALL_DIR) $(1)/etc/wlan
|
||||
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
|
||||
|
||||
# Install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
|
||||
ifneq ($(CONFIG_BCM_OPEN),y)
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
endif
|
||||
echo "#define BCM_SDK_VERSION $(BRCM_SDK_VERSION)" > $(STAGING_DIR)/usr/include/bcm_sdk_version.h
|
||||
|
||||
# create symlink to kernel build directory
|
||||
rm -f $(BUILD_DIR)/bcmkernel
|
||||
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
|
||||
|
||||
# Install binaries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
|
||||
|
||||
rm -f $(1)/usr/sbin/dhcp6c
|
||||
rm -f $(1)/usr/sbin/dhcp6s
|
||||
rm -f $(1)/usr/sbin/dhcpc
|
||||
rm -f $(1)/usr/sbin/dhcpd
|
||||
rm -f $(1)/usr/sbin/dnsproxy
|
||||
rm -f $(1)/usr/sbin/httpd
|
||||
rm -f $(1)/usr/sbin/openssl
|
||||
rm -f $(1)/usr/sbin/racoon
|
||||
rm -f $(1)/usr/sbin/ripd
|
||||
rm -f $(1)/usr/sbin/send_cms_msg
|
||||
rm -f $(1)/usr/sbin/sshd
|
||||
rm -f $(1)/usr/sbin/ssk
|
||||
rm -f $(1)/usr/sbin/telnetd
|
||||
rm -f $(1)/usr/sbin/tr64c
|
||||
rm -f $(1)/usr/sbin/tr69c
|
||||
rm -f $(1)/usr/sbin/ubi*
|
||||
rm -f $(1)/usr/sbin/udhcpd
|
||||
rm -f $(1)/usr/sbin/upnp
|
||||
rm -f $(1)/usr/sbin/upnpd
|
||||
rm -f $(1)/usr/sbin/vodsl
|
||||
rm -f $(1)/usr/sbin/wlmngr
|
||||
rm -f $(1)/usr/sbin/zebra
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/init.d/bcm-base-drivers.sh $(1)/lib/
|
||||
sed -i '/bcm_usb\.ko/d' $(1)/lib/bcm-base-drivers.sh
|
||||
sed -i 's|/kernel/.*/|/|' $(1)/lib/bcm-base-drivers.sh
|
||||
|
||||
if [ -a $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/rdpa_init.sh ]; then $(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/rdpa_init.sh $(1)/etc/; fi;
|
||||
|
||||
|
||||
# Install libraries
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
|
||||
|
||||
rm -f $(1)/usr/lib/ld-uClibc.so.0
|
||||
rm -f $(1)/usr/lib/libc.so.0
|
||||
rm -f $(1)/usr/lib/libdl.so.0
|
||||
rm -f $(1)/usr/lib/libgcc_s.so.1
|
||||
rm -f $(1)/usr/lib/libpthread.so.0
|
||||
rm -f $(1)/usr/lib/libm.so.0
|
||||
rm -f $(1)/usr/lib/libutil.so.0
|
||||
rm -f $(1)/usr/lib/libcrypt.so.0
|
||||
|
||||
rm -f $(1)/usr/lib/libcrypto.so
|
||||
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so
|
||||
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
ln -s /usr/lib/libcrypto.so.1.0.0 $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libssl.so
|
||||
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so
|
||||
rm -f $(1)/usr/lib/libssl.so.0.9.7
|
||||
ln -s /usr/lib/libssl.so.1.0.0 $(1)/usr/lib/libssl.so.0.9.7
|
||||
|
||||
rm -rf $(1)/usr/lib/modules
|
||||
rm -rf $(1)/usr/lib/private
|
||||
rm -rf $(1)/usr/lib/public
|
||||
rm -rf $(1)/usr/lib/gpl
|
||||
|
||||
# Install kernel modules
|
||||
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
#cp -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
|
||||
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
|
||||
|
||||
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
|
||||
|
||||
# Alternative DECT modules taken from the Natalie package and if that is not selected, no DECT modules should be loaded
|
||||
rm -f $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/dect.ko
|
||||
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
|
||||
|
||||
# bootloader nor
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
|
||||
|
||||
# ram part of the bootloader for nand boot
|
||||
if [ -a $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin ]; then cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.001; fi;
|
||||
if [ -a $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID)ram.bin ]; then cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID)ram.bin $(KDIR)/cferam.001; fi;
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
|
||||
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
|
||||
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
|
||||
|
||||
$(call Package/bcmkernel/removevoice,$(1))
|
||||
$(call Package/bcmkernel/removesound,$(1))
|
||||
# $(call Package/bcmkernel/removei2c,$(1))
|
||||
endef
|
||||
|
||||
|
|
@ -1,97 +0,0 @@
|
|||
menu "Profile and CFE"
|
||||
depends on PACKAGE_bcmkernel
|
||||
|
||||
config BCM_OPEN
|
||||
bool
|
||||
prompt "Build package for Public SDK"
|
||||
default n
|
||||
help
|
||||
Set this to build an package using a release tarball with the proprietary components removed.
|
||||
|
||||
choice
|
||||
prompt "Broadcom SDK version"
|
||||
default BRCM_SDK_VER_416030
|
||||
help
|
||||
Version of the Broadcom SDK to use.
|
||||
|
||||
config BRCM_SDK_VER_414040
|
||||
bool
|
||||
prompt "bcmkernel-4.14L.04"
|
||||
|
||||
config BRCM_SDK_VER_416021
|
||||
bool
|
||||
prompt "bcmkernel-4.16L.02A"
|
||||
|
||||
config BRCM_SDK_VER_416030
|
||||
bool
|
||||
prompt "bcmkernel-4.16L.03"
|
||||
|
||||
config BRCM_SDK_VER_416040
|
||||
bool
|
||||
prompt "bcmkernel-4.16L.04"
|
||||
|
||||
endchoice
|
||||
|
||||
config BCM_KERNEL_PROFILE
|
||||
string
|
||||
prompt "Broadcom kernel profile"
|
||||
default "96368GWV"
|
||||
help
|
||||
Profile to build the broadcom software with, 96368GWV, 963268GWV, 96362GWV, 96816GWV, 96816OV
|
||||
|
||||
config BCM_CFE_PASSWORD
|
||||
string
|
||||
prompt "Broadcom cfe password"
|
||||
default ""
|
||||
|
||||
config BCM_CHIP_ID
|
||||
string
|
||||
prompt "Broadcom chip id"
|
||||
default "6368"
|
||||
help
|
||||
Chip id to build the cfe with, 6328|6362|6368|6816|63268
|
||||
|
||||
config BCM_BLNAND
|
||||
string
|
||||
prompt "Broadcom boot loader nand"
|
||||
default "0"
|
||||
help
|
||||
Set this to 1 to build a boot loader for nand flash
|
||||
|
||||
config BCM_ENDPOINT_MODULE
|
||||
bool
|
||||
prompt "Broadcom endpoint voice FXS support"
|
||||
default y
|
||||
help
|
||||
Set this to include the endpoint module in image
|
||||
|
||||
config BCM_USBSOUND_MODULES
|
||||
bool
|
||||
prompt "Broadcom USB audio support"
|
||||
default n
|
||||
help
|
||||
Set this to include sound support modules in image
|
||||
|
||||
|
||||
config BCM_I2C
|
||||
bool
|
||||
prompt "Broadcom I2C support"
|
||||
default n
|
||||
help
|
||||
Set this to include the i2c modules in image
|
||||
|
||||
config BCM_BLUETOOTH
|
||||
bool
|
||||
prompt "Broadcom Bluetooth support"
|
||||
default n
|
||||
help
|
||||
Set this to include the Bluetooth modules in image
|
||||
|
||||
|
||||
config SECURE_BOOT_CFE
|
||||
prompt "Secure boot CFE"
|
||||
bool
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#
|
||||
# Primary/common bcmkernel makefile for all versions of Broadcom SDKs
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
define Package/bcmkernel
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Broadcom sdk 3.4 kernel
|
||||
URL:=
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/bcmkernel/description
|
||||
Broadcom kernel and userspace, compiled with the broadcom supplied tool-chain.
|
||||
endef
|
||||
|
||||
define Package/bcmkernel/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
# Include SDK version specific makefile based on config selection
|
||||
ifeq ($(CONFIG_ARCH),)
|
||||
include $(TOPDIR)/.config
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BCM_OPEN),y)
|
||||
PKG_NAME:=bcmopen
|
||||
PKG_VERSION:=consumer
|
||||
PKG_RELEASE:=1
|
||||
|
||||
TARGET_VERSION=$(shell echo $(CONFIG_TARGET_VERSION) | sed s/\"//g)
|
||||
TARGET_IBOARDID=$(shell echo $(CONFIG_TARGET_IBOARDID) | sed s/\"//g)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).$(TARGET_VERSION).$(TARGET_IBOARDID).tar.gz
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/ihgsp/consumer/
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BRCM_SDK_VER_414040),y)
|
||||
include ./414040.mk
|
||||
|
||||
else ifeq ($(CONFIG_BRCM_SDK_VER_416021),y)
|
||||
include ./416021.mk
|
||||
|
||||
else ifeq ($(CONFIG_BRCM_SDK_VER_416030),y)
|
||||
include ./416030.mk
|
||||
|
||||
else ifeq ($(CONFIG_BRCM_SDK_VER_416040),y)
|
||||
include ./416040.mk
|
||||
|
||||
else
|
||||
# Make 'make menuconfig' work even though no SDK version specified
|
||||
PKG_VERSION:=none
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
endif
|
||||
|
||||
# hack to be able to compile just the userspace part.
|
||||
# TOPDIR=$PWD make -C package/bcmkernel userspace
|
||||
userspace:
|
||||
$(call Build/Compile/Default, userspace)
|
||||
|
||||
$(eval $(call BuildPackage,bcmkernel))
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=brcm-h
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:brcm-h
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=HEAD
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
|
||||
|
||||
define Package/brcm-h
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Broadcom header files
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/brcm-h/description
|
||||
Broadcom header files
|
||||
endef
|
||||
|
||||
|
||||
define Package/brcm--h/install
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/brcm
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/codec/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/xchg_drivers/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
|
||||
endef
|
||||
|
||||
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,brcm-h))
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2009 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_NAME:=brcm_fw_tool
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/brcm_fw_tool
|
||||
SECTION:=utils
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Update utility for Broadcom nand firmware images
|
||||
DEPENDS:=bcmkernel
|
||||
endef
|
||||
|
||||
define Package/brcm_fw_tool/description
|
||||
This package contains an utility useful to upgrade from other firmware or
|
||||
older OpenWrt releases.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
ifdef CONFIG_MTD_REDBOOT_PARTS
|
||||
MAKE_FLAGS += FIS_SUPPORT=1
|
||||
TARGET_CFLAGS += -DFIS_SUPPORT=1
|
||||
endif
|
||||
|
||||
define Package/brcm_fw_tool/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/brcm_fw_tool $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,brcm_fw_tool))
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
CC = gcc
|
||||
CFLAGS += -Wall
|
||||
|
||||
CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx/
|
||||
CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj = brcm_fw_tool.o jffs2.o crc32.o
|
||||
obj.brcm47xx = $(obj.brcm)
|
||||
|
||||
brcm_fw_tool: $(obj) $(obj.$(TARGET))
|
||||
clean:
|
||||
rm -f *.o jffs2
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef __mtd_h
|
||||
#define __mtd_h
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define JFFS2_EOF "\xde\xad\xc0\xde"
|
||||
|
||||
extern int quiet;
|
||||
extern int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename, int nand_erasesize);
|
||||
|
||||
#endif /* __mtd_h */
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
|
||||
* code or tables extracted from it, as desired without restriction.
|
||||
*
|
||||
* First, the polynomial itself and its table of feedback terms. The
|
||||
* polynomial is
|
||||
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
|
||||
*
|
||||
* Note that we take it "backwards" and put the highest-order term in
|
||||
* the lowest-order bit. The X^32 term is "implied"; the LSB is the
|
||||
* X^31 term, etc. The X^0 term (usually shown as "+1") results in
|
||||
* the MSB being 1
|
||||
*
|
||||
* Note that the usual hardware shift register implementation, which
|
||||
* is what we're using (we're merely optimizing it by doing eight-bit
|
||||
* chunks at a time) shifts bits into the lowest-order term. In our
|
||||
* implementation, that means shifting towards the right. Why do we
|
||||
* do it this way? Because the calculated CRC must be transmitted in
|
||||
* order from highest-order term to lowest-order term. UARTs transmit
|
||||
* characters in order from LSB to MSB. By storing the CRC this way
|
||||
* we hand it to the UART in the order low-byte to high-byte; the UART
|
||||
* sends each low-bit to hight-bit; and the result is transmission bit
|
||||
* by bit from highest- to lowest-order term without requiring any bit
|
||||
* shuffling on our part. Reception works similarly
|
||||
*
|
||||
* The feedback terms table consists of 256, 32-bit entries. Notes
|
||||
*
|
||||
* The table can be generated at runtime if desired; code to do so
|
||||
* is shown later. It might not be obvious, but the feedback
|
||||
* terms simply represent the results of eight shift/xor opera
|
||||
* tions for all combinations of data and CRC register values
|
||||
*
|
||||
* The values must be right-shifted by eight bits by the "updcrc
|
||||
* logic; the shift must be unsigned (bring in zeroes). On some
|
||||
* hardware you could probably optimize the shift in assembler by
|
||||
* using byte-swap instructions
|
||||
* polynomial $edb88320
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
const uint32_t crc32_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint32_t crc32_table[256];
|
||||
|
||||
/* Return a 32-bit CRC of the contents of the buffer. */
|
||||
|
||||
static inline uint32_t
|
||||
crc32(uint32_t val, const void *ss, int len)
|
||||
{
|
||||
const unsigned char *s = ss;
|
||||
while (--len >= 0)
|
||||
val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline unsigned int crc32buf(char *buf, size_t len)
|
||||
{
|
||||
return crc32(0xFFFFFFFF, buf, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
/*
|
||||
* jffs2 on-disk structure generator for mtd
|
||||
*
|
||||
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License v2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* Based on:
|
||||
* JFFS2 -- Journalling Flash File System, Version 2.
|
||||
* Copyright © 2001-2007 Red Hat, Inc.
|
||||
* Created by David Woodhouse <dwmw2@infradead.org>
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <endian.h>
|
||||
#include "jffs2.h"
|
||||
#include "crc32.h"
|
||||
#include "brcm_fw_tool.h"
|
||||
|
||||
#define PAD(x) (((x)+3)&~3)
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
# define CLEANMARKER "\x19\x85\x20\x03\x00\x00\x00\x0c\xf0\x60\xdc\x98"
|
||||
#else
|
||||
# define CLEANMARKER "\x85\x19\x03\x20\x0c\x00\x00\x00\xb1\xb0\x1e\xe4"
|
||||
#endif
|
||||
|
||||
static int last_ino = 0;
|
||||
static int last_version = 0;
|
||||
static char *buf = NULL;
|
||||
static int ofs = 0;
|
||||
static int outfd = -1;
|
||||
static int mtdofs = 0;
|
||||
static int target_ino = 0;
|
||||
static int erasesize = 128*1024;
|
||||
|
||||
static void prep_eraseblock(void);
|
||||
|
||||
static void pad(int size)
|
||||
{
|
||||
if ((ofs % size == 0) && (ofs < erasesize))
|
||||
return;
|
||||
|
||||
if (ofs < erasesize) {
|
||||
memset(buf + ofs, 0xff, (size - (ofs % size)));
|
||||
ofs += (size - (ofs % size));
|
||||
}
|
||||
ofs = ofs % erasesize;
|
||||
if (ofs == 0) {
|
||||
write(outfd, buf, erasesize);
|
||||
mtdofs += erasesize;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int rbytes(void)
|
||||
{
|
||||
return erasesize - (ofs % erasesize);
|
||||
}
|
||||
|
||||
static inline void add_data(char *ptr, int len)
|
||||
{
|
||||
if (ofs + len > erasesize) {
|
||||
pad(erasesize);
|
||||
prep_eraseblock();
|
||||
}
|
||||
memcpy(buf + ofs, ptr, len);
|
||||
ofs += len;
|
||||
}
|
||||
|
||||
static void prep_eraseblock(void)
|
||||
{
|
||||
if (ofs > 0)
|
||||
return;
|
||||
|
||||
add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1);
|
||||
}
|
||||
|
||||
static int add_dirent(const char *name, const char type, int parent)
|
||||
{
|
||||
struct jffs2_raw_dirent *de;
|
||||
|
||||
if (ofs - erasesize < sizeof(struct jffs2_raw_dirent) + strlen(name))
|
||||
pad(erasesize);
|
||||
|
||||
prep_eraseblock();
|
||||
last_ino++;
|
||||
memset(buf + ofs, 0, sizeof(struct jffs2_raw_dirent));
|
||||
de = (struct jffs2_raw_dirent *) (buf + ofs);
|
||||
|
||||
de->magic = JFFS2_MAGIC_BITMASK;
|
||||
de->nodetype = JFFS2_NODETYPE_DIRENT;
|
||||
de->type = type;
|
||||
de->name_crc = crc32(0, name, strlen(name));
|
||||
de->ino = last_ino++;
|
||||
de->pino = parent;
|
||||
de->totlen = sizeof(*de) + strlen(name);
|
||||
de->hdr_crc = crc32(0, (void *) de, sizeof(struct jffs2_unknown_node) - 4);
|
||||
de->version = last_version++;
|
||||
de->mctime = 0;
|
||||
de->nsize = strlen(name);
|
||||
de->node_crc = crc32(0, (void *) de, sizeof(*de) - 8);
|
||||
memcpy(de->name, name, strlen(name));
|
||||
|
||||
ofs += sizeof(struct jffs2_raw_dirent) + de->nsize;
|
||||
pad(4);
|
||||
|
||||
return de->ino;
|
||||
}
|
||||
|
||||
static int add_dir(const char *name, int parent)
|
||||
{
|
||||
struct jffs2_raw_inode ri;
|
||||
int inode;
|
||||
|
||||
inode = add_dirent(name, IFTODT(S_IFDIR), parent);
|
||||
|
||||
if (rbytes() < sizeof(ri))
|
||||
pad(erasesize);
|
||||
prep_eraseblock();
|
||||
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
ri.magic = JFFS2_MAGIC_BITMASK;
|
||||
ri.nodetype = JFFS2_NODETYPE_INODE;
|
||||
ri.totlen = sizeof(ri);
|
||||
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
|
||||
|
||||
ri.ino = inode;
|
||||
ri.mode = S_IFDIR | 0755;
|
||||
ri.uid = ri.gid = 0;
|
||||
ri.atime = ri.ctime = ri.mtime = 0;
|
||||
ri.isize = ri.csize = ri.dsize = 0;
|
||||
ri.version = 1;
|
||||
ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
|
||||
ri.data_crc = 0;
|
||||
|
||||
add_data((char *) &ri, sizeof(ri));
|
||||
pad(4);
|
||||
return inode;
|
||||
}
|
||||
|
||||
static void add_file(const char *name, int parent)
|
||||
{
|
||||
int inode, f_offset = 0, fd;
|
||||
struct jffs2_raw_inode ri;
|
||||
struct stat st;
|
||||
char wbuf[4096];
|
||||
const char *fname;
|
||||
|
||||
if (stat(name, &st)) {
|
||||
fprintf(stderr, "File %s does not exist\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
fname = strrchr(name, '/');
|
||||
if (fname)
|
||||
fname++;
|
||||
else
|
||||
fname = name;
|
||||
|
||||
inode = add_dirent(fname, IFTODT(S_IFREG), parent);
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
ri.magic = JFFS2_MAGIC_BITMASK;
|
||||
ri.nodetype = JFFS2_NODETYPE_INODE;
|
||||
|
||||
ri.ino = inode;
|
||||
ri.mode = st.st_mode;
|
||||
ri.uid = ri.gid = 0;
|
||||
ri.atime = st.st_atime;
|
||||
ri.ctime = st.st_ctime;
|
||||
ri.mtime = st.st_mtime;
|
||||
ri.isize = st.st_size;
|
||||
ri.compr = 0;
|
||||
ri.usercompr = 0;
|
||||
|
||||
fd = open(name, 0);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "File %s does not exist\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int len = 0;
|
||||
|
||||
for (;;) {
|
||||
len = rbytes() - sizeof(ri);
|
||||
if (len > 128)
|
||||
break;
|
||||
|
||||
pad(erasesize);
|
||||
prep_eraseblock();
|
||||
}
|
||||
|
||||
if (len > sizeof(wbuf))
|
||||
len = sizeof(wbuf);
|
||||
|
||||
len = read(fd, wbuf, len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
|
||||
ri.totlen = sizeof(ri) + len;
|
||||
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
|
||||
ri.version = ++last_version;
|
||||
ri.offset = f_offset;
|
||||
ri.csize = ri.dsize = len;
|
||||
ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
|
||||
ri.data_crc = crc32(0, wbuf, len);
|
||||
f_offset += len;
|
||||
add_data((char *) &ri, sizeof(ri));
|
||||
add_data(wbuf, len);
|
||||
pad(4);
|
||||
prep_eraseblock();
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename, int nand_erasesize)
|
||||
{
|
||||
outfd = fd;
|
||||
mtdofs = ofs;
|
||||
erasesize = nand_erasesize;
|
||||
|
||||
buf = malloc(erasesize);
|
||||
target_ino = 1;
|
||||
if (!last_ino)
|
||||
last_ino = 1;
|
||||
add_file(filename, target_ino);
|
||||
pad(erasesize);
|
||||
|
||||
/* add eof marker, pad to eraseblock size and write the data */
|
||||
add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
|
||||
pad(erasesize);
|
||||
free(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mtd_parse_jffs2data(const char *buf, const char *dir)
|
||||
{
|
||||
struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
|
||||
unsigned int ofs = 0;
|
||||
|
||||
while (ofs < erasesize) {
|
||||
node = (struct jffs2_unknown_node *) (buf + ofs);
|
||||
if (node->magic != 0x1985)
|
||||
break;
|
||||
|
||||
ofs += PAD(node->totlen);
|
||||
if (node->nodetype == JFFS2_NODETYPE_DIRENT) {
|
||||
struct jffs2_raw_dirent *de = (struct jffs2_raw_dirent *) node;
|
||||
|
||||
/* is this the right directory name and is it a subdirectory of / */
|
||||
if (*dir && (de->pino == 1) && !strncmp((char *) de->name, dir, de->nsize))
|
||||
target_ino = de->ino;
|
||||
|
||||
/* store the last inode and version numbers for adding extra files */
|
||||
if (last_ino < de->ino)
|
||||
last_ino = de->ino;
|
||||
if (last_version < de->version)
|
||||
last_version = de->version;
|
||||
}
|
||||
}
|
||||
}
|
||||
int quiet = 0;
|
||||
int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir)
|
||||
{
|
||||
int err = -1, fdeof = 0;
|
||||
|
||||
if (quiet < 2)
|
||||
fprintf(stderr, "Appending %s to jffs2 partition %s\n", filename, mtd);
|
||||
|
||||
buf = malloc(erasesize);
|
||||
if (!buf) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!*dir)
|
||||
target_ino = 1;
|
||||
|
||||
/* parse the structure of the jffs2 first
|
||||
* locate the directory that the file is going to be placed in */
|
||||
for(;;) {
|
||||
struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
|
||||
|
||||
if (read(outfd, buf, erasesize) != erasesize) {
|
||||
fdeof = 1;
|
||||
break;
|
||||
}
|
||||
mtdofs += erasesize;
|
||||
|
||||
if (node->magic == 0x8519) {
|
||||
fprintf(stderr, "Error: wrong endianness filesystem\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* assume no magic == end of filesystem
|
||||
* the filesystem will probably end with be32(0xdeadc0de) */
|
||||
if (node->magic != 0x1985)
|
||||
break;
|
||||
|
||||
mtd_parse_jffs2data(buf, dir);
|
||||
}
|
||||
|
||||
if (fdeof) {
|
||||
fprintf(stderr, "Error: No room for additional data\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* jump back one eraseblock */
|
||||
mtdofs -= erasesize;
|
||||
lseek(outfd, mtdofs, SEEK_SET);
|
||||
|
||||
ofs = 0;
|
||||
|
||||
if (!last_ino)
|
||||
last_ino = 1;
|
||||
|
||||
if (!target_ino)
|
||||
target_ino = add_dir(dir, 1);
|
||||
|
||||
add_file(filename, target_ino);
|
||||
pad(erasesize);
|
||||
|
||||
/* add eof marker, pad to eraseblock size and write the data */
|
||||
add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
|
||||
pad(erasesize);
|
||||
|
||||
err = 0;
|
||||
|
||||
done:
|
||||
close(outfd);
|
||||
if (buf)
|
||||
free(buf);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
@ -1,216 +0,0 @@
|
|||
/*
|
||||
* JFFS2 -- Journalling Flash File System, Version 2.
|
||||
*
|
||||
* Copyright (C) 2001-2003 Red Hat, Inc.
|
||||
*
|
||||
* Created by David Woodhouse <dwmw2@infradead.org>
|
||||
*
|
||||
* For licensing information, see the file 'LICENCE' in the
|
||||
* jffs2 directory.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_JFFS2_H__
|
||||
#define __LINUX_JFFS2_H__
|
||||
|
||||
#define JFFS2_SUPER_MAGIC 0x72b6
|
||||
|
||||
/* You must include something which defines the C99 uintXX_t types.
|
||||
We don't do it from here because this file is used in too many
|
||||
different environments. */
|
||||
|
||||
/* Values we may expect to find in the 'magic' field */
|
||||
#define JFFS2_OLD_MAGIC_BITMASK 0x1984
|
||||
#define JFFS2_MAGIC_BITMASK 0x1985
|
||||
#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
|
||||
#define JFFS2_EMPTY_BITMASK 0xffff
|
||||
#define JFFS2_DIRTY_BITMASK 0x0000
|
||||
|
||||
/* Summary node MAGIC marker */
|
||||
#define JFFS2_SUM_MAGIC 0x02851885
|
||||
|
||||
/* We only allow a single char for length, and 0xFF is empty flash so
|
||||
we don't want it confused with a real length. Hence max 254.
|
||||
*/
|
||||
#define JFFS2_MAX_NAME_LEN 254
|
||||
|
||||
/* How small can we sensibly write nodes? */
|
||||
#define JFFS2_MIN_DATA_LEN 128
|
||||
|
||||
#define JFFS2_COMPR_NONE 0x00
|
||||
#define JFFS2_COMPR_ZERO 0x01
|
||||
#define JFFS2_COMPR_RTIME 0x02
|
||||
#define JFFS2_COMPR_RUBINMIPS 0x03
|
||||
#define JFFS2_COMPR_COPY 0x04
|
||||
#define JFFS2_COMPR_DYNRUBIN 0x05
|
||||
#define JFFS2_COMPR_ZLIB 0x06
|
||||
/* Compatibility flags. */
|
||||
#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
|
||||
#define JFFS2_NODE_ACCURATE 0x2000
|
||||
/* INCOMPAT: Fail to mount the filesystem */
|
||||
#define JFFS2_FEATURE_INCOMPAT 0xc000
|
||||
/* ROCOMPAT: Mount read-only */
|
||||
#define JFFS2_FEATURE_ROCOMPAT 0x8000
|
||||
/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
|
||||
#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
|
||||
/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
|
||||
#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
|
||||
|
||||
#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
|
||||
#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
|
||||
#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
|
||||
#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
|
||||
|
||||
#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
|
||||
|
||||
#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
|
||||
#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
|
||||
|
||||
/* XATTR Related */
|
||||
#define JFFS2_XPREFIX_USER 1 /* for "user." */
|
||||
#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
|
||||
#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
|
||||
#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
|
||||
#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
|
||||
|
||||
#define JFFS2_ACL_VERSION 0x0001
|
||||
|
||||
// Maybe later...
|
||||
//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
|
||||
//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
|
||||
|
||||
|
||||
#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
|
||||
mount time, don't wait for it to
|
||||
happen later */
|
||||
#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
|
||||
compression type */
|
||||
|
||||
|
||||
/* These can go once we've made sure we've caught all uses without
|
||||
byteswapping */
|
||||
|
||||
typedef uint32_t jint32_t;
|
||||
|
||||
typedef uint32_t jmode_t;
|
||||
|
||||
typedef uint16_t jint16_t;
|
||||
|
||||
struct jffs2_unknown_node
|
||||
{
|
||||
/* All start like this */
|
||||
jint16_t magic;
|
||||
jint16_t nodetype;
|
||||
jint32_t totlen; /* So we can skip over nodes we don't grok */
|
||||
jint32_t hdr_crc;
|
||||
};
|
||||
|
||||
struct jffs2_raw_dirent
|
||||
{
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t pino;
|
||||
jint32_t version;
|
||||
jint32_t ino; /* == zero for unlink */
|
||||
jint32_t mctime;
|
||||
uint8_t nsize;
|
||||
uint8_t type;
|
||||
uint8_t unused[2];
|
||||
jint32_t node_crc;
|
||||
jint32_t name_crc;
|
||||
uint8_t name[0];
|
||||
};
|
||||
|
||||
/* The JFFS2 raw inode structure: Used for storage on physical media. */
|
||||
/* The uid, gid, atime, mtime and ctime members could be longer, but
|
||||
are left like this for space efficiency. If and when people decide
|
||||
they really need them extended, it's simple enough to add support for
|
||||
a new type of raw node.
|
||||
*/
|
||||
struct jffs2_raw_inode
|
||||
{
|
||||
jint16_t magic; /* A constant magic number. */
|
||||
jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
|
||||
jint32_t totlen; /* Total length of this node (inc data, etc.) */
|
||||
jint32_t hdr_crc;
|
||||
jint32_t ino; /* Inode number. */
|
||||
jint32_t version; /* Version number. */
|
||||
jmode_t mode; /* The file's type or mode. */
|
||||
jint16_t uid; /* The file's owner. */
|
||||
jint16_t gid; /* The file's group. */
|
||||
jint32_t isize; /* Total resultant size of this inode (used for truncations) */
|
||||
jint32_t atime; /* Last access time. */
|
||||
jint32_t mtime; /* Last modification time. */
|
||||
jint32_t ctime; /* Change time. */
|
||||
jint32_t offset; /* Where to begin to write. */
|
||||
jint32_t csize; /* (Compressed) data size */
|
||||
jint32_t dsize; /* Size of the node's data. (after decompression) */
|
||||
uint8_t compr; /* Compression algorithm used */
|
||||
uint8_t usercompr; /* Compression algorithm requested by the user */
|
||||
jint16_t flags; /* See JFFS2_INO_FLAG_* */
|
||||
jint32_t data_crc; /* CRC for the (compressed) data. */
|
||||
jint32_t node_crc; /* CRC for the raw inode (excluding data) */
|
||||
uint8_t data[0];
|
||||
};
|
||||
|
||||
struct jffs2_raw_xattr {
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t xid; /* XATTR identifier number */
|
||||
jint32_t version;
|
||||
uint8_t xprefix;
|
||||
uint8_t name_len;
|
||||
jint16_t value_len;
|
||||
jint32_t data_crc;
|
||||
jint32_t node_crc;
|
||||
uint8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct jffs2_raw_xref
|
||||
{
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t ino; /* inode number */
|
||||
jint32_t xid; /* XATTR identifier number */
|
||||
jint32_t xseqno; /* xref sequencial number */
|
||||
jint32_t node_crc;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct jffs2_raw_summary
|
||||
{
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t sum_num; /* number of sum entries*/
|
||||
jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
|
||||
jint32_t padded; /* sum of the size of padding nodes */
|
||||
jint32_t sum_crc; /* summary information crc */
|
||||
jint32_t node_crc; /* node crc */
|
||||
jint32_t sum[0]; /* inode summary info */
|
||||
};
|
||||
|
||||
union jffs2_node_union
|
||||
{
|
||||
struct jffs2_raw_inode i;
|
||||
struct jffs2_raw_dirent d;
|
||||
struct jffs2_raw_xattr x;
|
||||
struct jffs2_raw_xref r;
|
||||
struct jffs2_raw_summary s;
|
||||
struct jffs2_unknown_node u;
|
||||
};
|
||||
|
||||
/* Data payload for device nodes. */
|
||||
union jffs2_device_node {
|
||||
jint16_t old;
|
||||
jint32_t new;
|
||||
};
|
||||
|
||||
#endif /* __LINUX_JFFS2_H__ */
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=brcminfo
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/brcminfo
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom voice driver info utility
|
||||
URL:=
|
||||
DEPENDS:= bcmkernel
|
||||
endef
|
||||
|
||||
define Package/brcminfo/description
|
||||
Utility that prints information regarding voice configuration
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
|
||||
|
||||
EXTRA_CFLAGS += -DBOS_OS_LINUXUSER
|
||||
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
|
||||
TARGET_CFLAGS += -D$(CONFIG_TARGET_IBOARDID) -Dtarget_$(target)=1 -Wall
|
||||
|
||||
define Package/brcminfo/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/brcminfo $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,brcminfo))
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
# Makefile for brcminfo utility
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
OBJS = brcminfo.o
|
||||
all: main
|
||||
|
||||
dynamic: all
|
||||
|
||||
main: brcminfo.o
|
||||
$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -o brcminfo brcminfo.o -lm
|
||||
|
||||
clean:
|
||||
rm -f brcminfo ${OBJS}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
* brcminfo.c
|
||||
* Minor utility that will attempt to read the number of available
|
||||
* endpoints from the brcm voice driver
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <endpointdrv.h>
|
||||
|
||||
static int endpoint_fd = -1;
|
||||
static int num_fxs_endpoints = -1;
|
||||
static int num_fxo_endpoints = -1;
|
||||
static int num_dect_endpoints = -1;
|
||||
static int num_endpoints = -1;
|
||||
|
||||
int vrgEndptDriverOpen(void)
|
||||
{
|
||||
endpoint_fd = open("/dev/bcmendpoint0", O_RDWR);
|
||||
if (endpoint_fd == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int vrgEndptDriverClose(void)
|
||||
{
|
||||
int result = close(endpoint_fd);
|
||||
endpoint_fd = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int brcm_get_endpoints_count(void)
|
||||
{
|
||||
ENDPOINTDRV_ENDPOINTCOUNT_PARM endpointCount;
|
||||
endpointCount.size = sizeof(ENDPOINTDRV_ENDPOINTCOUNT_PARM);
|
||||
|
||||
if ( ioctl( endpoint_fd, ENDPOINTIOCTL_FXSENDPOINTCOUNT, &endpointCount ) != IOCTL_STATUS_SUCCESS ) {
|
||||
return -1;
|
||||
} else {
|
||||
num_fxs_endpoints = endpointCount.endpointNum;
|
||||
}
|
||||
|
||||
if ( ioctl( endpoint_fd, ENDPOINTIOCTL_FXOENDPOINTCOUNT, &endpointCount ) != IOCTL_STATUS_SUCCESS ) {
|
||||
return -1;
|
||||
} else {
|
||||
num_fxo_endpoints = endpointCount.endpointNum;
|
||||
}
|
||||
|
||||
if ( ioctl( endpoint_fd, ENDPOINTIOCTL_DECTENDPOINTCOUNT, &endpointCount ) != IOCTL_STATUS_SUCCESS ) {
|
||||
return -1;
|
||||
} else {
|
||||
num_dect_endpoints = endpointCount.endpointNum;
|
||||
}
|
||||
|
||||
num_endpoints = num_fxs_endpoints + num_fxo_endpoints + num_dect_endpoints;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = vrgEndptDriverOpen();
|
||||
if (result != 0) {
|
||||
printf("Could not open endpoint driver\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = brcm_get_endpoints_count();
|
||||
if (result == 0) {
|
||||
printf("DECT Endpoints:\t%d\n", num_dect_endpoints);
|
||||
printf("FXS Endpoints:\t%d\n", num_fxs_endpoints);
|
||||
printf("FXO Endpoints:\t%d\n", num_fxo_endpoints);
|
||||
printf("All Endpoints:\t%d\n", num_endpoints);
|
||||
}
|
||||
else {
|
||||
printf("Endpoint counting failed, maybe driver is not initialized?\n");
|
||||
}
|
||||
|
||||
result = vrgEndptDriverClose();
|
||||
if (result != 0) {
|
||||
printf("Could not close endpoint driver\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.0.23
|
||||
ifeq ($(CONFIG_BCM_OPEN),y)
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/dectmngr.git
|
||||
else
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:dectmngr.git
|
||||
endif
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=5f6f0608b59484d76c6331279cc50104be5d8a95
|
||||
PKG_NAME:=dectmngr
|
||||
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/dectmngr
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom endpoint test application
|
||||
URL:=
|
||||
DEPENDS:= +libevent2 +libjson +natalie-dect-h bcmkernel
|
||||
endef
|
||||
|
||||
define Package/dectmngr/description
|
||||
Dect proxy, manager and tools
|
||||
endef
|
||||
|
||||
|
||||
define Package/dectmngr/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/dect
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_DIR) $(1)/etc/dect/
|
||||
$(INSTALL_DIR) $(1)/etc/config/
|
||||
|
||||
cp $(PKG_BUILD_DIR)/dectmngr $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/atohx $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dectproxy $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dectdbgd $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dect $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dectcalib $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dect_testmode $(1)/usr/bin/
|
||||
cp files/etc/init.d/* $(1)/etc/init.d/
|
||||
cp files/etc/hotplug.d/dect/* $(1)/etc/hotplug.d/dect/
|
||||
cp files/etc/dect/* $(1)/etc/dect/
|
||||
cp files/etc/config/* $(1)/etc/config/
|
||||
cp files/sbin/dectreg $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dectmngr))
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
config dect 'dect'
|
||||
option 'radio' 'auto'
|
||||
|
||||
Binary file not shown.
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$ACTION" == "led_blink" ]; then
|
||||
ubus call led.dect set '{"state":"notice"}'
|
||||
fi
|
||||
|
||||
if [ "$ACTION" == "led_on" ]; then
|
||||
ubus call led.dect set '{"state":"ok"}'
|
||||
fi
|
||||
|
||||
if [ "$ACTION" == "led_off" ]; then
|
||||
ubus call led.dect set '{"state":"off"}'
|
||||
fi
|
||||
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=97
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
|
||||
DEST=
|
||||
DEFAULT=
|
||||
OPTIONS=""
|
||||
|
||||
|
||||
start_service() {
|
||||
# avoid fp timing problem
|
||||
echo 1 > /proc/sys/kernel/printk_with_interrupt_enabled
|
||||
|
||||
# setup board specific dect parameters
|
||||
cat /proc/nvram/rfpi | tr -d ' ' | atohx > /tmp/rfpi
|
||||
cat /proc/nvram/fixed_emc | tr -d ' ' | atohx > /tmp/fixed_emc
|
||||
cat /proc/nvram/bcm_def_freq | tr -d ' ' | atohx > /tmp/bcm_def_freq
|
||||
DECTANTDIV=`db get hw.board.DectAntennaDiversity`
|
||||
case "$DECTANTDIV" in
|
||||
1|off) echo -e "\x01" > /tmp/dect_antenna_diversity ;;
|
||||
2) echo -e "\x02" > /tmp/dect_antenna_diversity ;;
|
||||
*) echo -e "\x00" > /tmp/dect_antenna_diversity ;;
|
||||
esac
|
||||
|
||||
if [ ! -f /etc/dect/nvs ]; then
|
||||
cp /etc/dect/nvs_default /etc/dect/nvs
|
||||
dd of=/etc/dect/nvs if=/tmp/rfpi conv=notrunc bs=1 seek=0
|
||||
dd of=/etc/dect/nvs if=/tmp/fixed_emc conv=notrunc bs=1 seek=10
|
||||
dd of=/etc/dect/nvs if=/tmp/bcm_def_freq conv=notrunc bs=1 seek=6
|
||||
dd of=/etc/dect/nvs if=/tmp/dect_antenna_diversity conv=notrunc bs=1 seek=34
|
||||
fi
|
||||
|
||||
# init dectproxy
|
||||
dectproxy > /dev/null 2>&1 &
|
||||
dectmngr > /tmp/dectmngr 2>&1 &
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
killall -9 dectproxy
|
||||
killall -9 dectmngr
|
||||
}
|
||||
|
||||
restart_service() {
|
||||
echo "restarting dect"
|
||||
killall dectmngr
|
||||
dectmngr > /tmp/dectmngr 2>&1 &
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
# reload config
|
||||
dect -c
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger dect
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script is likely not used. Just exit with
|
||||
# an error and see if someone screems... If not,
|
||||
# we can delete this file.
|
||||
exit 1
|
||||
|
||||
|
||||
[ -f /var/dectisregistering ] || {
|
||||
touch /var/dectisregistering 2>/dev/null
|
||||
/usr/bin/dectmngr -r
|
||||
ubus call led.dect set '{"state" : "notice"}'
|
||||
sleep 20
|
||||
rm /var/dectisregistering 2>/dev/null
|
||||
/usr/bin/dectmngr -s
|
||||
ubus call led.dect set '{"state" : "ok"}'
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.1.0
|
||||
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:dectmngr2.git
|
||||
else
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/dectmngr2.git
|
||||
endif
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=a51f8ed1b9178262777f73f7c275d3962f829c8a
|
||||
PKG_NAME:=dectmngr2
|
||||
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/dectmngr2
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Dectmngr2
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/dectmngr2/description
|
||||
Dectmngr2
|
||||
endef
|
||||
|
||||
|
||||
define Package/dectmngr2/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/etc/dect/
|
||||
|
||||
cp $(PKG_BUILD_DIR)/src/dectmngr2 $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/files/target.bin $(1)/etc/dect/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dectmngr2))
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=endptcfg
|
||||
PKG_VERSION:=0.2
|
||||
PKG_RELEASE:=1
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:endptcfg
|
||||
PKG_SOURCE_VERSION:=1194b05278bd0945ca5c76436e56617b86871a65
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
BCMKERNEL_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx
|
||||
export BCMKERNEL_DIR
|
||||
|
||||
TARGET_LDFLAGS += $(BCMKERNEL_DIR)/userspace/private/apps/vodsl/telephonyProfiles/telephonyProfiles.o \
|
||||
$(BCMKERNEL_DIR)/userspace/private/apps/vodsl/voip/util/log/vodslLog.o \
|
||||
$(BCMKERNEL_DIR)/userspace/private/apps/vodsl/endpoint/endpoint_user.o \
|
||||
$(BCMKERNEL_DIR)/userspace/private/apps/vodsl/bos/bos.o \
|
||||
-lpthread
|
||||
|
||||
ifeq ($(CONFIG_BRCM_SDK_VER_416040),y)
|
||||
TARGET_CFLAGS += -DFAKE_SSP
|
||||
endif
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/endptcfg
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom endpoint driver configuration application
|
||||
URL:=
|
||||
DEPENDS:=+libpthread bcmkernel
|
||||
endef
|
||||
|
||||
define Package/endptcfg/description
|
||||
Broadcom endpoint driver configuration application
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
$(TARGET_CONFIGURE_OPTS) LINUX_DIR=$(LINUX_DIR) LDFLAGS="$(TARGET_LDFLAGS)" CFLAGS="$(TARGET_CFLAGS) \
|
||||
-I$(LINUX_DIR)/include \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-DRS_ENDIAN_TYPE=RS_BIG_ENDIAN \
|
||||
-DBOS_OS_LINUXUSER -DBOS_CFG_TIME \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser"
|
||||
endef
|
||||
|
||||
define Package/endptcfg/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/endptcfg $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,endptcfg))
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=benjamin
|
||||
PKG_SOURCE_URL:=ssh://inteno@ihgsp.inteno.se/home/inteno/private/git/$(PKG_VERSION)/endptctl.git
|
||||
|
||||
PKG_NAME:=endptctl
|
||||
PKG_VERSION:=0.1
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
BCMKERNEL_DIR:=$(BUILD_DIR)/bcmkernel-3.4-4.14/bcm963xx
|
||||
export BCMKERNEL_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/endptctl
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom endpoint test application
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/endptctl/description
|
||||
Broadcom endpoint test application
|
||||
endef
|
||||
|
||||
|
||||
define Package/endptctl/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/endptctl $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,endptctl))
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=natalie-dect-h
|
||||
PKG_VERSION:=11.19
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
ifeq ($(CONFIG_BCM_OPEN),y)
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/natalie-dect-h
|
||||
else
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:natalie-dect-h
|
||||
endif
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=c2139d05e3d082f1dcf58ce3f19306cb76fd0873
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
|
||||
|
||||
define Package/natalie-dect-h
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Dect stack headers
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/natalie-dect-h/description
|
||||
Kernel dect driver headers
|
||||
endef
|
||||
|
||||
|
||||
define Package/natalie-dect-h/install
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/natalie-dect
|
||||
$(CP) -r $(PKG_BUILD_DIR)/SrcHeaders/* $(STAGING_DIR)/usr/include/natalie-dect/
|
||||
endef
|
||||
|
||||
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,natalie-dect-h))
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=natalie-dect-open
|
||||
PKG_VERSION:=11.19
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/ihgsp/consumer/
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
|
||||
|
||||
BCM_KERNEL_VERSION=`cat $(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-*/include/config/kernel.release`
|
||||
|
||||
export BUILD_DIR
|
||||
export BCM_KERNEL_VERSION
|
||||
|
||||
|
||||
define Package/natalie-dect-open
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Dect stack
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/natalie-dect-open/description
|
||||
Kernel dect driver
|
||||
endef
|
||||
|
||||
|
||||
define Package/natalie-dect-open/install
|
||||
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
$(CP) $(PKG_BUILD_DIR)/dect.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/dect.ko
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,natalie-dect-open))
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=natalie-dect
|
||||
PKG_VERSION:=11.19.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:natalie-dect-11.19
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=2015e8106c7d541dd038381c2845bd8462d74a30
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
|
||||
|
||||
BCM_KERNEL_VERSION=`cat $(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-*/include/config/kernel.release`
|
||||
|
||||
export BUILD_DIR
|
||||
export BCM_KERNEL_VERSION
|
||||
|
||||
|
||||
define Package/natalie-dect
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Dect stack
|
||||
URL:=
|
||||
DEPENDS:=bcmkernel
|
||||
endef
|
||||
|
||||
define Package/natalie-dect/description
|
||||
Kernel dect driver
|
||||
endef
|
||||
|
||||
|
||||
define Package/natalie-dect/install
|
||||
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
$(CP) $(PKG_BUILD_DIR)/NatalieFpCvm6362/Src/Projects/NatalieV3/FpCvm/Linux6362/dects.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/dect.ko
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,natalie-dect))
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=peripheral_manager
|
||||
PKG_RELEASE:=1
|
||||
|
||||
# support parallel build
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
#re create configure scripts if not present.
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
# run install target when cross compiling. basically, make install DESTDIR=$(PKG_INSTALL_DIR)
|
||||
# this way we don't need to pick out the resulting files from the build dir.
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/peripheral_manager
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Application deamon for handling of peripheral
|
||||
URL:=
|
||||
DEPENDS:=+libuci +libubus +libblobmsg-json bcmkernel
|
||||
endef
|
||||
|
||||
define Package/peripheral_manager/description
|
||||
Application handling peripheral
|
||||
endef
|
||||
|
||||
TARGET_CPPFLAGS := \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
|
||||
$(TARGET_CPPFLAGS)
|
||||
|
||||
# In future get the git. unpack it in src.
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
$(CP) ./files/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Package/peripheral_manager/install
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/peripheral_manager $(1)/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gpio_test $(1)/sbin/
|
||||
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/etc/init.d/* $(1)/etc/init.d/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,peripheral_manager))
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=19
|
||||
STOP=91
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=peripheral_manager
|
||||
PROG=/sbin/peripheral_manager
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" -f
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_running() {
|
||||
ubus -t 2 wait_for leds
|
||||
ubus call led.status set '{"state":"ok"}'
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /sbin/peripheral_manager
|
||||
}
|
||||
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
#PRG_VERSION := $(shell cd @top_srcdir@; if ! git describe --tags ;then echo version-$(PACKAGE_VERSION) ;fi )
|
||||
|
||||
AM_CFLAGS = $(OUR_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = peripheral_manager
|
||||
dist_data_DATA = configs/hw
|
||||
|
||||
peripheral_manager_SOURCES = \
|
||||
src/peripheral_manager.c \
|
||||
src/ucix.c \
|
||||
src/ucix.h \
|
||||
src/server.c \
|
||||
src/server.h \
|
||||
src/led.c \
|
||||
src/led.h \
|
||||
src/sim_led.c \
|
||||
src/button.h \
|
||||
src/button.c \
|
||||
src/sim_button.c \
|
||||
src/catv.c \
|
||||
src/catv_monitor.c \
|
||||
src/catv.h \
|
||||
src/smbus.c \
|
||||
src/smbus.h \
|
||||
src/i2c.c \
|
||||
src/i2c.h \
|
||||
src/sfp.c \
|
||||
src/sfp.h
|
||||
|
||||
if BRCM_BOARD
|
||||
|
||||
bin_PROGRAMS += vox_test gpio_test
|
||||
|
||||
peripheral_manager_SOURCES += \
|
||||
src/gpio_led.c \
|
||||
src/gpio_led.h \
|
||||
src/gpio_button.c \
|
||||
src/gpio_button.h \
|
||||
src/gpio.c \
|
||||
src/gpio.h \
|
||||
src/gpio_shift_register.c \
|
||||
src/gpio_shift_register.h \
|
||||
src/touch_sx9512.c \
|
||||
src/touch_sx9512.h \
|
||||
src/sx9512.c \
|
||||
src/sx9512.h \
|
||||
src/vox.h \
|
||||
src/vox.c \
|
||||
src/prox_px3220.c
|
||||
|
||||
vox_test_SOURCES = \
|
||||
src/vox_test.c \
|
||||
src/gpio.c \
|
||||
src/gpio.h
|
||||
|
||||
gpio_test_SOURCES = \
|
||||
src/gpio_test.c \
|
||||
src/gpio.c \
|
||||
src/gpio.h \
|
||||
src/gpio_shift_register.c \
|
||||
src/gpio_shift_register.h \
|
||||
src/smbus.c \
|
||||
src/smbus.h \
|
||||
src/i2c.c \
|
||||
src/i2c.h \
|
||||
src/sx9512.c \
|
||||
src/sx9512.h
|
||||
|
||||
endif
|
||||
|
||||
peripheral_manager_LDADD = $(UCI_LIB) $(UBOX_LIB) $(UBUS_LIB) -lm
|
||||
|
||||
peripheral_manager_CFLAGS = $(AM_CFLAGS) -DPRG_VERSION=\"$(PRG_VERSION)\"
|
||||
|
|
@ -1,247 +0,0 @@
|
|||
# test config for peripheral_manager
|
||||
# only contain options that peripheral_manager needs and that can be used
|
||||
# when compiling to host (not target hardware)
|
||||
|
||||
config board 'board'
|
||||
option hardware 'CG300'
|
||||
|
||||
# for CATV parsing we need this hardware
|
||||
# option hardware 'EG300'
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# example for low level button.
|
||||
#
|
||||
#
|
||||
|
||||
config sim_button sim_buttons
|
||||
list buttons sim_button_A
|
||||
list buttons sim_button_B
|
||||
list buttons sim_button_c
|
||||
list buttons sim_button_d
|
||||
list buttons sim_button_e
|
||||
|
||||
config sim_button sim_button_A
|
||||
option addr 10
|
||||
option active hi
|
||||
|
||||
config sim_button sim_button_B
|
||||
option addr 11
|
||||
option active low
|
||||
|
||||
config sim_button sim_button_c
|
||||
option addr 12
|
||||
option active hi
|
||||
|
||||
config sim_button sim_button_d
|
||||
option addr 13
|
||||
option active hi
|
||||
|
||||
config sim_button sim_button_e
|
||||
option addr 14
|
||||
option active hi
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# example for mapping system button to driver button.
|
||||
#
|
||||
# mapping serveral "functions" buttons to one physical can be done with the long press option
|
||||
# if
|
||||
#
|
||||
# this is a list of all button names. perifmanger will read this list then read out the specific button config
|
||||
|
||||
config button_map button_map
|
||||
list buttonnames RESET
|
||||
list buttonnames Wireless
|
||||
list buttonnames WPS
|
||||
list buttonnames DECTS
|
||||
list buttonnames DECTL
|
||||
list buttonnames TOUCH_NEAR
|
||||
list buttonnames TOUCH_FAR
|
||||
option minpress 100 # default minimum time a button nedes to be pressed.
|
||||
|
||||
config button_map RESET
|
||||
# list button gpio_reset
|
||||
list button sim_button_A # driver that is used for this button
|
||||
option minpress 5000 # don't allow button unless pressed for 5 seconds.
|
||||
option hotplug resetbutton
|
||||
|
||||
config button_map Wireless
|
||||
list button sim_button_B # driver that is used for this button
|
||||
list button sim_button_c # we support user having to press two at the same time to register a button event.
|
||||
option minpress 1000
|
||||
option hotplug ecobutton
|
||||
|
||||
# long press example one or the other of touch_near or touch_far will trigger not booth.
|
||||
|
||||
config button_map TOUCH_NEAR
|
||||
list button gpio_reset
|
||||
# list button sim_button_d # driver that is used for this button
|
||||
option hotplug touch_near
|
||||
|
||||
config button_map TOUCH_FAR
|
||||
list button sim_button_d # driver that is used for this button
|
||||
option longpress 3000 # this button has a long press option.
|
||||
option hotplug touch_far
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# example for low level led driver.
|
||||
# here we list what the led can do and any info the driver needs to know to controll the led.
|
||||
#
|
||||
# would proably be smarter to name the leds as the color and not just A B C.
|
||||
# but this is an example to show there is no connection with the name and what it
|
||||
# does.
|
||||
#
|
||||
config sim_led sim_leds
|
||||
list leds sim_led_A
|
||||
list leds sim_led_B
|
||||
list leds sim_led_C
|
||||
|
||||
config sim_led sim_led_A
|
||||
option addr 1
|
||||
option color green
|
||||
option breading no
|
||||
|
||||
config sim_led sim_led_B
|
||||
option addr 7
|
||||
option color red
|
||||
option breading no
|
||||
|
||||
config sim_led sim_led_C
|
||||
option addr 3
|
||||
option color blue
|
||||
option breading yes
|
||||
option fadein yes
|
||||
option fadeout yes
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# gpio leds
|
||||
#
|
||||
config gpio_led gpio_leds
|
||||
list leds Status_green
|
||||
list leds Status_red
|
||||
list leds Wireless_green
|
||||
list leds Wireless_blue
|
||||
list leds WAN_green
|
||||
list leds WAN_yellow
|
||||
|
||||
config gpio_led Status_green
|
||||
option addr 39
|
||||
option active low
|
||||
option mode direct
|
||||
|
||||
config gpio_led Status_red
|
||||
option addr 38
|
||||
option active low
|
||||
option mode direct
|
||||
|
||||
config gpio_led Wireless_green
|
||||
option addr 37
|
||||
option active low
|
||||
option mode direct
|
||||
|
||||
config gpio_led Wireless_blue
|
||||
option addr 36
|
||||
option active low
|
||||
option mode direct
|
||||
|
||||
config gpio_led WAN_green
|
||||
option addr 9
|
||||
option active low
|
||||
option mode direct
|
||||
|
||||
config gpio_led WAN_yellow
|
||||
option addr 10
|
||||
option active low
|
||||
option mode direct
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# gpio buttons
|
||||
#
|
||||
|
||||
config gpio_button gpio_buttons
|
||||
list buttons gpio_reset
|
||||
|
||||
config gpio_button gpio_reset
|
||||
option addr 32
|
||||
option active low
|
||||
# option feedback
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# example mapping sim leds to system leds.
|
||||
#
|
||||
# the led_action list can be from one entry and up.
|
||||
#
|
||||
# led_action, list of leds to set.
|
||||
# button_action. list of button events to send out
|
||||
# effect_action, list of special effects to activate. (dim display.....)
|
||||
#
|
||||
|
||||
config led_map led_map
|
||||
list functions status
|
||||
list functions wifi
|
||||
list functions wps
|
||||
|
||||
config led_map led_status
|
||||
list led_action_ok 'sim_led_A = ON'
|
||||
list led_action_ok 'sim_led_B = OFF'
|
||||
list led_action_off 'sim_led_A = OFF'
|
||||
list led_action_off 'sim_led_B = OFF'
|
||||
list led_action_notice 'sim_led_A = FLASH_SLOW'
|
||||
list led_action_notice 'sim_led_B = OFF'
|
||||
list led_action_alert 'sim_led_A = OFF'
|
||||
list led_action_alert 'sim_led_B = FLASH_SLOW'
|
||||
list led_action_error 'sim_led_A = OFF'
|
||||
list led_action_error 'sim_led_B = FLASH_FAST'
|
||||
|
||||
config led_map led_wps
|
||||
# list led_action_ok 'WPS_green=ON'
|
||||
# list led_action_off 'WPS_green=OFF'
|
||||
# list led_action_notice 'WPS_green=FLASH_SLOW'
|
||||
# list led_action_alert 'WPS_green=FLASH_FAST'
|
||||
# list led_action_error 'WPS_green=OFF'
|
||||
|
||||
config led_map led_wifi
|
||||
# list led_action_ok 'Wireless_green = ON'
|
||||
# list led_action_ok 'Wireless_blue = OFF'
|
||||
# list led_action_eok 'Wireless_green = OFF'
|
||||
# list led_action_eok 'Wireless_blue = ON'
|
||||
# list led_action_off 'Wireless_green = OFF'
|
||||
# list led_action_off 'Wireless_blue = OFF'
|
||||
# list led_action_notice 'Wireless_green = FLASH_SLOW'
|
||||
# list led_action_notice 'Wireless_blue = OFF'
|
||||
# list led_action_alert 'Wireless_green = OFF'
|
||||
# list led_action_alert 'Wireless_blue = FLASH_SLOW'
|
||||
# list led_action_error 'Wireless_green = OFF'
|
||||
# list led_action_error 'Wireless_blue = FLASH_FAST'
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# function superfunctions
|
||||
#
|
||||
# Used when one led is controlled by seferal different functions
|
||||
# here we map in what state the underlying normal functions should have
|
||||
# to set a state, and what action to take in that state.
|
||||
|
||||
|
||||
# list available super functions.
|
||||
config led_map led_map
|
||||
list functions super_a
|
||||
|
||||
config led_map led_super_a
|
||||
list led_action_ok sim_led_C=ON
|
||||
list super_ok 'wifi_ok, wps_ok'
|
||||
|
||||
list led_action_off sim_led_C=OFF
|
||||
list super_off 'wifi_off, wps_off'
|
||||
|
||||
list led_action_notice sim_led_C=FLASH_SLOW
|
||||
list super_notice 'wifi_notice'
|
||||
list super_notice 'wps_notice'
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
dnl init stuff needs to be first in file
|
||||
AC_INIT([peripheral_manager], [0.1], [Kenneth Johansson <kenneth@southpole.se>])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
|
||||
AC_PROG_CC
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
|
||||
CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
|
||||
-pipe \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-inline \
|
||||
-Wundef \
|
||||
"-Wformat=2 -Wformat-security -Wformat-nonliteral" \
|
||||
-Wlogical-op \
|
||||
-Wsign-compare \
|
||||
-Wmissing-include-dirs \
|
||||
-Wold-style-definition \
|
||||
-Wpointer-arith \
|
||||
-Winit-self \
|
||||
-Wdeclaration-after-statement \
|
||||
-Wfloat-equal \
|
||||
-Wsuggest-attribute=noreturn \
|
||||
-Wmissing-prototypes \
|
||||
-Wstrict-prototypes \
|
||||
-Wredundant-decls \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-noreturn \
|
||||
-Wshadow \
|
||||
-Wendif-labels \
|
||||
-Wstrict-aliasing=2 \
|
||||
-Wwrite-strings \
|
||||
-Wno-long-long \
|
||||
-Wno-overlength-strings \
|
||||
-Wno-unused-parameter \
|
||||
-Wno-missing-field-initializers \
|
||||
-Wno-unused-result \
|
||||
-Werror=overflow \
|
||||
-Wdate-time \
|
||||
-Wnested-externs \
|
||||
-ffast-math \
|
||||
-fno-common \
|
||||
-fdiagnostics-show-option \
|
||||
-fno-strict-aliasing \
|
||||
-fvisibility=hidden \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-fstack-protector \
|
||||
-fstack-protector-strong \
|
||||
-fPIE \
|
||||
--param=ssp-buffer-size=4])
|
||||
|
||||
AC_SUBST([OUR_CFLAGS], "$with_cflags")
|
||||
|
||||
dnl check for uci , its manadatory
|
||||
AC_SEARCH_LIBS([uci_load], [uci], [], [AC_MSG_ERROR([*** UCI library not found])])
|
||||
|
||||
dnl check ubox , its manadatory
|
||||
AC_SEARCH_LIBS([uloop_init], [ubox], [], [AC_MSG_ERROR([*** UBOX library not found])])
|
||||
|
||||
dnl chek ubus , its manadatory
|
||||
AC_SEARCH_LIBS([ubus_connect], [ubus], [], [AC_MSG_ERROR([*** UBUS library not found])])
|
||||
|
||||
dnl check for board.h file
|
||||
AC_CHECK_HEADERS(board.h, AM_CONDITIONAL(BRCM_BOARD, true), AM_CONDITIONAL(BRCM_BOARD, false))
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
AC_MSG_RESULT([
|
||||
$PACKAGE_NAME $VERSION
|
||||
CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
|
||||
CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
|
||||
LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
|
||||
])
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
dnl Macros to check the presence of generic (non-typed) symbols.
|
||||
dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
|
||||
dnl Copyright (c) 2006-2008 xine project
|
||||
dnl Copyright (c) 2012 Lucas De Marchi <lucas.de.marchi@gmail.com>
|
||||
dnl
|
||||
dnl This program is free software; you can redistribute it and/or modify
|
||||
dnl it under the terms of the GNU General Public License as published by
|
||||
dnl the Free Software Foundation; either version 2, or (at your option)
|
||||
dnl any later version.
|
||||
dnl
|
||||
dnl This program is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
dnl GNU General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU General Public License
|
||||
dnl along with this program; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
dnl 02110-1301, USA.
|
||||
dnl
|
||||
dnl As a special exception, the copyright owners of the
|
||||
dnl macro gives unlimited permission to copy, distribute and modify the
|
||||
dnl configure scripts that are the output of Autoconf when processing the
|
||||
dnl Macro. You need not follow the terms of the GNU General Public
|
||||
dnl License when using or distributing such scripts, even though portions
|
||||
dnl of the text of the Macro appear in them. The GNU General Public
|
||||
dnl License (GPL) does govern all other use of the material that
|
||||
dnl constitutes the Autoconf Macro.
|
||||
dnl
|
||||
dnl This special exception to the GPL applies to versions of the
|
||||
dnl Autoconf Macro released by this project. When you make and
|
||||
dnl distribute a modified version of the Autoconf Macro, you may extend
|
||||
dnl this special exception to the GPL to apply to your modified version as
|
||||
dnl well.
|
||||
|
||||
dnl Check if FLAG in ENV-VAR is supported by compiler and append it
|
||||
dnl to WHERE-TO-APPEND variable
|
||||
dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG])
|
||||
|
||||
AC_DEFUN([CC_CHECK_FLAG_APPEND], [
|
||||
AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
|
||||
AS_TR_SH([cc_cv_$2_$3]),
|
||||
[eval "AS_TR_SH([cc_save_$2])='${$2}'"
|
||||
eval "AS_TR_SH([$2])='-Werror $3'"
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; } ])],
|
||||
[eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
|
||||
[eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
|
||||
eval "AS_TR_SH([$2])='$cc_save_$2'"])
|
||||
|
||||
AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
|
||||
[eval "$1='${$1} $3'"])
|
||||
])
|
||||
|
||||
dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2])
|
||||
AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
|
||||
for flag in $3; do
|
||||
CC_CHECK_FLAG_APPEND($1, $2, $flag)
|
||||
done
|
||||
])
|
||||
|
||||
dnl Check if the flag is supported by linker (cacheable)
|
||||
dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
|
||||
|
||||
AC_DEFUN([CC_CHECK_LDFLAGS], [
|
||||
AC_CACHE_CHECK([if $CC supports $1 flag],
|
||||
AS_TR_SH([cc_cv_ldflags_$1]),
|
||||
[ac_save_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $1"
|
||||
AC_LINK_IFELSE([int main() { return 1; }],
|
||||
[eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
|
||||
[eval "AS_TR_SH([cc_cv_ldflags_$1])="])
|
||||
LDFLAGS="$ac_save_LDFLAGS"
|
||||
])
|
||||
|
||||
AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
|
||||
[$2], [$3])
|
||||
])
|
||||
|
||||
dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
|
||||
dnl the current linker to avoid undefined references in a shared object.
|
||||
AC_DEFUN([CC_NOUNDEFINED], [
|
||||
dnl We check $host for which systems to enable this for.
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
|
||||
case $host in
|
||||
dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
|
||||
dnl are requested, as different implementations are present; to avoid problems
|
||||
dnl use -Wl,-z,defs only for those platform not behaving this way.
|
||||
*-freebsd* | *-openbsd*) ;;
|
||||
*)
|
||||
dnl First of all check for the --no-undefined variant of GNU ld. This allows
|
||||
dnl for a much more readable command line, so that people can understand what
|
||||
dnl it does without going to look for what the heck -z defs does.
|
||||
for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
|
||||
CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
|
||||
break
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST([LDFLAGS_NOUNDEFINED])
|
||||
])
|
||||
|
||||
dnl Check for a -Werror flag or equivalent. -Werror is the GCC
|
||||
dnl and ICC flag that tells the compiler to treat all the warnings
|
||||
dnl as fatal. We usually need this option to make sure that some
|
||||
dnl constructs (like attributes) are not simply ignored.
|
||||
dnl
|
||||
dnl Other compilers don't support -Werror per se, but they support
|
||||
dnl an equivalent flag:
|
||||
dnl - Sun Studio compiler supports -errwarn=%all
|
||||
AC_DEFUN([CC_CHECK_WERROR], [
|
||||
AC_CACHE_CHECK(
|
||||
[for $CC way to treat warnings as errors],
|
||||
[cc_cv_werror],
|
||||
[CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
|
||||
[CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_CHECK_ATTRIBUTE], [
|
||||
AC_REQUIRE([CC_CHECK_WERROR])
|
||||
AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
|
||||
AS_TR_SH([cc_cv_attribute_$1]),
|
||||
[ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $cc_cv_werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
|
||||
[eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
|
||||
[eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
])
|
||||
|
||||
AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
|
||||
[AC_DEFINE(
|
||||
AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
|
||||
[Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
|
||||
)
|
||||
$4],
|
||||
[$5])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[constructor],,
|
||||
[void __attribute__((constructor)) ctor() { int a; }],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[format], [format(printf, n, n)],
|
||||
[void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[format_arg], [format_arg(printf)],
|
||||
[char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[visibility_$1], [visibility("$1")],
|
||||
[void __attribute__((visibility("$1"))) $1_function() { }],
|
||||
[$2], [$3])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[nonnull], [nonnull()],
|
||||
[void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[unused], ,
|
||||
[void some_function(void *foo, __attribute__((unused)) void *bar);],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[sentinel], ,
|
||||
[void some_function(void *foo, ...) __attribute__((sentinel));],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[deprecated], ,
|
||||
[void some_function(void *foo, ...) __attribute__((deprecated));],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[alias], [weak, alias],
|
||||
[void other_function(void *foo) { }
|
||||
void some_function(void *foo) __attribute__((weak, alias("other_function")));],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[malloc], ,
|
||||
[void * __attribute__((malloc)) my_alloc(int n);],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_PACKED], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[packed], ,
|
||||
[struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_CONST], [
|
||||
CC_CHECK_ATTRIBUTE(
|
||||
[const], ,
|
||||
[int __attribute__((const)) twopow(int n) { return 1 << n; } ],
|
||||
[$1], [$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_FLAG_VISIBILITY], [
|
||||
AC_REQUIRE([CC_CHECK_WERROR])
|
||||
AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
|
||||
[cc_cv_flag_visibility],
|
||||
[cc_flag_visibility_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $cc_cv_werror"
|
||||
CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
|
||||
cc_cv_flag_visibility='yes',
|
||||
cc_cv_flag_visibility='no')
|
||||
CFLAGS="$cc_flag_visibility_save_CFLAGS"])
|
||||
|
||||
AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
|
||||
[AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
|
||||
[Define this if the compiler supports the -fvisibility flag])
|
||||
$1],
|
||||
[$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_FUNC_EXPECT], [
|
||||
AC_REQUIRE([CC_CHECK_WERROR])
|
||||
AC_CACHE_CHECK([if compiler has __builtin_expect function],
|
||||
[cc_cv_func_expect],
|
||||
[ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $cc_cv_werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
|
||||
[int some_function() {
|
||||
int a = 3;
|
||||
return (int)__builtin_expect(a, 3);
|
||||
}])],
|
||||
[cc_cv_func_expect=yes],
|
||||
[cc_cv_func_expect=no])
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
])
|
||||
|
||||
AS_IF([test "x$cc_cv_func_expect" = "xyes"],
|
||||
[AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
|
||||
[Define this if the compiler supports __builtin_expect() function])
|
||||
$1],
|
||||
[$2])
|
||||
])
|
||||
|
||||
AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
|
||||
AC_REQUIRE([CC_CHECK_WERROR])
|
||||
AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
|
||||
[cc_cv_attribute_aligned],
|
||||
[ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $cc_cv_werror"
|
||||
for cc_attribute_align_try in 64 32 16 8 4 2; do
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
int main() {
|
||||
static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
|
||||
return c;
|
||||
}])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
|
||||
done
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
])
|
||||
|
||||
if test "x$cc_cv_attribute_aligned" != "x"; then
|
||||
AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
|
||||
[Define the highest alignment supported])
|
||||
fi
|
||||
])
|
||||
|
|
@ -1,534 +0,0 @@
|
|||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
#include "config.h"
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include "log.h"
|
||||
#include "button.h"
|
||||
#include "led.h"
|
||||
#include "touch_sx9512.h"
|
||||
#include "prox_px3220.h"
|
||||
|
||||
|
||||
static struct ubus_context *global_ubus_ctx;
|
||||
static struct blob_buf bblob;
|
||||
|
||||
|
||||
void button_ubus_interface_event(struct ubus_context *ubus_ctx, char *button, button_state_t pressed)
|
||||
{
|
||||
char s[UBUS_BUTTON_NAME_PREPEND_LEN+BUTTON_MAX_NAME_LEN];
|
||||
s[0]=0;
|
||||
strcat(s, UBUS_BUTTON_NAME_PREPEND);
|
||||
strcat(s, button);
|
||||
blob_buf_init(&bblob, 0);
|
||||
blobmsg_add_string(&bblob, "action", pressed ? "pressed" : "released");
|
||||
ubus_send_event(ubus_ctx, s, bblob.head);
|
||||
}
|
||||
|
||||
|
||||
/* used to map in the driver buttons to a function button */
|
||||
struct button_drv_list {
|
||||
struct list_head list;
|
||||
struct timespec pressed_time;
|
||||
struct button_drv *drv;
|
||||
};
|
||||
|
||||
/**/
|
||||
struct function_button {
|
||||
struct list_head list;
|
||||
char *name;
|
||||
int dimming;
|
||||
char *hotplug;
|
||||
char *hotplug_long;
|
||||
int minpress;
|
||||
int longpress; /* negative value means valid if mintime < time < abs(longpress ) */
|
||||
/* positive value means valid if time > longpreass */
|
||||
/* zero value means valid if time > mintime */
|
||||
struct list_head drv_list; /* list of all driver button that is needed to activate this button function */
|
||||
};
|
||||
|
||||
/* PUT every button from drivers into a list */
|
||||
struct drv_button_list{
|
||||
struct list_head list;
|
||||
struct button_drv *drv;
|
||||
};
|
||||
|
||||
/* list of all driver buttons added by drivers. */
|
||||
static LIST_HEAD(drv_buttons_list);
|
||||
|
||||
/* list containing all function buttons read from config file */
|
||||
static LIST_HEAD(buttons);
|
||||
|
||||
|
||||
void button_add( struct button_drv *drv)
|
||||
{
|
||||
struct drv_button_list *drv_node = malloc(sizeof(struct drv_button_list));
|
||||
|
||||
DBG(1,"called with button name [%s]", drv->name);
|
||||
drv_node->drv = drv;
|
||||
|
||||
list_add(&drv_node->list, &drv_buttons_list);
|
||||
}
|
||||
|
||||
static struct button_drv *get_drv_button(const char *name)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &drv_buttons_list) {
|
||||
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
|
||||
if (! strcmp(node->drv->name, name))
|
||||
return node->drv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static struct function_button *get_button(const char *name)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &buttons) {
|
||||
struct function_button *node = list_entry(i, struct function_button, list);
|
||||
if (! strcmp(node->name, name))
|
||||
return node;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//! Read state for single button
|
||||
static button_state_t read_button_state(const char *name)
|
||||
{
|
||||
struct list_head *i;
|
||||
#ifdef HAVE_BOARD_H
|
||||
/* sx9512 driver needs to read out all buttons at once */
|
||||
/* so call it once at beginning of scanning inputs */
|
||||
sx9512_check();
|
||||
/* same for px3220 */
|
||||
px3220_check();
|
||||
#endif
|
||||
list_for_each(i, &buttons) {
|
||||
struct list_head *j;
|
||||
struct function_button *node = list_entry(i, struct function_button, list);
|
||||
if(!strcmp(node->name, name)) {
|
||||
button_state_t state=BUTTON_ERROR;
|
||||
list_for_each(j, &node->drv_list) {
|
||||
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
|
||||
if(drv_node->drv) {
|
||||
if(drv_node->drv->func->get_state(drv_node->drv))
|
||||
return BUTTON_PRESSED;
|
||||
else
|
||||
state=BUTTON_RELEASED;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
return BUTTON_ERROR;
|
||||
}
|
||||
|
||||
struct button_status {
|
||||
char name[BUTTON_MAX_NAME_LEN];
|
||||
button_state_t state;
|
||||
};
|
||||
|
||||
struct button_status_all {
|
||||
int n;
|
||||
struct button_status status[BUTTON_MAX];
|
||||
};
|
||||
|
||||
|
||||
//! Read states for all buttons
|
||||
static struct button_status_all * read_button_states(void)
|
||||
{
|
||||
static struct button_status_all p;
|
||||
p.n=0;
|
||||
struct list_head *i;
|
||||
#ifdef HAVE_BOARD_H
|
||||
/* sx9512 driver needs to read out all buttons at once */
|
||||
/* so call it once at beginning of scanning inputs */
|
||||
sx9512_check();
|
||||
/* same for px3220 */
|
||||
px3220_check();
|
||||
#endif
|
||||
list_for_each(i, &buttons) {
|
||||
struct list_head *j;
|
||||
button_state_t state=BUTTON_ERROR;
|
||||
struct function_button *node = list_entry(i, struct function_button, list);
|
||||
strcpy(p.status[p.n].name, node->name);
|
||||
list_for_each(j, &node->drv_list) {
|
||||
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
|
||||
if(drv_node->drv) {
|
||||
if(drv_node->drv->func->get_state(drv_node->drv))
|
||||
state=BUTTON_PRESSED;
|
||||
else
|
||||
state=BUTTON_RELEASED;
|
||||
}
|
||||
}
|
||||
p.status[p.n].state = state;
|
||||
p.n++;
|
||||
}
|
||||
return &p;
|
||||
}
|
||||
|
||||
static void dump_drv_list(void)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &drv_buttons_list) {
|
||||
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
|
||||
DBG(1,"button name = [%s]",node->drv->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_buttons_list(void)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &buttons) {
|
||||
struct function_button *node = list_entry(i, struct function_button, list);
|
||||
DBG(1,"button name = [%s]",node->name);
|
||||
{
|
||||
struct list_head *j;
|
||||
list_for_each(j, &node->drv_list) {
|
||||
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
|
||||
if(drv_node->drv != NULL)
|
||||
DBG(1,"%13s drv button name = [%s]","",drv_node->drv->name);
|
||||
}
|
||||
DBG(1,"%13s minpress = %d","",node->minpress);
|
||||
DBG(1,"%13s longpress = %d","",node->longpress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Run the hotplug command associated with function button
|
||||
//! @retval 0 ok
|
||||
static int button_hotplug_cmd(const char *name, bool longpress)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &buttons) {
|
||||
struct function_button *node = list_entry(i, struct function_button, list);
|
||||
if(!strcmp(node->name, name)) {
|
||||
char str[512];
|
||||
char *hotplug = node->hotplug;
|
||||
if(longpress && node->hotplug_long)
|
||||
hotplug = node->hotplug_long;
|
||||
if(!hotplug)
|
||||
return 1;
|
||||
DBG(1, "send key %s [%s] to system %s", node->name, hotplug, longpress ? "(longpress)" : "");
|
||||
snprintf(str, 512, "ACTION=register INTERFACE=%s /sbin/hotplug-call button &", hotplug);
|
||||
system(str);
|
||||
syslog(LOG_INFO, "%s",str);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int timer_started(struct button_drv_list *button_drv)
|
||||
{
|
||||
if (button_drv->pressed_time.tv_sec == 0 )
|
||||
if (button_drv->pressed_time.tv_nsec == 0 )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void timer_start(struct button_drv_list *button_drv)
|
||||
{
|
||||
clock_gettime(CLOCK_MONOTONIC, &button_drv->pressed_time);
|
||||
}
|
||||
|
||||
static void timer_stop(struct button_drv_list *button_drv)
|
||||
{
|
||||
button_drv->pressed_time.tv_sec = 0;
|
||||
button_drv->pressed_time.tv_nsec = 0;
|
||||
}
|
||||
|
||||
|
||||
static button_press_type_t timer_valid(struct button_drv_list *button_drv, int mtimeout, int longpress)
|
||||
{
|
||||
struct timespec now;
|
||||
int sec;
|
||||
int nsec;
|
||||
int time_elapsed;
|
||||
|
||||
if (timer_started(button_drv)) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
sec = now.tv_sec - button_drv->pressed_time.tv_sec;
|
||||
nsec = now.tv_nsec - button_drv->pressed_time.tv_nsec;
|
||||
time_elapsed = sec*1000 + nsec/1000000;
|
||||
if ( mtimeout < time_elapsed) {
|
||||
if (longpress && (longpress < time_elapsed))
|
||||
return BUTTON_PRESS_LONG;
|
||||
return BUTTON_PRESS_SHORT;
|
||||
}
|
||||
}
|
||||
return BUTTON_PRESS_NONE;
|
||||
}
|
||||
|
||||
#define BUTTON_TIMEOUT 100
|
||||
static void button_handler(struct uloop_timeout *timeout);
|
||||
static struct uloop_timeout button_inform_timer = { .cb = button_handler };
|
||||
|
||||
static void button_handler(struct uloop_timeout *timeout)
|
||||
{
|
||||
struct list_head *i;
|
||||
int r;
|
||||
// DBG(1, "");
|
||||
|
||||
#ifdef HAVE_BOARD_H
|
||||
|
||||
/* sx9512 driver needs to read out all buttons at once */
|
||||
/* so call it once at beginning of scanning inputs */
|
||||
sx9512_check();
|
||||
/* same for px3220 */
|
||||
px3220_check();
|
||||
#endif
|
||||
|
||||
/* clean out indicator status, set by any valid press again if we find it */
|
||||
led_pressindicator_clear();
|
||||
|
||||
list_for_each(i, &buttons) {
|
||||
struct list_head *j;
|
||||
struct function_button *node = list_entry(i, struct function_button, list);
|
||||
|
||||
list_for_each(j, &node->drv_list) {
|
||||
struct button_drv_list *drv_node = list_entry(j, struct button_drv_list, list);
|
||||
if (drv_node->drv) {
|
||||
button_state_t st = drv_node->drv->func->get_state(drv_node->drv);
|
||||
|
||||
if (st == BUTTON_PRESSED ) {
|
||||
if (! timer_started(drv_node)) {
|
||||
timer_start(drv_node);
|
||||
DBG(1, " %s pressed", drv_node->drv->name);
|
||||
button_ubus_interface_event(global_ubus_ctx, node->name, BUTTON_PRESSED);
|
||||
}
|
||||
if(timer_valid(drv_node, node->minpress, 0))
|
||||
led_pressindicator_set();
|
||||
}
|
||||
|
||||
if (st == BUTTON_RELEASED ) {
|
||||
if (timer_started(drv_node)) {
|
||||
DBG(1, " %s released", drv_node->drv->name);
|
||||
if((r=timer_valid(drv_node, node->minpress, node->longpress))) {
|
||||
button_ubus_interface_event(global_ubus_ctx, node->name, BUTTON_RELEASED);
|
||||
if(node->dimming)
|
||||
led_dimming();
|
||||
button_hotplug_cmd(node->name, r==BUTTON_PRESS_LONG);
|
||||
}
|
||||
}
|
||||
timer_stop(drv_node);
|
||||
}
|
||||
// DBG(1, " %s state = %d", drv_node->drv->name,st);
|
||||
}
|
||||
}
|
||||
}
|
||||
uloop_timeout_set(&button_inform_timer, BUTTON_TIMEOUT);
|
||||
}
|
||||
|
||||
|
||||
static int button_state_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
|
||||
{
|
||||
blob_buf_init(&bblob, 0);
|
||||
button_state_t state = read_button_state(obj->name+UBUS_BUTTON_NAME_PREPEND_LEN);
|
||||
switch(read_button_state(obj->name+UBUS_BUTTON_NAME_PREPEND_LEN)) {
|
||||
case BUTTON_RELEASED:
|
||||
blobmsg_add_string(&bblob, "state", "released");
|
||||
break;
|
||||
case BUTTON_PRESSED:
|
||||
blobmsg_add_string(&bblob, "state", "pressed");
|
||||
break;
|
||||
default:
|
||||
blobmsg_add_string(&bblob, "state", "error");
|
||||
}
|
||||
ubus_send_reply(ubus_ctx, req, bblob.head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int button_press_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
|
||||
{
|
||||
button_hotplug_cmd(obj->name+UBUS_BUTTON_NAME_PREPEND_LEN, 0);
|
||||
blob_buf_init(&bblob, 0);
|
||||
ubus_send_reply(ubus_ctx, req, bblob.head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int button_press_long_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
|
||||
{
|
||||
button_hotplug_cmd(obj->name+UBUS_BUTTON_NAME_PREPEND_LEN, 1);
|
||||
blob_buf_init(&bblob, 0);
|
||||
ubus_send_reply(ubus_ctx, req, bblob.head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int buttons_state_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
|
||||
{
|
||||
int i;
|
||||
static struct button_status_all *p;
|
||||
p = read_button_states();
|
||||
blob_buf_init(&bblob, 0);
|
||||
for(i=0;i < p->n; i++) {
|
||||
switch(p->status[i].state) {
|
||||
case BUTTON_RELEASED:
|
||||
blobmsg_add_string(&bblob, p->status[i].name, "released");
|
||||
break;
|
||||
case BUTTON_PRESSED:
|
||||
blobmsg_add_string(&bblob, p->status[i].name, "pressed");
|
||||
break;
|
||||
default:
|
||||
blobmsg_add_string(&bblob, p->status[i].name, "error");
|
||||
}
|
||||
}
|
||||
ubus_send_reply(ubus_ctx, req, bblob.head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const struct ubus_method button_methods[] = {
|
||||
// { .name = "status", .handler = button_status_method },
|
||||
{ .name = "state", .handler = button_state_method },
|
||||
{ .name = "press", .handler = button_press_method },
|
||||
{ .name = "press_long", .handler = button_press_long_method },
|
||||
};
|
||||
|
||||
static struct ubus_object_type button_object_type = UBUS_OBJECT_TYPE("button", button_methods);
|
||||
|
||||
|
||||
static const struct ubus_method buttons_methods[] = {
|
||||
{ .name = "state", .handler = buttons_state_method },
|
||||
};
|
||||
|
||||
static struct ubus_object_type buttons_object_type = UBUS_OBJECT_TYPE("buttons", buttons_methods);
|
||||
|
||||
static struct ubus_object buttons_object = { .name = "buttons", .type = &buttons_object_type, .methods = buttons_methods, .n_methods = ARRAY_SIZE(buttons_methods), };
|
||||
|
||||
|
||||
void button_init( struct server_ctx *s_ctx)
|
||||
{
|
||||
struct ucilist *node;
|
||||
LIST_HEAD(buttonnames);
|
||||
int default_minpress = 0;
|
||||
char *s;
|
||||
int i,r;
|
||||
|
||||
global_ubus_ctx=s_ctx->ubus_ctx;
|
||||
|
||||
/* register buttons object with ubus */
|
||||
if((r=ubus_add_object(s_ctx->ubus_ctx, &buttons_object)))
|
||||
DBG(1,"Failed to add object: %s", ubus_strerror(r));
|
||||
|
||||
/* read out default global options */
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , "button_map", "minpress");
|
||||
DBG(1, "default minpress = [%s]", s);
|
||||
if (s){
|
||||
default_minpress = strtol(s,0,0);
|
||||
}
|
||||
|
||||
/* read function buttons from section button_map */
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"button_map", "buttonnames", &buttonnames);
|
||||
list_for_each_entry(node, &buttonnames, list) {
|
||||
struct function_button *function;
|
||||
|
||||
// DBG(1, "value = [%s]",node->val);
|
||||
|
||||
function = malloc(sizeof(struct function_button));
|
||||
memset(function,0,sizeof(struct function_button));
|
||||
function->name = node->val;
|
||||
|
||||
/* read out dimming */
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "dimming");
|
||||
DBG(1, "dimming = [%s]", s);
|
||||
if (s){
|
||||
function->dimming = 1;
|
||||
}else
|
||||
function->dimming = 0;
|
||||
|
||||
/* read out minpress */
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "minpress");
|
||||
DBG(1, "minpress = [%s]", s);
|
||||
if (s){
|
||||
function->minpress = strtol(s,0,0);
|
||||
}else
|
||||
function->minpress = default_minpress;
|
||||
|
||||
/* read out long_press */
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "longpress");
|
||||
DBG(1, "longpress = [%s]", s);
|
||||
if (s){
|
||||
function->longpress = strtol(s,0,0);
|
||||
}
|
||||
|
||||
/* read out hotplug option */
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "hotplug");
|
||||
DBG(1, "hotplug = [%s]", s);
|
||||
if (s){
|
||||
function->hotplug = s;
|
||||
}
|
||||
|
||||
/* read out hotplug option for longpress */
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , function->name, "hotplug_long");
|
||||
DBG(1, "hotplug_long = [%s]", s);
|
||||
if (s){
|
||||
function->hotplug_long = s;
|
||||
}
|
||||
|
||||
INIT_LIST_HEAD(&function->drv_list);
|
||||
|
||||
{
|
||||
struct ucilist *drv_node;
|
||||
LIST_HEAD(head);
|
||||
int num = 0;
|
||||
|
||||
/* read out all driver buttons that needs to be pressed for this button function. */
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,function->name, "button", &head);
|
||||
|
||||
list_for_each_entry(drv_node, &head, list) {
|
||||
struct button_drv_list *new_button;
|
||||
|
||||
num++;
|
||||
DBG(1,"function %s -> drv button %s", function->name, drv_node->val);
|
||||
|
||||
new_button = malloc(sizeof(struct button_drv_list));
|
||||
memset(new_button,0,sizeof(struct button_drv_list));
|
||||
|
||||
new_button->drv = get_drv_button(drv_node->val);
|
||||
|
||||
if(new_button->drv == NULL){
|
||||
syslog(LOG_WARNING, "%s wanted drv button [%s] but it can't be found. check spelling.",
|
||||
function->name,
|
||||
drv_node->val);
|
||||
}
|
||||
|
||||
list_add( &new_button->list, &function->drv_list);
|
||||
}
|
||||
if (num == 0 )
|
||||
syslog(LOG_WARNING, "Function %s did not have any mapping to a driver button", function->name);
|
||||
}
|
||||
|
||||
list_add(&function->list, &buttons);
|
||||
|
||||
/* register each button with ubus */
|
||||
struct ubus_object *ubo;
|
||||
ubo = malloc(sizeof(struct ubus_object));
|
||||
memset(ubo, 0, sizeof(struct ubus_object));
|
||||
char name[UBUS_BUTTON_NAME_PREPEND_LEN+BUTTON_MAX_NAME_LEN];
|
||||
snprintf(name, UBUS_BUTTON_NAME_PREPEND_LEN+BUTTON_MAX_NAME_LEN, "%s%s", UBUS_BUTTON_NAME_PREPEND, node->val);
|
||||
ubo->name = strdup(name);
|
||||
ubo->methods = button_methods;
|
||||
ubo->n_methods = ARRAY_SIZE(button_methods);
|
||||
ubo->type = &button_object_type;
|
||||
if((r=ubus_add_object(s_ctx->ubus_ctx, ubo)))
|
||||
DBG(1,"Failed to add object: %s", ubus_strerror(r));
|
||||
}
|
||||
|
||||
uloop_timeout_set(&button_inform_timer, BUTTON_TIMEOUT);
|
||||
|
||||
dump_drv_list();
|
||||
dump_buttons_list();
|
||||
}
|
||||
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef BUTTON_H
|
||||
#define BUTTON_H
|
||||
#include "server.h"
|
||||
|
||||
#define BUTTON_MAX 32
|
||||
#define BUTTON_MAX_NAME_LEN 16
|
||||
#define UBUS_BUTTON_NAME_PREPEND "button."
|
||||
#define UBUS_BUTTON_NAME_PREPEND_LEN sizeof(UBUS_BUTTON_NAME_PREPEND)
|
||||
|
||||
typedef enum {
|
||||
BUTTON_RELEASED,
|
||||
BUTTON_PRESSED,
|
||||
BUTTON_ERROR,
|
||||
} button_state_t;
|
||||
|
||||
typedef enum {
|
||||
BUTTON_PRESS_NONE,
|
||||
BUTTON_PRESS_SHORT,
|
||||
BUTTON_PRESS_LONG,
|
||||
} button_press_type_t;
|
||||
|
||||
struct button_drv;
|
||||
|
||||
struct button_drv_func {
|
||||
button_state_t (*get_state)(struct button_drv *); /* Get button state, on,off ... */
|
||||
};
|
||||
|
||||
struct button_drv {
|
||||
const char *name; /* name, set in the confg file,has to be uniq */
|
||||
void *priv; /* for use by the driver */
|
||||
struct button_drv_func *func; /* function pointers for reading the button */
|
||||
};
|
||||
|
||||
void button_add( struct button_drv *drv);
|
||||
void button_init( struct server_ctx *s_ctx);
|
||||
|
||||
#endif /* BUTTON_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef CATV_H
|
||||
#include "libubus.h"
|
||||
|
||||
#include "ucix.h"
|
||||
|
||||
struct catv_handler;
|
||||
|
||||
struct catv_handler * catv_init(struct uci_context *uci_ctx, const char * i2c_bus, int i2c_addr_a0,int i2c_addr_a2);
|
||||
void catv_destroy(struct catv_handler *h);
|
||||
int catv_ubus_populate(struct catv_handler *h, struct ubus_context *ubus_ctx);
|
||||
|
||||
#endif /* CATV_H */
|
||||
|
|
@ -1,242 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include "log.h"
|
||||
|
||||
#include "server.h"
|
||||
|
||||
#include "libubus.h"
|
||||
#include <uci_config.h>
|
||||
#include <uci.h>
|
||||
#include "ucix.h"
|
||||
|
||||
typedef enum {
|
||||
STATE_OFF,
|
||||
STATE_OK,
|
||||
STATE_NOTICE,
|
||||
STATE_ALERT,
|
||||
STATE_ERROR,
|
||||
}state_t;
|
||||
|
||||
state_t state;
|
||||
|
||||
static struct ubus_context *ubus_ctx;
|
||||
static char *ubus_socket;
|
||||
|
||||
#define CATV_MONITOR_TIME (1000 * 10) /* 10 sec in ms */
|
||||
|
||||
void catv_monitor_init(struct server_ctx *s_ctx);
|
||||
void catv_monitor_set_socket(char *socket_name);
|
||||
|
||||
static void set_led(state_t state);
|
||||
static int is_enabled(void);
|
||||
|
||||
static void catv_monitor_handler(struct uloop_timeout *timeout);
|
||||
struct uloop_timeout catv_monitor_timer = { .cb = catv_monitor_handler };
|
||||
|
||||
static void
|
||||
catv_status_cb(struct ubus_request *req, int type, struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *cur;
|
||||
uint32_t rem;
|
||||
const char *data;
|
||||
|
||||
rem = blob_len(msg);
|
||||
|
||||
__blob_for_each_attr(cur, blob_data(msg), rem) {
|
||||
if (!strcmp("RF enable", blobmsg_name(cur))) {
|
||||
data = blobmsg_data(cur);
|
||||
if (!strncasecmp("on", data, 2))
|
||||
*(int*)req->priv = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*(int*)req->priv = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static int is_enabled(void)
|
||||
{
|
||||
uint32_t id;
|
||||
struct blob_buf b;
|
||||
int enabled = 0;
|
||||
int ret;
|
||||
|
||||
if (ubus_lookup_id(ubus_ctx, "catv", &id)) {
|
||||
DBG(4, "Failed to look up catv object\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&b, 0, sizeof(struct blob_buf));
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
ret = ubus_invoke(ubus_ctx, id, "status", b.head, catv_status_cb, &enabled, 3000);
|
||||
|
||||
if (ret)
|
||||
DBG(1,"catv_monitor: ret = %s", ubus_strerror(ret));
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
static void
|
||||
catv_vpd_cb(struct ubus_request *req, int type, struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *cur;
|
||||
uint32_t rem;
|
||||
const char *data = "-inf";
|
||||
|
||||
rem = blob_len(msg);
|
||||
|
||||
/* no response */
|
||||
if ( rem == 0 ) {
|
||||
state = STATE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
__blob_for_each_attr(cur, blob_data(msg), rem) {
|
||||
if (!strcmp("VPD", blobmsg_name(cur))) {
|
||||
data = blobmsg_data(cur);
|
||||
}
|
||||
}
|
||||
|
||||
/* no cable */
|
||||
if (!strcmp("-inf", data)) {
|
||||
state = STATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
catv_alarm_cb(struct ubus_request *req, int type, struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *cur;
|
||||
uint32_t rem;
|
||||
const char *data = "-inf";
|
||||
|
||||
rem = blob_len(msg);
|
||||
|
||||
/* no response */
|
||||
if ( rem == 0 ) {
|
||||
state = STATE_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
__blob_for_each_attr(cur, blob_data(msg), rem) {
|
||||
if (!strcasecmp("Alarm VPD HI", blobmsg_name(cur))) {
|
||||
data = blobmsg_data(cur);
|
||||
/* if on */
|
||||
if (!strcmp("on", data)) {
|
||||
state = STATE_ALERT;
|
||||
}
|
||||
}else if (!strcasecmp("Alarm VPD LO", blobmsg_name(cur))) {
|
||||
data = blobmsg_data(cur);
|
||||
/* if on */
|
||||
if (!strcmp("on", data)) {
|
||||
state = STATE_ALERT;
|
||||
}
|
||||
}else if (!strcasecmp("Warning VPD HI", blobmsg_name(cur))) {
|
||||
data = blobmsg_data(cur);
|
||||
/* if on */
|
||||
if (!strcmp("on", data)) {
|
||||
state = STATE_NOTICE;
|
||||
}
|
||||
}else if (!strcasecmp("Warning VPD LO", blobmsg_name(cur))) {
|
||||
data = blobmsg_data(cur);
|
||||
/* if on */
|
||||
if (!strcmp("on", data)) {
|
||||
state = STATE_NOTICE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void catv_monitor_handler(struct uloop_timeout *timeout)
|
||||
{
|
||||
uint32_t id;
|
||||
struct blob_buf b;
|
||||
int ret;
|
||||
|
||||
/* start to set new state to OK */
|
||||
/* then checks turn on different errors */
|
||||
state = STATE_OK;
|
||||
|
||||
if (is_enabled()) {
|
||||
|
||||
if (ubus_lookup_id(ubus_ctx, "catv", &id)) {
|
||||
DBG(1, "Failed to look up catv object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&b, 0, sizeof(struct blob_buf));
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
/* first check alarms, they set notice/alert if present */
|
||||
ret = ubus_invoke(ubus_ctx, id, "alarm", b.head, catv_alarm_cb, 0, 3000);
|
||||
if (ret)
|
||||
DBG(1,"ret = %s", ubus_strerror(ret));
|
||||
|
||||
/* then check cable in, it sets Error,*/
|
||||
ret = ubus_invoke(ubus_ctx, id, "vpd", b.head, catv_vpd_cb, 0, 3000);
|
||||
if (ret)
|
||||
DBG(1,"ret = %s", ubus_strerror(ret));
|
||||
}else
|
||||
state = STATE_OFF;
|
||||
|
||||
set_led(state);
|
||||
|
||||
uloop_timeout_set(&catv_monitor_timer, CATV_MONITOR_TIME);
|
||||
}
|
||||
|
||||
static void set_led(state_t lstate)
|
||||
{
|
||||
uint32_t id;
|
||||
struct blob_buf b;
|
||||
int ret;
|
||||
static state_t old_state = -1;
|
||||
|
||||
if ( lstate == old_state )
|
||||
return;
|
||||
old_state = lstate;
|
||||
|
||||
memset(&b, 0, sizeof(struct blob_buf));
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
switch (lstate) {
|
||||
case STATE_OFF:
|
||||
blobmsg_add_string(&b, "state", "off"); break;
|
||||
case STATE_OK:
|
||||
blobmsg_add_string(&b, "state", "ok"); break;
|
||||
case STATE_NOTICE:
|
||||
blobmsg_add_string(&b, "state", "notice"); break;
|
||||
case STATE_ALERT:
|
||||
blobmsg_add_string(&b, "state", "alert"); break;
|
||||
case STATE_ERROR:
|
||||
blobmsg_add_string(&b, "state", "error"); break;
|
||||
}
|
||||
|
||||
if (ubus_lookup_id(ubus_ctx, "led.ext", &id)) {
|
||||
DBG(1, "Failed to look up led.ext object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = ubus_invoke(ubus_ctx, id, "set", b.head, NULL, 0, 3000);
|
||||
|
||||
if ( ret )
|
||||
DBG(1,"catv_moitor: set led failed [%s]", ubus_strerror(ret));
|
||||
}
|
||||
|
||||
void catv_monitor_init(struct server_ctx *s_ctx)
|
||||
{
|
||||
ubus_ctx = ubus_connect(ubus_socket);
|
||||
if (!ubus_ctx) {
|
||||
syslog(LOG_ERR,"catv monitor: Failed to connect to ubus\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* start monitor timer */
|
||||
uloop_timeout_set(&catv_monitor_timer, CATV_MONITOR_TIME);
|
||||
}
|
||||
|
||||
void catv_monitor_set_socket(char *socket_name)
|
||||
{
|
||||
if (socket_name)
|
||||
ubus_socket = strdup(socket_name);
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include "gpio.h"
|
||||
#include "log.h"
|
||||
|
||||
#define DEVFILE_BRCM_BOARD "/dev/brcmboard"
|
||||
|
||||
static int brcmboard = -1;
|
||||
|
||||
|
||||
int board_ioctl_init(void) {
|
||||
if (brcmboard == -1){
|
||||
brcmboard = open(DEVFILE_BRCM_BOARD, O_RDWR);
|
||||
if ( brcmboard == -1 ) {
|
||||
syslog(LOG_ERR, "failed to open: %s", DEVFILE_BRCM_BOARD);
|
||||
return 1;
|
||||
}
|
||||
DBG(1, "fd %d allocated\n", brcmboard);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int board_ioctl(int ioctl_id, int action, int hex, char* string_buf, int string_buf_len, int offset) {
|
||||
BOARD_IOCTL_PARMS IoctlParms = {0};
|
||||
|
||||
IoctlParms.string = string_buf;
|
||||
IoctlParms.strLen = string_buf_len;
|
||||
IoctlParms.offset = offset;
|
||||
IoctlParms.action = action;
|
||||
IoctlParms.buf = (char*)"";
|
||||
|
||||
if ( ioctl(brcmboard, ioctl_id, &IoctlParms) < 0 ) {
|
||||
syslog(LOG_ERR, "ioctl: %d failed", ioctl_id);
|
||||
return(-255);
|
||||
}
|
||||
return IoctlParms.result;
|
||||
}
|
||||
|
||||
|
||||
gpio_state_t gpio_get_state(gpio_t gpio)
|
||||
{
|
||||
return board_ioctl(BOARD_IOCTL_GET_GPIO, 0, 0, NULL, gpio, 0);
|
||||
}
|
||||
|
||||
|
||||
void gpio_set_state(gpio_t gpio, gpio_state_t state)
|
||||
{
|
||||
board_ioctl(BOARD_IOCTL_SET_GPIO, 0, 0, NULL, gpio, state);
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#ifndef GPIO_H
|
||||
#define GPIO_H
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <board.h>
|
||||
|
||||
typedef int gpio_t;
|
||||
|
||||
typedef enum {
|
||||
GPIO_STATE_LOW,
|
||||
GPIO_STATE_HIGH,
|
||||
} gpio_state_t;
|
||||
|
||||
int board_ioctl_init(void);
|
||||
int board_ioctl(int ioctl_id, int action, int hex, char* string_buf, int string_buf_len, int offset);
|
||||
#define gpio_init() board_ioctl_init()
|
||||
gpio_state_t gpio_get_state(gpio_t gpio);
|
||||
void gpio_set_state(gpio_t gpio, gpio_state_t state);
|
||||
|
||||
#endif /* GPIO_H */
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include "button.h"
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
#include "gpio.h"
|
||||
#include <board.h>
|
||||
|
||||
void gpio_button_init(struct server_ctx *s_ctx);
|
||||
|
||||
struct gpio_button_data {
|
||||
int addr;
|
||||
int active;
|
||||
int state;
|
||||
struct button_drv button;
|
||||
};
|
||||
|
||||
static button_state_t gpio_button_get_state(struct button_drv *drv)
|
||||
{
|
||||
// DBG(1, "state for %s", drv->name);
|
||||
struct gpio_button_data *p = (struct gpio_button_data *)drv->priv;
|
||||
int value;
|
||||
|
||||
value = board_ioctl( BOARD_IOCTL_GET_GPIO, 0, 0, NULL, p->addr, 0);
|
||||
|
||||
if(p->active)
|
||||
p->state = !!value;
|
||||
else
|
||||
p->state = !value;
|
||||
|
||||
return p->state;
|
||||
}
|
||||
|
||||
static struct button_drv_func func = {
|
||||
.get_state = gpio_button_get_state,
|
||||
};
|
||||
|
||||
void gpio_button_init(struct server_ctx *s_ctx) {
|
||||
struct ucilist *node;
|
||||
LIST_HEAD(buttons);
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"gpio_buttons", "buttons", &buttons);
|
||||
list_for_each_entry(node, &buttons, list) {
|
||||
struct gpio_button_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct gpio_button_data));
|
||||
memset(data,0,sizeof(struct gpio_button_data));
|
||||
|
||||
data->button.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s){
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "active");
|
||||
data->active = -1;
|
||||
if (s){
|
||||
if (!strncasecmp("hi",s,2))
|
||||
data->active = 1;
|
||||
else if (!strncasecmp("low",s,3))
|
||||
data->active = 0;
|
||||
|
||||
}
|
||||
DBG(1, "active = %d", data->active);
|
||||
|
||||
data->button.func = &func;
|
||||
data->button.priv = data;
|
||||
|
||||
button_add(&data->button);
|
||||
}
|
||||
|
||||
gpio_init();
|
||||
}
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <board.h>
|
||||
#include "led.h"
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
#include "gpio.h"
|
||||
#include "gpio_shift_register.h"
|
||||
|
||||
gpio_shift_register_t led_gpio_shift_register;
|
||||
|
||||
void gpio_led_init(struct server_ctx *s_ctx);
|
||||
|
||||
typedef enum {
|
||||
LOW,
|
||||
HI,
|
||||
UNKNOWN,
|
||||
} active_t;
|
||||
|
||||
typedef enum {
|
||||
MODE_UNKNOWN,
|
||||
DIRECT,
|
||||
SHIFTREG_BRCM,
|
||||
SHIFTREG_GPIO,
|
||||
} gpio_mode_t;
|
||||
|
||||
struct gpio_led_data {
|
||||
int addr;
|
||||
active_t active;
|
||||
int state;
|
||||
gpio_mode_t mode;
|
||||
struct led_drv led;
|
||||
};
|
||||
|
||||
static int gpio_led_set_state(struct led_drv *drv, led_state_t state)
|
||||
{
|
||||
struct gpio_led_data *p = (struct gpio_led_data *)drv->priv;
|
||||
int bit_val = 0;
|
||||
|
||||
if(state) {
|
||||
if(p->active)
|
||||
bit_val=1;
|
||||
} else {
|
||||
if(!p->active)
|
||||
bit_val=1;
|
||||
}
|
||||
|
||||
p->state = state;
|
||||
|
||||
switch (p->mode) {
|
||||
case DIRECT:
|
||||
board_ioctl( BOARD_IOCTL_SET_GPIO, 0, 0, NULL, p->addr, bit_val);
|
||||
break;
|
||||
case SHIFTREG_BRCM:
|
||||
board_ioctl( BOARD_IOCTL_LED_CTRL, 0, 0, NULL, p->addr, bit_val);
|
||||
break;
|
||||
case SHIFTREG_GPIO:
|
||||
gpio_shift_register_cached_set(&led_gpio_shift_register, p->addr, bit_val);
|
||||
break;
|
||||
default:
|
||||
DBG(1,"access mode not supported [%d,%s]", p->mode, p->led.name);
|
||||
}
|
||||
|
||||
return p->state;
|
||||
}
|
||||
|
||||
static led_state_t gpio_led_get_state(struct led_drv *drv)
|
||||
{
|
||||
struct gpio_led_data *p = (struct gpio_led_data *)drv->priv;
|
||||
DBG(1, "state for %s", drv->name);
|
||||
|
||||
return p->state;
|
||||
}
|
||||
|
||||
static struct led_drv_func func = {
|
||||
.set_state = gpio_led_set_state,
|
||||
.get_state = gpio_led_get_state,
|
||||
};
|
||||
|
||||
void gpio_led_init(struct server_ctx *s_ctx) {
|
||||
|
||||
LIST_HEAD(leds);
|
||||
struct ucilist *node;
|
||||
int gpio_shiftreg_clk=0, gpio_shiftreg_dat=1, gpio_shiftreg_mask=2, gpio_shiftreg_bits=0;
|
||||
char *s;
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
if((s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "gpio_shiftreg_clk")))
|
||||
gpio_shiftreg_clk = strtol(s,0,0);
|
||||
DBG(1, "gpio_shiftreg_clk = [%d]", gpio_shiftreg_clk);
|
||||
if((s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "gpio_shiftreg_dat")))
|
||||
gpio_shiftreg_dat = strtol(s,0,0);
|
||||
DBG(1, "gpio_shiftreg_dat = [%d]", gpio_shiftreg_dat);
|
||||
if((s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "gpio_shiftreg_mask")))
|
||||
gpio_shiftreg_mask = strtol(s,0,0);
|
||||
DBG(1, "gpio_shiftreg_mask = [%d]", gpio_shiftreg_mask);
|
||||
if((s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "gpio_shiftreg_bits")))
|
||||
gpio_shiftreg_bits = strtol(s,0,0);
|
||||
DBG(1, "gpio_shiftreg_bits = [%d]", gpio_shiftreg_bits);
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"gpio_leds", "leds", &leds);
|
||||
list_for_each_entry(node,&leds,list){
|
||||
struct gpio_led_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct gpio_led_data));
|
||||
memset(data,0,sizeof(struct gpio_led_data));
|
||||
|
||||
data->led.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s) {
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "mode");
|
||||
DBG(1, "mode = [%s]", s);
|
||||
if (s) {
|
||||
|
||||
if (!strncasecmp("direct",s,3))
|
||||
data->mode = DIRECT;
|
||||
else if (!strncasecmp("sr",s,5))
|
||||
data->mode = SHIFTREG_BRCM;
|
||||
else if (!strncasecmp("csr",s,4))
|
||||
data->mode = SHIFTREG_GPIO;
|
||||
else
|
||||
DBG(1, "Mode %s : Not supported!", s);
|
||||
}
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "active");
|
||||
DBG(1, "active = [%s]", s);
|
||||
if (s) {
|
||||
data->active = UNKNOWN;
|
||||
if (!strncasecmp("hi",s,3))
|
||||
data->active = HI;
|
||||
if (!strncasecmp("low",s,3))
|
||||
data->active = LOW;
|
||||
}
|
||||
data->led.func = &func;
|
||||
data->led.priv = data;
|
||||
led_add(&data->led);
|
||||
}
|
||||
gpio_init();
|
||||
gpio_shift_register_init(&led_gpio_shift_register, gpio_shiftreg_clk, gpio_shiftreg_dat, gpio_shiftreg_mask, gpio_shiftreg_bits);
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#include "gpio_shift_register.h"
|
||||
#include <stdlib.h>
|
||||
#include "log.h"
|
||||
|
||||
int gpio_shift_register_init(gpio_shift_register_t *p, gpio_t gpio_clk, gpio_t gpio_dat, gpio_t gpio_mask, int size)
|
||||
{
|
||||
p->clk=gpio_clk;
|
||||
p->dat=gpio_dat;
|
||||
p->mask=gpio_mask;
|
||||
p->size=size;
|
||||
p->state_cache=0;
|
||||
gpio_set_state(p->clk, 0);
|
||||
gpio_set_state(p->dat, 0);
|
||||
gpio_set_state(p->mask, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gpio_shift_register_set(gpio_shift_register_t *p, int state)
|
||||
{
|
||||
int i;
|
||||
if(!p->size)
|
||||
return;
|
||||
gpio_set_state(p->mask, 0); //mask low
|
||||
for(i=p->size; i; i--) {
|
||||
gpio_set_state(p->clk, 0); //clk low
|
||||
gpio_set_state(p->dat, (state>>(i-1)) & 1); //place bit
|
||||
gpio_set_state(p->clk, 1); //clk high
|
||||
}
|
||||
gpio_set_state(p->mask, 1); //mask high / sreg load
|
||||
p->state_cache=state; //update internal register copy
|
||||
}
|
||||
|
||||
|
||||
void gpio_shift_register_cached_set(gpio_shift_register_t *p, shift_register_index_t index, gpio_state_t state)
|
||||
{
|
||||
if(!p->size)
|
||||
return;
|
||||
if(!(index < p->size)) {
|
||||
syslog(LOG_ERR, "index %d out of bounds", index);
|
||||
return;
|
||||
}
|
||||
//update internal register copy
|
||||
if(state)
|
||||
p->state_cache |= (1<<index);
|
||||
else
|
||||
p->state_cache &= ~(1<<index);
|
||||
gpio_shift_register_set(p, p->state_cache);
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef GPIO_SHIFT_REGISTER_H
|
||||
#define GPIO_SHIFT_REGISTER_H
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
typedef int shift_register_index_t;
|
||||
|
||||
typedef struct {
|
||||
gpio_t clk;
|
||||
gpio_t dat;
|
||||
gpio_t mask;
|
||||
int size;
|
||||
int state_cache;
|
||||
} gpio_shift_register_t;
|
||||
|
||||
int gpio_shift_register_init(gpio_shift_register_t *p, gpio_t gpio_clk, gpio_t gpio_dat, gpio_t gpio_mask, int size);
|
||||
void gpio_shift_register_set(gpio_shift_register_t *p, int state);
|
||||
void gpio_shift_register_cached_set(gpio_shift_register_t *p, shift_register_index_t address, gpio_state_t bit_val);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,376 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
//#include <libgen.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <error.h>
|
||||
#include <errno.h>
|
||||
//#include <limits.h>
|
||||
//#include <sys/types.h>
|
||||
//#include <sys/stat.h>
|
||||
//#include <syslog.h>
|
||||
//#include <config.h>
|
||||
#include <getopt.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include "smbus.h"
|
||||
#include "i2c.h"
|
||||
#include "log.h"
|
||||
#include "gpio.h"
|
||||
#include "gpio_shift_register.h"
|
||||
#include "sx9512.h"
|
||||
|
||||
#define DEV_I2C "/dev/i2c-0"
|
||||
|
||||
int verbose, debug_level;
|
||||
|
||||
|
||||
#define CMDS \
|
||||
X(NONE, "none", 0, 0, "", "") \
|
||||
X(GPIO_GET, "gpio_get", 1, 1, "Get pin state", "<pin>") \
|
||||
X(GPIO_SET, "gpio_set", 2, 2, "Set pin state", "<pin> <state>") \
|
||||
X(SH_SET, "sh_set", 5, 5, "Set shift register state", "<clk> <dat> <mask> <size> <state>") \
|
||||
X(SMBUS_READ, "smbus_read", 3, 3, "Read from I2C/SMBUS device", "<addr> <reg> <len>") \
|
||||
X(SMBUS_WRITE, "smbus_write", 3, 3, "Write to I2C/SMBUS device", "<addr> <reg> <hex_data>") \
|
||||
X(SX9512_BUTTON, "sx9512_button", 0, 0, "Read SX9512 buttons (endless loop)", "") \
|
||||
X(SX9512_READ, "sx9512_read", 0, 0, "Look at configuration data (compare to default)", "") \
|
||||
X(SX9512_INIT, "sx9512_init", 0, 1, "Init SX9512 config to device defaults", "[device]") \
|
||||
X(SX9512_NVM_LOAD, "sx9512_nvm_load", 0, 0, "SX9512 load values from NVM", "") \
|
||||
X(SX9512_NVM_STORE, "sx9512_nvm_store", 0, 0, "SX9512 store config to NVM", "") \
|
||||
X(SX9512_RESET, "sx9512_reset", 0, 0, "Send reset command to SX9512", "")
|
||||
|
||||
|
||||
#define X(id, str, min_arg, max_arg, desc, arg_desc) CMD_##id,
|
||||
enum { CMDS CMDS_AMOUNT } cmd;
|
||||
#undef X
|
||||
|
||||
struct cmd {
|
||||
const char *str;
|
||||
int min_arg, max_arg;
|
||||
const char *desc, *arg_desc;
|
||||
};
|
||||
|
||||
#define X(id, str, min_arg, max_arg, desc, arg_desc) { str, min_arg, max_arg, desc, arg_desc },
|
||||
const struct cmd cmd_data[] = { CMDS };
|
||||
#undef X
|
||||
|
||||
|
||||
#define SX9512_DEVCFGS \
|
||||
X(NONE, "none" ) \
|
||||
X(DEFAULT, "default") \
|
||||
X(CLEAR, "clear" ) \
|
||||
X(CG300, "cg300" ) \
|
||||
X(CG301, "cg301" ) \
|
||||
X(EG300, "eg300" ) \
|
||||
X(DG400, "dg400" )
|
||||
|
||||
#define X(a, b) SX9512_DEVCFG_##a,
|
||||
enum sx9512_devcfg { SX9512_DEVCFGS SX9512_DEVCFG_AMOUNT };
|
||||
#undef X
|
||||
|
||||
#define X(a, b) b,
|
||||
const char *sx9512_devcfg_str[] = { SX9512_DEVCFGS };
|
||||
#undef X
|
||||
|
||||
|
||||
static enum sx9512_devcfg sx9512_devcfg_str_to_id(const char *s)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<SX9512_DEVCFG_AMOUNT; i++) {
|
||||
if(!strcmp(s, sx9512_devcfg_str[i]))
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void print_usage(char *prg_name)
|
||||
{
|
||||
int i;
|
||||
char tmp[64];
|
||||
printf("Usage: %s [options...] <cmd> <arg(s)>\n", prg_name);
|
||||
printf("Options:\n");
|
||||
printf(" -v, --verbose Verbose output\n");
|
||||
printf(" -h, --help Show this help screen.\n");
|
||||
printf("Commands:\n");
|
||||
for(i=0;i<CMDS_AMOUNT;i++) {
|
||||
sprintf(tmp, "%s %s", cmd_data[i].str, cmd_data[i].arg_desc);
|
||||
printf(" %-40.40s %s\n", tmp, cmd_data[i].desc);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, j, ch, r, fd=0;
|
||||
int pin, state;
|
||||
int pin_clk, pin_dat, pin_mask;
|
||||
gpio_shift_register_t p;
|
||||
int addr=0, s, n, l;
|
||||
enum sx9512_devcfg devcfg=0;
|
||||
uint8_t tmp[32];
|
||||
char *str_value=0, *eptr, str_hex[3];
|
||||
struct sx9512_reg_nvm nvm, nvm_def;
|
||||
while(1) {
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
ch = getopt_long(argc, argv, "vh", long_options, &option_index);
|
||||
if(ch == -1)
|
||||
break;
|
||||
switch (ch) {
|
||||
case 'v':
|
||||
verbose=1;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
print_usage(argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
//i=argc-optind;
|
||||
if((argc-optind)<1) {
|
||||
print_usage(argv[0]);
|
||||
error(-1, errno, "Error: need cmd");
|
||||
}
|
||||
for(i=0;i<CMDS_AMOUNT;i++) {
|
||||
if(!strcmp(argv[optind], cmd_data[i].str))
|
||||
cmd=i;
|
||||
}
|
||||
if(!cmd) {
|
||||
print_usage(argv[0]);
|
||||
error(-1, errno, "Error: bad cmd %s", argv[optind]);
|
||||
}
|
||||
optind++;
|
||||
if((argc-optind)<cmd_data[cmd].min_arg) {
|
||||
print_usage(argv[0]);
|
||||
error(-1, errno, "Error: too few arguments");
|
||||
}
|
||||
if((argc-optind)>cmd_data[cmd].max_arg) {
|
||||
print_usage(argv[0]);
|
||||
error(-1, errno, "Error: too many arguments");
|
||||
}
|
||||
switch(cmd) {
|
||||
case CMD_GPIO_GET:
|
||||
case CMD_GPIO_SET:
|
||||
case CMD_SH_SET:
|
||||
gpio_init();
|
||||
break;
|
||||
case CMD_SMBUS_READ:
|
||||
case CMD_SMBUS_WRITE:
|
||||
addr=strtol(argv[optind],NULL,16);
|
||||
optind++;
|
||||
if(verbose)
|
||||
printf("Open I2C device %s\n", DEV_I2C);
|
||||
fd = open(DEV_I2C, O_RDWR);
|
||||
if(fd < 0)
|
||||
error(-1, errno, "could not open %s", DEV_I2C);
|
||||
if(verbose)
|
||||
printf("Set I2C addr=%02x\n", addr);
|
||||
if(ioctl(fd, I2C_SLAVE, addr) < 0) {
|
||||
error(0, errno, "could not set address %x for i2c chip", addr);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case CMD_SX9512_BUTTON:
|
||||
case CMD_SX9512_READ:
|
||||
case CMD_SX9512_INIT:
|
||||
case CMD_SX9512_NVM_LOAD:
|
||||
case CMD_SX9512_NVM_STORE:
|
||||
case CMD_SX9512_RESET:
|
||||
if((fd=sx9512_init(DEV_I2C, SX9512_I2C_ADDRESS, NULL))<0)
|
||||
error(-1, errno, "could not init SX9512");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(cmd) {
|
||||
case CMD_GPIO_GET:
|
||||
pin=strtol(argv[optind],0,0);
|
||||
if(verbose)
|
||||
printf("Get gpio %d state\n", pin);
|
||||
r=gpio_get_state(pin);
|
||||
if(verbose)
|
||||
printf("state=%d\n", r);
|
||||
return(r);
|
||||
case CMD_GPIO_SET:
|
||||
pin=strtol(argv[optind],0,0);
|
||||
optind++;
|
||||
state=strtol(argv[optind],0,0);
|
||||
if(state!=0 && state!=1) {
|
||||
print_usage(argv[0]);
|
||||
error(-1, errno, "Error: bad state %d", state);
|
||||
}
|
||||
if(verbose)
|
||||
printf("Set gpio %d state to %d\n", pin, state);
|
||||
gpio_set_state(pin, state);
|
||||
break;
|
||||
case CMD_SH_SET:
|
||||
pin_clk=strtol(argv[optind],NULL,0);
|
||||
optind++;
|
||||
pin_dat=strtol(argv[optind],NULL,0);
|
||||
optind++;
|
||||
pin_mask=strtol(argv[optind],NULL,0);
|
||||
optind++;
|
||||
s=strtol(argv[optind],NULL,0);
|
||||
optind++;
|
||||
state=strtol(argv[optind],NULL,16);
|
||||
if(verbose)
|
||||
printf("Set shift register (clk=%d, dat=%d, mask=%d, size=%d) state to %X\n", pin_clk, pin_dat, pin_mask, s, state);
|
||||
gpio_shift_register_init(&p, pin_clk, pin_dat, pin_mask, s);
|
||||
gpio_shift_register_set(&p, state);
|
||||
break;
|
||||
case CMD_SMBUS_READ:
|
||||
s=strtol(argv[optind],NULL,16);
|
||||
optind++;
|
||||
n=strtol(argv[optind],NULL,0);
|
||||
if(s+n>256)
|
||||
n=256-s;
|
||||
if(verbose)
|
||||
printf("smbus read start (addr=%02x, reg=%02x, len=%d)\n", addr, s, n);
|
||||
for(i=s; i<(s+n); i+=32) {
|
||||
l=n-(i-s);
|
||||
if(l>32)
|
||||
l=32;
|
||||
if(verbose)
|
||||
printf("smbus read (reg=%02x, len=%d)\n", i, l);
|
||||
r=i2c_smbus_read_i2c_block_data(fd, i, l, (__u8 *)&tmp);
|
||||
if(r<0) {
|
||||
error(0, errno, "I2C read error (%d)", r);
|
||||
close(fd);
|
||||
return(-1);
|
||||
}
|
||||
printf("%02X:", i/32);
|
||||
for(j=0; j<l; j++)
|
||||
printf("%02x", tmp[j]);
|
||||
printf("\n");
|
||||
}
|
||||
close(fd);
|
||||
if(n==1)
|
||||
return(tmp[0]);
|
||||
break;
|
||||
case CMD_SMBUS_WRITE:
|
||||
s=strtol(argv[optind],NULL,16);
|
||||
optind++;
|
||||
str_value = argv[optind];
|
||||
n=strlen(str_value);
|
||||
if(n%2)
|
||||
error(-1, errno, "Error: odd length hex value %s", str_value);
|
||||
n>>=1;
|
||||
if(s+n>256)
|
||||
n=256-s;
|
||||
if(verbose)
|
||||
printf("smbus write start (addr=%02x, reg=%02x, len=%d, val=%s)\n", addr, s, n, str_value);
|
||||
for(i=0; i<n; i+=32) {
|
||||
l=n-i;
|
||||
if(l>32)
|
||||
l=32;
|
||||
str_hex[2]=0;
|
||||
for(j=0; j<l; j++) {
|
||||
str_hex[0]=str_value[(i+j)<<1];
|
||||
str_hex[1]=str_value[((i+j)<<1)+1];
|
||||
tmp[j]=strtol(str_hex, &eptr,16);
|
||||
if((errno != 0 && tmp[j] == 0) || eptr==str_hex)
|
||||
error(-1, errno, "hex conversion error at %d (%s)", j, str_hex);
|
||||
}
|
||||
if(verbose)
|
||||
printf("smbus write (reg=%02x, len=%d, val=%.*s)\n", s+i, l, l*2, str_value+(i*2));
|
||||
r=i2c_smbus_write_i2c_block_data(fd, s+i, l, tmp);
|
||||
if(r<0) {
|
||||
error(0, errno, "I2C write error (%d)", r);
|
||||
close(fd);
|
||||
return(-1);
|
||||
}
|
||||
printf("%02X:", i/32);
|
||||
for(j=0; j<l; j++)
|
||||
printf("%02x ", tmp[j]);
|
||||
printf("\n");
|
||||
}
|
||||
close(fd);
|
||||
break;
|
||||
case CMD_SX9512_BUTTON:
|
||||
while(1) {
|
||||
if(verbose)
|
||||
printf("Start reading buttons from SX9512\n");
|
||||
struct sx9512_touch_state touch_state;
|
||||
if(sx9512_read_status_cached(fd, &touch_state))
|
||||
error(-1, errno, "I2C read error");
|
||||
//printf("[state %02X]\n", touch_state.state);
|
||||
if(touch_state.touched)
|
||||
printf("[touch %02X]\n", touch_state.touched);
|
||||
if(touch_state.released)
|
||||
printf("[release %02X]\n", touch_state.released);
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
}
|
||||
break;
|
||||
case CMD_SX9512_READ:
|
||||
if(verbose)
|
||||
printf("Read SX9512 registers (and compare to defaults)\n");
|
||||
sx9512_reg_nvm_init_defaults(&nvm_def, 0xff, 0xff);
|
||||
if(sx9512_reg_nvm_read(fd, &nvm))
|
||||
error(-1, errno, "while reading nvm registers");
|
||||
s=sizeof(nvm);
|
||||
for(i=0; i<s; i++)
|
||||
printf("%02x: %02x (%02x)0 %s\n", SX9512_REG_NVM_AREA_START+i, ((uint8_t *)&nvm)[i], ((uint8_t *)&nvm_def)[i], sx9512_reg_name(SX9512_REG_NVM_AREA_START+i));
|
||||
break;
|
||||
case CMD_SX9512_INIT:
|
||||
if((argc-optind)==1)
|
||||
devcfg = sx9512_devcfg_str_to_id(argv[optind]);
|
||||
switch(devcfg) {
|
||||
case SX9512_DEVCFG_DEFAULT:
|
||||
sx9512_reg_nvm_init_defaults(&nvm, 0xff, 0xff);
|
||||
break;
|
||||
case SX9512_DEVCFG_CLEAR:
|
||||
memset(&nvm, 0, sizeof(nvm));
|
||||
break;
|
||||
case SX9512_DEVCFG_CG300:
|
||||
sx9512_reg_nvm_init_cg300(&nvm);
|
||||
break;
|
||||
case SX9512_DEVCFG_CG301:
|
||||
sx9512_reg_nvm_init_cg301(&nvm);
|
||||
break;
|
||||
case SX9512_DEVCFG_EG300:
|
||||
sx9512_reg_nvm_init_eg300(&nvm);
|
||||
break;
|
||||
case SX9512_DEVCFG_DG400:
|
||||
sx9512_reg_nvm_init_dg400(&nvm);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Error: bad device arg, valid options are:\n");
|
||||
for(i=0;i<SX9512_DEVCFG_AMOUNT;i++)
|
||||
fprintf(stderr, "%s ", sx9512_devcfg_str[i]);
|
||||
fprintf(stderr, "\n");
|
||||
return -1;
|
||||
}
|
||||
if(verbose)
|
||||
printf("Init SX9512 registers to %s\n", sx9512_devcfg_str[devcfg]);
|
||||
if(sx9512_reg_nvm_write(fd, &nvm))
|
||||
error(-1, errno, "while writing nvm registers");
|
||||
break;
|
||||
case CMD_SX9512_NVM_LOAD:
|
||||
if(sx9512_reg_nvm_load(fd))
|
||||
error(-1, errno, "while loading nvm registers");
|
||||
break;
|
||||
case CMD_SX9512_NVM_STORE:
|
||||
if(sx9512_reg_nvm_store(fd))
|
||||
error(-1, errno, "while storing nvm registers");
|
||||
break;
|
||||
case CMD_SX9512_RESET:
|
||||
if(sx9512_reset(fd))
|
||||
error(-1, errno, "while trying to reset");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "smbus.h"
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
|
||||
#include "i2c.h"
|
||||
#include "log.h"
|
||||
|
||||
void dump_i2c(int fd,int start,int stop)
|
||||
{
|
||||
int i;
|
||||
int res;
|
||||
|
||||
for (i=start ; i < stop; i++) {
|
||||
res = i2c_smbus_read_byte_data(fd,i);
|
||||
if (res < 0){perror("i2c error\n");}
|
||||
DBG(1,"/dev/i2c-0 READ %d = 0x%02x\n",i,(unsigned char)res);
|
||||
}
|
||||
}
|
||||
|
||||
int i2c_open_dev (const char *bus, int addr, unsigned long funcs_needed)
|
||||
{
|
||||
int fd = open(bus, O_RDWR);
|
||||
if (fd < 0) {
|
||||
syslog(LOG_INFO,"%s: could not open %s\n",__func__, bus);
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, I2C_SLAVE, addr) < 0) {
|
||||
syslog(LOG_INFO,"%s: could not set address %x for i2c chip\n",
|
||||
__func__, addr);
|
||||
error:
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
if(funcs_needed) {
|
||||
unsigned long funcs;
|
||||
if (ioctl(fd, I2C_FUNCS, &funcs) < 0) {
|
||||
syslog(LOG_INFO,"%s: could not get I2C_FUNCS\n",__func__);
|
||||
goto error;
|
||||
}
|
||||
if((funcs & funcs_needed) != funcs_needed) {
|
||||
syslog(LOG_INFO,"%s: lacking I2C capabilities, have %lx, need %lx\n",
|
||||
__func__, funcs, funcs_needed);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
void dump_i2c(int fd,int start,int stop);
|
||||
int i2c_open_dev (const char *bus, int addr, unsigned long functions_needed);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,895 +0,0 @@
|
|||
#include <ctype.h>
|
||||
#include <syslog.h>
|
||||
#include "log.h"
|
||||
#include "led.h"
|
||||
|
||||
static struct blob_buf bblob;
|
||||
|
||||
typedef enum {
|
||||
LED_OFF,
|
||||
LED_OK,
|
||||
LED_EOK,
|
||||
LED_NOTICE,
|
||||
LED_ALERT,
|
||||
LED_ERROR,
|
||||
LED_CUSTOM,
|
||||
LED_ACTION_MAX,
|
||||
} led_action_t;
|
||||
|
||||
typedef enum {
|
||||
LEDS_NORMAL,
|
||||
LEDS_PROXIMITY,
|
||||
LEDS_SILENT,
|
||||
LEDS_INFO,
|
||||
LEDS_TEST,
|
||||
LEDS_PROD,
|
||||
LEDS_RESET,
|
||||
LEDS_ALLON,
|
||||
LEDS_ALLOFF,
|
||||
LEDS_MAX,
|
||||
} leds_state_t;
|
||||
|
||||
/* Names for led_action_t */
|
||||
static const char * const fn_actions[LED_ACTION_MAX] =
|
||||
{ "off", "ok", "eok", "notice", "alert", "error", "custom"};
|
||||
|
||||
/* Names for led_state_t */
|
||||
static const char* const led_states[LED_STATES_MAX] =
|
||||
{ "off", "on", "flash_slow", "flash_fast","pulsing", "fadeon", "fadeoff" };
|
||||
|
||||
/* Names for leds_state_t */
|
||||
static const char* const leds_states[LEDS_MAX] =
|
||||
{ "normal", "proximity", "silent", "info", "test", "production", "reset", "allon" , "alloff"};
|
||||
|
||||
/* lowest level, contain states, timers,pointer to driver for a single physical led.*/
|
||||
struct led {
|
||||
struct list_head list;
|
||||
led_state_t state; /* state that this led should have, set from the config file */
|
||||
struct led_drv *drv;
|
||||
};
|
||||
|
||||
struct super_functions {
|
||||
struct list_head list;
|
||||
led_action_t state; /* state that the function need to match */
|
||||
struct function_led *function;
|
||||
};
|
||||
|
||||
struct super_list {
|
||||
struct list_head list;
|
||||
struct list_head sf_list; /* this list contains states that needs to match for this super fuction action to be active */
|
||||
};
|
||||
|
||||
/*middle layer contains lists of leds /buttons/... that should be set to a specific state */
|
||||
struct function_action {
|
||||
const char *name; /* If name is set this led action is in use by the board. */
|
||||
struct list_head led_list;
|
||||
struct list_head button_list;
|
||||
struct list_head super_list; /* list of super function lists */
|
||||
};
|
||||
|
||||
/* main struct for the function leds.*/
|
||||
struct function_led {
|
||||
const char *name; /* If name is set this led function is in use by the board. */
|
||||
led_action_t state; /* state of the function led. contain what action is currently set */
|
||||
int dimming; /* should this led be dimmed */
|
||||
int brightness; /* Brightness of the led */
|
||||
int press_indicator; /* record if this is part of press indictor */
|
||||
struct function_action actions[LED_ACTION_MAX];
|
||||
};
|
||||
|
||||
struct function_led *leds; /* Array of functions, LED_FUNCTIONS + super_functions */
|
||||
static int total_functions; /* number of entries in leds array */
|
||||
|
||||
static leds_state_t global_state; /* global state for the leds,overrids individual states */
|
||||
static leds_state_t press_state; /* global state for the press indicator */
|
||||
|
||||
static led_action_t dimming_level; /* The min level where dimming should not happen on led */
|
||||
static int dimming_timeout; /* The time to turn on leds when we have dimming on */
|
||||
static int dimming_count; /* as long as this is not zero show all leds */
|
||||
|
||||
|
||||
int get_index_by_name(const char *const*array, int max, const char *name);
|
||||
int get_index_for_function(const char *name);
|
||||
struct led_drv *get_drv_led(char *name);
|
||||
static void dump_drv_list(void);
|
||||
static void dump_led(void);
|
||||
static void all_leds_off(void);
|
||||
static void all_leds_on(void);
|
||||
static void all_leds(led_state_t state);
|
||||
static const char * get_function_action( const char *s, struct function_led **function, int *action);
|
||||
static void super_update(void);
|
||||
|
||||
/* we find out the index for a match in an array of char pointers containing max number of pointers */
|
||||
int get_index_by_name(const char *const*array, int max, const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < max ; i++ ){
|
||||
if (!strcasecmp(name, array[i]))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int get_index_for_function(const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i=0 ; i < total_functions; i++) {
|
||||
if (!strcasecmp(name, leds[i].name))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* PUT every led from drivers into a list */
|
||||
struct drv_led_list{
|
||||
struct list_head list;
|
||||
struct led_drv *drv;
|
||||
};
|
||||
LIST_HEAD(drv_leds_list);
|
||||
|
||||
void led_add( struct led_drv *drv)
|
||||
{
|
||||
struct drv_led_list *drv_node = malloc(sizeof(struct drv_led_list));
|
||||
|
||||
DBG(1,"called with led name [%s]", drv->name);
|
||||
drv_node->drv = drv;
|
||||
|
||||
list_add(&drv_node->list, &drv_leds_list);
|
||||
}
|
||||
|
||||
static void all_leds(led_state_t state) {
|
||||
struct drv_led_list *node;
|
||||
DBG(1, "set to state %d",state);
|
||||
|
||||
list_for_each_entry(node, &drv_leds_list, list) {
|
||||
node->drv->func->set_state( node->drv, state);
|
||||
}
|
||||
}
|
||||
|
||||
static void all_leds_off(void) {
|
||||
all_leds(OFF);
|
||||
}
|
||||
|
||||
static void all_leds_on(void) {
|
||||
all_leds(ON);
|
||||
}
|
||||
|
||||
#define TEST_TIMEOUT 250
|
||||
static void test_handler(struct uloop_timeout *timeout);
|
||||
static struct uloop_timeout test_inform_timer = { .cb = test_handler };
|
||||
|
||||
static void test_handler(struct uloop_timeout *timeout) {
|
||||
|
||||
static int cnt = 0;
|
||||
static led_state_t state = OFF;
|
||||
|
||||
static struct drv_led_list *led;
|
||||
DBG(1,"cnt = %d state %d",cnt,state);
|
||||
|
||||
/* flash all leads 2 times.*/
|
||||
if ( cnt < 4) {
|
||||
cnt++;
|
||||
if (state == OFF){
|
||||
all_leds_on();
|
||||
state = ON;
|
||||
}else{
|
||||
all_leds_off();
|
||||
state = OFF;
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (global_state == LEDS_RESET){
|
||||
cnt = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* cycle through every led once */
|
||||
if (cnt == 4 ) {
|
||||
cnt++;
|
||||
led = list_first_entry(&drv_leds_list, struct drv_led_list, list );
|
||||
}
|
||||
if (cnt == 5 ) {
|
||||
if (state == OFF){
|
||||
led->drv->func->set_state(led->drv, ON);
|
||||
state = ON;
|
||||
}else{
|
||||
led->drv->func->set_state(led->drv, OFF);
|
||||
/* was this the last led ? if so stop */
|
||||
if ( list_is_last(&led->list, &drv_leds_list) ){
|
||||
cnt = 0;
|
||||
state = OFF;
|
||||
goto done;
|
||||
}else{ /* nope more leds in list. get next and turn it on */
|
||||
led = (struct drv_led_list *)led->list.next;
|
||||
led->drv->func->set_state(led->drv, ON);
|
||||
state = ON;
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
|
||||
if (global_state == LEDS_TEST || global_state == LEDS_RESET)
|
||||
uloop_timeout_set(&test_inform_timer, TEST_TIMEOUT);
|
||||
else{
|
||||
cnt = 0;
|
||||
state = OFF;
|
||||
}
|
||||
}
|
||||
|
||||
/* go over the driver list for any led name that matches name and returna pointer to driver. */
|
||||
struct led_drv *get_drv_led(char *name)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &drv_leds_list) {
|
||||
struct drv_led_list *node = list_entry(i, struct drv_led_list, list);
|
||||
if (!strcmp(node->drv->name, name))
|
||||
return node->drv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void dump_drv_list(void)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &drv_leds_list) {
|
||||
struct drv_led_list *node = list_entry(i, struct drv_led_list, list);
|
||||
DBG(1,"led name = [%s]",node->drv->name);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_led(void)
|
||||
{
|
||||
int i,j;
|
||||
for (i = 0; i < total_functions ; i++) {
|
||||
for (j = 0 ; j < LED_ACTION_MAX; j++ ) {
|
||||
if ( leds[i].actions[j].name != NULL ) {
|
||||
struct led *led;
|
||||
struct super_list *sl;
|
||||
|
||||
/* print out action list */
|
||||
list_for_each_entry(led, &leds[i].actions[j].led_list, list) {
|
||||
DBG(1,"%-15s %-8s %-15s %-10s",
|
||||
leds[i].name,
|
||||
leds[i].actions[j].name,
|
||||
led->drv->name,
|
||||
led_states[led->state]);
|
||||
}
|
||||
/* print out super function list */
|
||||
list_for_each_entry(sl, &leds[i].actions[j].super_list, list) {
|
||||
struct super_functions *sf;
|
||||
DBG(1," AND list");
|
||||
list_for_each_entry(sf, &sl->sf_list, list) {
|
||||
DBG(1,"\tfunction [%s] action [%s]",sf->function->name, fn_actions[sf->state]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* loop over every function, if it is a super function update the state */
|
||||
static void super_update(void)
|
||||
{
|
||||
int i,j;
|
||||
for (i = 0; i < total_functions ; i++) {
|
||||
for (j = 0 ; j < LED_ACTION_MAX; j++ ) {
|
||||
if ( leds[i].actions[j].name != NULL ) {
|
||||
struct super_list *sl;
|
||||
list_for_each_entry(sl, &leds[i].actions[j].super_list, list) {
|
||||
struct super_functions *sf;
|
||||
int status = 0;
|
||||
// DBG(1," AND list");
|
||||
list_for_each_entry(sf, &sl->sf_list, list) {
|
||||
// DBG(1,"\tfunction [%s] action [%s]",sf->function->name, fn_actions[sf->state]);
|
||||
if (sf->function->state == sf->state ) {
|
||||
status = 1;
|
||||
} else {
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (status){
|
||||
leds[i].state = j;
|
||||
DBG(1,"\tSet super function [%s] to action [%s]",leds[i].name, fn_actions[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* return 0 = OK, -1 = error */
|
||||
static int set_function_led(const char* fn_name, const char* action) {
|
||||
int led_idx = get_index_for_function(fn_name);
|
||||
int act_idx = get_index_by_name(fn_actions , LED_ACTION_MAX, action );
|
||||
struct led *led;
|
||||
|
||||
if(led_idx == -1) {
|
||||
syslog(LOG_WARNING, "called over ubus with non valid led name [%s]", fn_name);
|
||||
return -1;
|
||||
}
|
||||
if(act_idx == -1) {
|
||||
syslog(LOG_WARNING, "called over ubus with non valid action [%s] for led [%s]", action, fn_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
leds[led_idx].state = act_idx;
|
||||
|
||||
list_for_each_entry(led, &leds[led_idx].actions[act_idx].led_list, list) {
|
||||
if (led->drv){
|
||||
led->drv->func->set_state(led->drv, led->state);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int brightness_function_led(const char* fn_name, int brightness) {
|
||||
int led_idx = get_index_for_function(fn_name);
|
||||
struct led *led;
|
||||
|
||||
if(led_idx == -1) {
|
||||
syslog(LOG_WARNING, "called over ubus with non valid led name [%s]", fn_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
leds[led_idx].brightness = brightness;
|
||||
|
||||
list_for_each_entry(led, &leds[led_idx].actions[ leds[led_idx].state ].led_list, list) {
|
||||
if (led->drv){
|
||||
if (led->drv->func->set_brightness){
|
||||
led->drv->func->set_brightness(led->drv, brightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum {
|
||||
LED_STATE,
|
||||
LED_BRIGHTNESS,
|
||||
__LED_MAX
|
||||
};
|
||||
|
||||
static const struct blobmsg_policy led_policy[] = {
|
||||
[LED_STATE] = { .name = "state", .type = BLOBMSG_TYPE_STRING },
|
||||
[LED_BRIGHTNESS] = { .name = "brightness", .type = BLOBMSG_TYPE_INT32 },
|
||||
};
|
||||
|
||||
static int led_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__LED_MAX];
|
||||
char* state;
|
||||
int *number;
|
||||
char *fn_name = strchr(obj->name, '.') + 1;
|
||||
|
||||
blobmsg_parse(led_policy, ARRAY_SIZE(led_policy), tb, blob_data(msg), blob_len(msg));
|
||||
if (tb[LED_STATE]) {
|
||||
state = blobmsg_data(tb[LED_STATE]);
|
||||
DBG(1,"set led [%s]->[%s]", fn_name, state);
|
||||
if (set_function_led(fn_name, state) ){
|
||||
return UBUS_STATUS_NO_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (tb[LED_BRIGHTNESS]) {
|
||||
number = blobmsg_data(tb[LED_BRIGHTNESS]);
|
||||
DBG(1,"set brightness [%s]->[%d]", fn_name, *number);
|
||||
if (brightness_function_led(fn_name, *number) ){
|
||||
return UBUS_STATUS_NO_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int led_status_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
char *fn_name = strchr(obj->name, '.') + 1;
|
||||
int led_idx = get_index_for_function(fn_name);
|
||||
DBG(1,"for led %s",leds[led_idx].name);
|
||||
|
||||
blob_buf_init (&bblob, 0);
|
||||
blobmsg_add_string(&bblob, "state",fn_actions[leds[led_idx].state]);
|
||||
blobmsg_add_u32(&bblob, "brightness",leds[led_idx].brightness);
|
||||
ubus_send_reply(ubus_ctx, req, bblob.head);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int leds_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__LED_MAX];
|
||||
|
||||
blobmsg_parse(led_policy, ARRAY_SIZE(led_policy), tb, blob_data(msg), blob_len(msg));
|
||||
|
||||
if (tb[LED_STATE]) {
|
||||
char* state;
|
||||
int state_idx;
|
||||
|
||||
state = blobmsg_data(tb[LED_STATE]);
|
||||
state_idx = get_index_by_name(leds_states, LEDS_MAX , state);
|
||||
|
||||
if (state_idx == -1) {
|
||||
syslog(LOG_WARNING, "leds_set_method: Unknown state %s.", state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
global_state = state_idx;
|
||||
|
||||
if (global_state == LEDS_INFO) {
|
||||
all_leds_off();
|
||||
}
|
||||
|
||||
if (global_state == LEDS_PROD) {
|
||||
all_leds_off();
|
||||
}
|
||||
|
||||
if (global_state == LEDS_TEST || global_state == LEDS_RESET) {
|
||||
all_leds_off();
|
||||
uloop_timeout_set(&test_inform_timer, TEST_TIMEOUT);
|
||||
}
|
||||
if (global_state == LEDS_ALLON) {
|
||||
all_leds_on();
|
||||
}
|
||||
if (global_state == LEDS_ALLOFF) {
|
||||
all_leds_off();
|
||||
}
|
||||
|
||||
DBG(1,"led global state set to [%s] wanted [%s]", leds_states[global_state], state);
|
||||
}else
|
||||
syslog(LOG_WARNING, "Unknown attribute [%s]", (char *)blob_data(msg));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int leds_status_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
|
||||
blob_buf_init (&bblob, 0);
|
||||
blobmsg_add_string(&bblob, "state", leds_states[global_state]);
|
||||
DBG(1,"leds global state is [%s]",leds_states[global_state]);
|
||||
ubus_send_reply(ubus_ctx, req, bblob.head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct ubus_method led_methods[] = {
|
||||
UBUS_METHOD("set", led_set_method, led_policy),
|
||||
{ .name = "status", .handler = led_status_method },
|
||||
};
|
||||
|
||||
static struct ubus_object_type led_object_type =
|
||||
UBUS_OBJECT_TYPE("led", led_methods);
|
||||
|
||||
static const struct ubus_method leds_methods[] = {
|
||||
UBUS_METHOD("set", leds_set_method, led_policy),
|
||||
{ .name = "status", .handler = leds_status_method },
|
||||
// { .name = "proximity", .handler = leds_proximity_method },
|
||||
};
|
||||
|
||||
static struct ubus_object_type leds_object_type =
|
||||
UBUS_OBJECT_TYPE("leds", leds_methods);
|
||||
|
||||
#define LED_OBJECTS 1
|
||||
static struct ubus_object led_objects[LED_OBJECTS] = {
|
||||
{ .name = "leds", .type = &leds_object_type, .methods = leds_methods, .n_methods = ARRAY_SIZE(leds_methods), },
|
||||
};
|
||||
|
||||
|
||||
#define FLASH_TIMEOUT 250
|
||||
static void flash_handler(struct uloop_timeout *timeout);
|
||||
static struct uloop_timeout flash_inform_timer = { .cb = flash_handler };
|
||||
|
||||
static void flash_handler(struct uloop_timeout *timeout)
|
||||
{
|
||||
static int counter = 1; /* bit 0 is fast flash bit 2 is slow flash */
|
||||
int i;
|
||||
led_state_t slow=OFF,fast=OFF;
|
||||
counter++;
|
||||
|
||||
/* count down dimming to zero */
|
||||
if (dimming_count)
|
||||
dimming_count--;
|
||||
|
||||
if (counter & 1 )
|
||||
fast = ON;
|
||||
if (counter & 4 )
|
||||
slow = ON;
|
||||
|
||||
super_update();
|
||||
|
||||
if (global_state == LEDS_NORMAL ||
|
||||
global_state == LEDS_INFO ) {
|
||||
for (i = 0; i < total_functions ; i++) {
|
||||
struct led *led;
|
||||
if (leds[i].press_indicator & press_state) {
|
||||
// DBG(1,"INDICATE_PRESS on %s",leds[i].name);
|
||||
list_for_each_entry(led, &leds[i].actions[leds[i].state].led_list, list) {
|
||||
if (led->drv)
|
||||
led->drv->func->set_state(led->drv, fast);
|
||||
}
|
||||
|
||||
/* normal operation, flash else reset state */
|
||||
} else {
|
||||
led_action_t action_state = leds[i].state;
|
||||
|
||||
/* in case of info mode suppress OK state. that is if OK -> turn it into OFF */
|
||||
if (global_state == LEDS_INFO) {
|
||||
if (action_state == LED_OK)
|
||||
action_state = LED_OFF;
|
||||
}
|
||||
|
||||
/* is this function dimmed ? */
|
||||
if (leds[i].dimming) {
|
||||
/* if timer is not active we should dimm */
|
||||
if (!dimming_count){
|
||||
if (action_state < dimming_level)
|
||||
action_state = LED_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
list_for_each_entry(led, &leds[i].actions[action_state].led_list, list) {
|
||||
|
||||
if (led->state == FLASH_FAST) {
|
||||
if (led->drv) {
|
||||
if (led->drv->func->support) {
|
||||
if (led->drv->func->support(led->drv, FLASH_FAST)) {
|
||||
/* hardware support flash */
|
||||
led->drv->func->set_state(led->drv, FLASH_FAST);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* emulate flash with on/off */
|
||||
led->drv->func->set_state(led->drv, fast);
|
||||
}
|
||||
}else if (led->state == FLASH_SLOW) {
|
||||
if (led->drv) {
|
||||
if (led->drv->func->support) {
|
||||
if (led->drv->func->support(led->drv, FLASH_SLOW)) {
|
||||
/* hardware support flash */
|
||||
led->drv->func->set_state(led->drv, FLASH_SLOW);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* emulate flash with on/off */
|
||||
led->drv->func->set_state(led->drv, slow);
|
||||
}
|
||||
}else{
|
||||
if (led->drv)
|
||||
led->drv->func->set_state(led->drv, led->state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
uloop_timeout_set(&flash_inform_timer, FLASH_TIMEOUT);
|
||||
}
|
||||
|
||||
void led_pressindicator_set(void){
|
||||
press_state = 1;
|
||||
}
|
||||
|
||||
void led_pressindicator_clear(void){
|
||||
press_state = 0;
|
||||
}
|
||||
|
||||
void led_dimming(void){
|
||||
|
||||
/* we resuse the flash timer and decrement dimmming_count on every loop */
|
||||
/* set the intial value so that we get the correct timeout */
|
||||
dimming_count = dimming_timeout * (1000/FLASH_TIMEOUT);
|
||||
}
|
||||
|
||||
/*
|
||||
input: s, string of comma separated function_action names, 'wifi_ok, wps_ok'
|
||||
|
||||
return:
|
||||
NULL if no valid function actionpair found.
|
||||
pointer to start of unused part of string.
|
||||
|
||||
fills in the function pointer with NULL or a real function
|
||||
fills in action with 0 or real index (include 0),
|
||||
|
||||
*/
|
||||
const char * get_function_action( const char *s, struct function_led **function, int *action)
|
||||
{
|
||||
const char *first, *last, *end, *p;
|
||||
char func[100], act[20];
|
||||
|
||||
DBG(1,"start [%s]", s);
|
||||
|
||||
*function = NULL;
|
||||
*action = 0;
|
||||
|
||||
/* if string is zero length give up. */
|
||||
if ( 0 == strlen(s))
|
||||
return NULL;
|
||||
|
||||
end = s + strlen(s);
|
||||
|
||||
/* find first alpha char */
|
||||
while (!isalnum(*s)){
|
||||
s++;
|
||||
if (s == end)
|
||||
return NULL;
|
||||
}
|
||||
first = s;
|
||||
|
||||
/* find , or end of string or space/tab */
|
||||
while ( (*s != ',') && (!isblank(*s))) {
|
||||
s++;
|
||||
if (s == end)
|
||||
break;
|
||||
}
|
||||
last = s;
|
||||
|
||||
/* scan backwards for _ */
|
||||
while (*s != '_' && s > first){
|
||||
s--;
|
||||
}
|
||||
|
||||
/* if we could not find a _ char bail out */
|
||||
if (*s != '_')
|
||||
return NULL;
|
||||
|
||||
/* extract function name */
|
||||
p = first;
|
||||
while (p != s) {
|
||||
func[p-first] = *p;
|
||||
p++;
|
||||
}
|
||||
func[p-first] = 0;
|
||||
|
||||
/* extract action name */
|
||||
p = s + 1;
|
||||
while (p != last) {
|
||||
act[p-(s+1)] = *p;
|
||||
p++;
|
||||
}
|
||||
act[p-(s+1)] = 0;
|
||||
|
||||
DBG(1,"function[%s] action[%s] func_idx %d", func, act, get_index_for_function(func));
|
||||
*function = &leds[get_index_for_function(func)];
|
||||
*action = get_index_by_name(fn_actions , LED_ACTION_MAX, act );
|
||||
|
||||
if (*last == ',')
|
||||
last++;
|
||||
|
||||
return last;
|
||||
}
|
||||
|
||||
/* when this is called all driver leds needs to exist */
|
||||
void led_init( struct server_ctx *s_ctx)
|
||||
{
|
||||
int i,j;
|
||||
LIST_HEAD(led_map_list);
|
||||
struct ucilist *map_node;
|
||||
const char *s;
|
||||
|
||||
dump_drv_list();
|
||||
|
||||
/* register leds with ubus */
|
||||
for (i=0 ; i<LED_OBJECTS ; i++) {
|
||||
int ret = ubus_add_object(s_ctx->ubus_ctx, &led_objects[i]);
|
||||
if (ret)
|
||||
DBG(1,"Failed to add object: %s", ubus_strerror(ret));
|
||||
}
|
||||
|
||||
/* read out the function leds */
|
||||
ucix_get_option_list( s_ctx->uci_ctx, "hw", "led_map", "functions" , &led_map_list);
|
||||
|
||||
total_functions = 0;
|
||||
list_for_each_entry(map_node, &led_map_list, list) {
|
||||
total_functions++;
|
||||
}
|
||||
|
||||
leds = malloc(sizeof(struct function_led) * total_functions);
|
||||
memset(leds, 0, sizeof(struct function_led) * total_functions);
|
||||
|
||||
/* set function name & regiter with ubus */
|
||||
i = 0;
|
||||
list_for_each_entry(map_node, &led_map_list, list) {
|
||||
char name[100];
|
||||
int ret;
|
||||
struct ubus_object *ubo;
|
||||
ubo = malloc(sizeof(struct ubus_object));
|
||||
memset(ubo, 0, sizeof(struct ubus_object));
|
||||
|
||||
leds[i].name = strdup(map_node->val);
|
||||
|
||||
sprintf(name, "led.%s", leds[i].name);
|
||||
ubo->name = strdup(name);
|
||||
ubo->methods = led_methods;
|
||||
ubo->n_methods = ARRAY_SIZE(led_methods);
|
||||
ubo->type = &led_object_type;
|
||||
|
||||
ret = ubus_add_object(s_ctx->ubus_ctx, ubo);
|
||||
if (ret)
|
||||
DBG(1,"Failed to add object: %s", ubus_strerror(ret));
|
||||
i++;
|
||||
}
|
||||
|
||||
/* we create a top list of led functions */
|
||||
/* that list contains a new list of actions */
|
||||
/* every action contains led actions lists */
|
||||
/* the led states is attached to the drv_leds lists */
|
||||
|
||||
for (i = 0; i < total_functions ; i++) {
|
||||
for (j = 0 ; j < LED_ACTION_MAX; j++ ) {
|
||||
char led_fn_name[256];
|
||||
char led_action[256];
|
||||
|
||||
LIST_HEAD(led_action_list);
|
||||
struct ucilist *node;
|
||||
snprintf(led_fn_name, 256, "led_%s", leds[i].name);
|
||||
snprintf(led_action, 256, "led_action_%s", fn_actions[j]);
|
||||
ucix_get_option_list( s_ctx->uci_ctx, "hw", led_fn_name, led_action , &led_action_list);
|
||||
|
||||
INIT_LIST_HEAD( &leds[i].actions[j].led_list );
|
||||
|
||||
if (!list_empty(&led_action_list)) {
|
||||
|
||||
/* Found led with action, init structs */
|
||||
leds[i].state = LED_OFF;
|
||||
leds[i].brightness = 100;
|
||||
|
||||
leds[i].actions[j].name = fn_actions[j];
|
||||
|
||||
/* fill in led actions */
|
||||
DBG(2,"%-15s has led actions %s -> ", led_fn_name, fn_actions[j]);
|
||||
list_for_each_entry(node, &led_action_list, list) {
|
||||
char led_name[256],led_state[256];
|
||||
struct led *led;
|
||||
struct led_drv *drv;
|
||||
char *c;
|
||||
s = strdup(node->val);
|
||||
led_name[0]=0;
|
||||
led_state[0]=0;
|
||||
|
||||
/* get pointer to low level led driver. by removing the = sign and
|
||||
storing the remaining two strings.
|
||||
*/
|
||||
c = strchr(s,'=');
|
||||
if( c == NULL)
|
||||
continue; /* no = found, abort */
|
||||
*c = ' ';
|
||||
|
||||
sscanf(s, "%s %s", led_name, led_state);
|
||||
drv = get_drv_led(led_name);
|
||||
|
||||
if (drv) {
|
||||
led = malloc(sizeof(struct led));
|
||||
led->drv = drv;
|
||||
led->state = get_index_by_name(led_states, LED_STATES_MAX, led_state);
|
||||
list_add(&led->list, &leds[i].actions[j].led_list);
|
||||
}else {
|
||||
syslog(LOG_ERR,"Config specified use of led name [%s]. But it's not registerd with a led driver.", led_name);
|
||||
}
|
||||
DBG(2, "%-35s%s","",node->val);
|
||||
free((void*)s);
|
||||
}
|
||||
|
||||
/* fill in button actions */
|
||||
|
||||
/* fill in xxx actions */
|
||||
}else {
|
||||
DBG(2,"%-15s has no actions -> %s", led_fn_name, fn_actions[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read in functions that have function list (super functions) */
|
||||
for (i = 0; i < total_functions ; i++) {
|
||||
for (j = 0 ; j < LED_ACTION_MAX; j++ ) {
|
||||
char led_fn_name[256];
|
||||
char super_action[256];
|
||||
LIST_HEAD(super_action_list);
|
||||
struct ucilist *node;
|
||||
snprintf(led_fn_name, 256, "led_%s", leds[i].name);
|
||||
snprintf(super_action, 256, "super_%s", fn_actions[j]);
|
||||
ucix_get_option_list( s_ctx->uci_ctx, "hw", led_fn_name, super_action , &super_action_list);
|
||||
INIT_LIST_HEAD( &leds[i].actions[j].super_list );
|
||||
|
||||
if (!list_empty(&super_action_list)) {
|
||||
DBG(1,"A:%s %s is a super function ",led_fn_name,super_action);
|
||||
|
||||
list_for_each_entry(node, &super_action_list, list) {
|
||||
struct function_led *function;
|
||||
int action_ix;
|
||||
struct super_list *sl = malloc(sizeof(struct super_list));
|
||||
memset(sl, 0, sizeof(struct super_list));
|
||||
list_add(&sl->list, &leds[i].actions[j].super_list);
|
||||
INIT_LIST_HEAD( &sl->sf_list );
|
||||
|
||||
DBG(1,"add to super list %s",node->val);
|
||||
|
||||
s = node->val;
|
||||
while ((s = get_function_action(s, &function, &action_ix))){
|
||||
if (function) {
|
||||
struct super_functions *sf = malloc(sizeof(struct super_functions));
|
||||
memset(sf, 0, sizeof(struct super_functions));
|
||||
sf->state = action_ix;
|
||||
sf->function = function;
|
||||
list_add(&sf->list, &sl->sf_list);
|
||||
DBG(1,"C %s %s",function->name, fn_actions[action_ix]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
DBG(1,"A:%s %s is a normal function ",led_fn_name,super_action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* setup and read dimming options for led */
|
||||
{
|
||||
struct ucilist *node;
|
||||
LIST_HEAD(dimm_list);
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , "led_map", "dimming_level");
|
||||
dimming_level = LED_OFF;
|
||||
if (s) {
|
||||
DBG(1,"Dimming init");
|
||||
for(i=0 ; i < LED_ACTION_MAX ; i++) {
|
||||
if (! strncasecmp(s, fn_actions[i], sizeof(fn_actions[i]))){
|
||||
dimming_level = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , "led_map", "dimming_on");
|
||||
dimming_timeout = 0;
|
||||
if (s) {
|
||||
dimming_timeout = strtol(s, NULL, 0);
|
||||
}
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"led_map", "dimming", &dimm_list);
|
||||
list_for_each_entry(node, &dimm_list, list) {
|
||||
int ix;
|
||||
s = node->val;
|
||||
ix = get_index_for_function(s);
|
||||
if (ix != -1){
|
||||
leds[ix].dimming = 1;
|
||||
DBG(1,"dimming on led [%s]", leds[ix].name);
|
||||
}else
|
||||
syslog(LOG_ERR,"dimming Led [%s] don't exist", s);
|
||||
}
|
||||
}
|
||||
|
||||
DBG(1,"Dimming level %s", fn_actions[dimming_level]);
|
||||
DBG(1,"Dimming timeout %d", dimming_timeout);
|
||||
|
||||
{
|
||||
struct ucilist *node;
|
||||
/* read function buttons from section button_map */
|
||||
LIST_HEAD(press_indicator);
|
||||
|
||||
/* read in generic configuration. press indicator listdefault params..... */
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"led_map", "press_indicator", &press_indicator);
|
||||
list_for_each_entry(node, &press_indicator, list) {
|
||||
int ix;
|
||||
s = node->val;
|
||||
s +=4; /*remove 'led_' from string */
|
||||
DBG(1,"press indicator %s [%s]",node->val, s);
|
||||
ix = get_index_for_function(s);
|
||||
// DBG(1,"press indicator %s [%s]->%d",node->val, s, ix);
|
||||
leds[ix].press_indicator = 1;
|
||||
}
|
||||
}
|
||||
uloop_timeout_set(&flash_inform_timer, FLASH_TIMEOUT);
|
||||
|
||||
dump_led();
|
||||
all_leds_off();
|
||||
}
|
||||
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
#include "server.h"
|
||||
|
||||
typedef enum {
|
||||
OFF,
|
||||
ON,
|
||||
FLASH_SLOW,
|
||||
FLASH_FAST,
|
||||
PULSING,
|
||||
FADEON,
|
||||
FADEOFF,
|
||||
NEED_INIT, /* set on loading config */
|
||||
LED_STATES_MAX,
|
||||
} led_state_t;
|
||||
|
||||
typedef enum {
|
||||
NONE,
|
||||
RED,
|
||||
GREEN,
|
||||
BLUE,
|
||||
YELLOW,
|
||||
WHITE,
|
||||
} led_color_t;
|
||||
|
||||
struct led_drv;
|
||||
|
||||
struct led_drv_func{
|
||||
int (*set_state)(struct led_drv *, led_state_t); /* Set led state, on,off,flash ... */
|
||||
led_state_t (*get_state)(struct led_drv *); /* Get led state, on,off,flash ... */
|
||||
int (*set_color)(struct led_drv *, led_color_t); /* Set led color */
|
||||
led_color_t (*get_color)(struct led_drv *); /* Get led color */
|
||||
int (*set_brightness)(struct led_drv *, int ); /* Set led brightness */
|
||||
int (*get_brightness)(struct led_drv *); /* Get led brightness */
|
||||
int (*support) (struct led_drv *, led_state_t); /* do driver has hardware support for state */
|
||||
};
|
||||
|
||||
struct led_drv {
|
||||
const char *name; /* name, set in the confg file,has to be uniq */
|
||||
void *priv; /* for use by the driver */
|
||||
struct led_drv_func *func; /* function pointers for controlling the led */
|
||||
};
|
||||
|
||||
void led_add( struct led_drv *);
|
||||
void led_init(struct server_ctx *);
|
||||
|
||||
void led_dimming(void);
|
||||
void led_pressindicator_set(void);
|
||||
void led_pressindicator_clear(void);
|
||||
|
||||
#endif /* LED_H */
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
/* Use this */
|
||||
#include <syslog.h>
|
||||
|
||||
extern int debug_level;
|
||||
|
||||
#define DBG_RAW(...) fprintf( stderr, __VA_ARGS__ );
|
||||
#define DBG(level,fmt, args...) \
|
||||
do { \
|
||||
if (level <= debug_level) \
|
||||
syslog( LOG_DEBUG,"%-20s: " fmt , __func__, ##args); \
|
||||
} while(0)
|
||||
|
||||
#endif /* LOG_H */
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <libgen.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <syslog.h>
|
||||
#include <config.h>
|
||||
#include <getopt.h>
|
||||
#include "log.h"
|
||||
#include "ucix.h"
|
||||
|
||||
#include <libubox/uloop.h>
|
||||
#include <libubus.h>
|
||||
|
||||
#include "server.h"
|
||||
|
||||
int debug_level = 0;
|
||||
|
||||
static const char *config_path = "/lib/db/config";
|
||||
static const char *config_file = "hw";
|
||||
|
||||
static char *ubus_socket;
|
||||
|
||||
void catv_monitor_set_socket(char *);
|
||||
|
||||
void print_usage(char *prg_name);
|
||||
|
||||
void print_usage(char *prg_name) {
|
||||
printf("Usage: %s -h -f\n", prg_name);
|
||||
printf(" Options: \n");
|
||||
printf(" -f, --foreground\tDon't fork off as a daemon.\n");
|
||||
printf(" -d, --debug=NUM\tSet debug level. Higher = more output\n");
|
||||
printf(" -c, --config=FILE\tConfig file to use. default = %s/%s\n", config_path, config_file);
|
||||
printf(" -s, --socket=FILE\tSet the unix domain socket to connect to for ubus\n");
|
||||
printf(" -h\t\tShow this help screen.\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ch;
|
||||
int daemonize = 1;
|
||||
pid_t pid, sid;
|
||||
struct uci_context *uci_ctx = NULL;
|
||||
static struct ubus_context *ubus_ctx = NULL;
|
||||
|
||||
while (1) {
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"foreground", no_argument, 0, 'f'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{"debug", required_argument, 0, 'd'},
|
||||
{"config",required_argument, 0, 'c'},
|
||||
{"socket",required_argument, 0, 's'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
ch = getopt_long(argc, argv, "hvfhd:c:s:",
|
||||
long_options, &option_index);
|
||||
|
||||
if (ch == -1)
|
||||
break;
|
||||
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
daemonize = 0;
|
||||
break;
|
||||
case 'd':
|
||||
debug_level = strtol(optarg, 0, 0);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
config_file = basename(optarg);
|
||||
config_path = dirname(optarg);
|
||||
break;
|
||||
case 's':
|
||||
ubus_socket = optarg;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
print_usage(argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
printf("Extra arguments discarded: ");
|
||||
while (optind < argc)
|
||||
printf("%s ", argv[optind++]);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/* Setup logging */
|
||||
if (daemonize) {
|
||||
setlogmask(LOG_UPTO(LOG_INFO));
|
||||
openlog(PACKAGE, LOG_CONS, LOG_USER);
|
||||
|
||||
syslog(LOG_INFO, "%s daemon starting up", PACKAGE);
|
||||
} else {
|
||||
setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
openlog(PACKAGE, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID, LOG_USER);
|
||||
|
||||
syslog(LOG_INFO, "%s program starting up", PACKAGE);
|
||||
}
|
||||
|
||||
/* daemonize */
|
||||
if (daemonize) {
|
||||
syslog(LOG_INFO, "starting the daemonizing process");
|
||||
|
||||
/* Fork off the parent process */
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* If we got a good PID, then
|
||||
we can exit the parent process. */
|
||||
if (pid > 0) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Change the file mode mask */
|
||||
umask(0);
|
||||
|
||||
/* Create a new SID for the child process */
|
||||
sid = setsid();
|
||||
if (sid < 0) {
|
||||
/* Log the failure */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Change the current working directory */
|
||||
if ((chdir("/")) < 0) {
|
||||
/* Log the failure */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* Close out the standard file descriptors */
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
}
|
||||
|
||||
/* open configuration file */
|
||||
uci_ctx = ucix_init_path(config_path , config_file, 0 );
|
||||
if (! uci_ctx ) {
|
||||
syslog(LOG_ERR,"Failed to load config file \"%s/%s\"\n", config_path, config_file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* connect to ubus */
|
||||
ubus_ctx = ubus_connect(ubus_socket);
|
||||
if (!ubus_ctx) {
|
||||
syslog(LOG_ERR,"Failed to connect to ubus. Can't continue.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* connect ubus handler to ubox evenet loop */
|
||||
if (uloop_init() != 0) {
|
||||
syslog(LOG_ERR,"Could not init event loop, Can't continue.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
ubus_add_uloop(ubus_ctx);
|
||||
|
||||
catv_monitor_set_socket(ubus_socket);
|
||||
|
||||
server_start(uci_ctx, ubus_ctx);
|
||||
|
||||
ubus_free(ubus_ctx);
|
||||
|
||||
DBG(1,"testing\n");
|
||||
syslog(LOG_INFO, "%s exiting", PACKAGE);
|
||||
|
||||
uloop_done();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,196 +0,0 @@
|
|||
#include <syslog.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <board.h>
|
||||
#include "button.h"
|
||||
|
||||
#include "smbus.h"
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include "ucix.h"
|
||||
#include "i2c.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "gpio.h"
|
||||
#include "prox_px3220.h"
|
||||
|
||||
/* register names, from page 29, */
|
||||
#define PX3220_SYSCONF 0x00
|
||||
#define PX3220_IRQ_STATUS 0x01
|
||||
#define PX3220_IRQ_CLEAR 0x02
|
||||
#define PX3220_IR_DATA_LOW 0x0A
|
||||
#define PX3220_IR_DATA_HIGH 0x0B
|
||||
#define PX3220_PS_DATA_LOW 0x0E
|
||||
#define PX3220_PS_DATA_HIGH 0x0F
|
||||
#define PX3220_PS_LOW_THRESH_L 0x2A
|
||||
#define PX3220_PS_LOW_THRESH_H 0x2B
|
||||
#define PX3220_PS_HIGH_THRESH_L 0x2C
|
||||
#define PX3220_PS_HIGH_THRESH_H 0x2D
|
||||
|
||||
#define IRQ_BUTTON 33
|
||||
|
||||
struct i2c_reg_tab {
|
||||
char addr;
|
||||
char value;
|
||||
char range; /* if set registers starting from addr to addr+range will be set to the same value */
|
||||
};
|
||||
|
||||
struct button_data {
|
||||
int addr;
|
||||
int state;
|
||||
struct button_drv button;
|
||||
};
|
||||
|
||||
static const struct i2c_reg_tab i2c_init_tab_vox25[]={
|
||||
{PX3220_SYSCONF, 0x04, 0x00 }, /* Reset */
|
||||
{PX3220_SYSCONF, 0x02, 0x00 }, /* Power on IR */
|
||||
{PX3220_IRQ_STATUS, 0x01, 0x00 },
|
||||
{0x20, 0x17, 0x00 },
|
||||
{0x23, 0x03, 0x00 },
|
||||
{PX3220_PS_LOW_THRESH_L, 0x00, 0x00 },
|
||||
{PX3220_PS_LOW_THRESH_H, 0x18, 0x00 },
|
||||
{PX3220_PS_HIGH_THRESH_L, 0x00, 0x00 },
|
||||
{PX3220_PS_HIGH_THRESH_H, 0x14, 0x00 },
|
||||
};
|
||||
|
||||
int dev;
|
||||
int shadow_proximity;
|
||||
|
||||
void do_init_tab(const struct i2c_reg_tab *tab, int len );
|
||||
|
||||
|
||||
void do_init_tab(const struct i2c_reg_tab *tab, int len )
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < len ; i++){
|
||||
int y;
|
||||
int ret;
|
||||
for ( y = 0 ; y <= tab[i].range; y++ ){
|
||||
DBG(3,"%s: addr %02X = %02X ",__func__,(unsigned char)tab[i].addr+y, (unsigned char)tab[i].value);
|
||||
ret = i2c_smbus_write_byte_data(dev, tab[i].addr+y, tab[i].value);
|
||||
if (ret < 0){
|
||||
perror("write to i2c dev\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void px3220_check(void)
|
||||
{
|
||||
int got_irq;
|
||||
unsigned short reg_low, reg_high, ps_val;
|
||||
|
||||
shadow_proximity = 0;
|
||||
if (dev){
|
||||
got_irq = board_ioctl( BOARD_IOCTL_GET_GPIO, 0, 0, NULL, IRQ_BUTTON, 0);
|
||||
|
||||
/* got_irq is active low */
|
||||
if (!got_irq) {
|
||||
reg_low = i2c_smbus_read_byte_data(dev, PX3220_PS_DATA_LOW);
|
||||
|
||||
reg_high = i2c_smbus_read_byte_data(dev, PX3220_PS_DATA_HIGH);
|
||||
|
||||
ps_val = ((reg_high & 0x3F) << 4) | (reg_low & 0xF);
|
||||
|
||||
if (ps_val > 0x58)
|
||||
shadow_proximity |= 0x1;
|
||||
else
|
||||
shadow_proximity |= 0x2;
|
||||
}
|
||||
}
|
||||
|
||||
if (shadow_proximity)
|
||||
DBG(1,"shadow_proximity [%x]", shadow_proximity);
|
||||
}
|
||||
|
||||
static button_state_t px3220_button_get_state(struct button_drv *drv)
|
||||
{
|
||||
struct button_data *p = (struct button_data *)drv->priv;
|
||||
|
||||
if (p->addr == 0 ){
|
||||
if (shadow_proximity & 1 ) {
|
||||
shadow_proximity &= ~0x1;
|
||||
return p->state = BUTTON_PRESSED;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->addr == 1 ){
|
||||
if (shadow_proximity & 2 ) {
|
||||
shadow_proximity &= ~0x2;
|
||||
return p->state = BUTTON_PRESSED;
|
||||
}
|
||||
}
|
||||
|
||||
p->state = BUTTON_RELEASED;
|
||||
return p->state;
|
||||
}
|
||||
|
||||
static struct button_drv_func button_func = {
|
||||
.get_state = px3220_button_get_state,
|
||||
};
|
||||
|
||||
void px3220_init(struct server_ctx *s_ctx) {
|
||||
|
||||
const char *p;
|
||||
|
||||
struct ucilist *node;
|
||||
LIST_HEAD(buttons);
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
p = ucix_get_option(s_ctx->uci_ctx, "hw", "board", "hardware");
|
||||
if (p == 0){
|
||||
syslog(LOG_INFO, "%s: Missing Hardware identifier in configuration. I2C is not started\n",__func__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Driver only existfor VOX25 board */
|
||||
if (strcmp("VOX25", p))
|
||||
return;
|
||||
|
||||
/* open i2c device */
|
||||
dev = i2c_open_dev("/dev/i2c-0", 0x1E,
|
||||
I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE);
|
||||
if (dev < 0) {
|
||||
syslog(LOG_INFO,"%s: could not open i2c touch device\n",__func__);
|
||||
dev = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
do_init_tab(i2c_init_tab_vox25, sizeof(i2c_init_tab_vox25)/sizeof(struct i2c_reg_tab));
|
||||
|
||||
|
||||
/* read config file */
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"3220_buttons", "buttons", &buttons);
|
||||
list_for_each_entry(node, &buttons, list) {
|
||||
struct button_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct button_data));
|
||||
memset(data,0,sizeof(struct button_data));
|
||||
|
||||
data->button.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s){
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
data->button.func = &button_func;
|
||||
data->button.priv = data;
|
||||
|
||||
button_add(&data->button);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef PROX_PX3220_H
|
||||
#define PROX_PX3220_H
|
||||
|
||||
#include "server.h"
|
||||
|
||||
void px3220_init(struct server_ctx *);
|
||||
void px3220_check(void);
|
||||
|
||||
#endif /* PROX_PX3220_H */
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#include "config.h"
|
||||
#include <syslog.h>
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
#include "led.h"
|
||||
#include "button.h"
|
||||
#include "catv.h"
|
||||
#include "sfp.h"
|
||||
#include "touch_sx9512.h"
|
||||
#include "prox_px3220.h"
|
||||
|
||||
struct server_ctx server;
|
||||
|
||||
void sim_led_init(struct server_ctx *);
|
||||
void sim_button_init(struct server_ctx *);
|
||||
|
||||
void gpio_led_init(struct server_ctx *);
|
||||
void gpio_button_init(struct server_ctx *);
|
||||
|
||||
void catv_monitor_init(struct server_ctx *);
|
||||
void vox_init(struct server_ctx *);
|
||||
|
||||
struct catv_handler *catv_h;
|
||||
struct sfp_handler *sfp_h;
|
||||
|
||||
void server_start(struct uci_context *uci_ctx, struct ubus_context *ubus_ctx)
|
||||
|
||||
{
|
||||
DBG(1, "init server context.");
|
||||
server.uci_ctx = uci_ctx;
|
||||
server.ubus_ctx = ubus_ctx;
|
||||
|
||||
DBG(1, "run init function for all hardware drivers.");
|
||||
|
||||
sim_led_init(&server);
|
||||
sim_button_init(&server);
|
||||
|
||||
#ifdef HAVE_BOARD_H
|
||||
gpio_led_init(&server);
|
||||
gpio_button_init(&server);
|
||||
|
||||
sx9512_handler_init(&server);
|
||||
|
||||
px3220_init(&server);
|
||||
|
||||
vox_init(&server);
|
||||
#endif
|
||||
|
||||
DBG(1, "connect generic buttons/leds to hardware drivers.");
|
||||
led_init(&server);
|
||||
button_init(&server);
|
||||
|
||||
sfp_h = sfp_init(uci_ctx);
|
||||
if (sfp_h) {
|
||||
sfp_ubus_populate(sfp_h, ubus_ctx);
|
||||
}
|
||||
|
||||
catv_h = catv_init(uci_ctx, "/dev/i2c-0", 0x50, 0x51);
|
||||
if (catv_h){
|
||||
catv_ubus_populate(catv_h, ubus_ctx);
|
||||
}
|
||||
|
||||
catv_monitor_init(&server);
|
||||
|
||||
DBG(1, "give control to uloop main loop.");
|
||||
uloop_run();
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef SERVER_H
|
||||
#define SERVER_H
|
||||
#include <libubus.h>
|
||||
#include "ucix.h"
|
||||
|
||||
struct server_ctx {
|
||||
struct uci_context *uci_ctx;
|
||||
struct ubus_context *ubus_ctx;
|
||||
};
|
||||
|
||||
void server_start( struct uci_context *uci_ctx, struct ubus_context *ubus_ctx);
|
||||
|
||||
#endif /* SERVER_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef SFP_H
|
||||
#include "libubus.h"
|
||||
#include "ucix.h"
|
||||
|
||||
struct sfp_handler;
|
||||
|
||||
struct sfp_handler * sfp_init(struct uci_context *uci_ctx);
|
||||
int sfp_ubus_populate(struct sfp_handler *h, struct ubus_context *ubus_ctx);
|
||||
void sfp_destroy(struct sfp_handler *h);
|
||||
|
||||
#endif /*SFP_H*/
|
||||
|
|
@ -1,191 +0,0 @@
|
|||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include "button.h"
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
|
||||
|
||||
void sim_button_init(struct server_ctx *s_ctx);
|
||||
|
||||
struct sim_data {
|
||||
int addr;
|
||||
int active;
|
||||
int state;
|
||||
struct button_drv button;
|
||||
};
|
||||
|
||||
struct drv_button_list{
|
||||
struct list_head list;
|
||||
struct button_drv *drv;
|
||||
};
|
||||
|
||||
static button_state_t sim_get_state(struct button_drv *drv)
|
||||
{
|
||||
// DBG(1, "state for %s", drv->name);
|
||||
struct sim_data *p = (struct sim_data *)drv->priv;
|
||||
|
||||
return p->state;
|
||||
}
|
||||
|
||||
static struct button_drv_func func = {
|
||||
.get_state = sim_get_state,
|
||||
};
|
||||
|
||||
static LIST_HEAD(sim_buttons);
|
||||
|
||||
|
||||
enum {
|
||||
SIM_NAME,
|
||||
SIM_STATE,
|
||||
__SIM_MAX
|
||||
};
|
||||
|
||||
static const struct blobmsg_policy sim_policy[] = {
|
||||
[SIM_NAME] = { .name = "name", .type = BLOBMSG_TYPE_STRING },
|
||||
[SIM_STATE] = { .name = "state", .type = BLOBMSG_TYPE_STRING },
|
||||
};
|
||||
|
||||
static struct button_drv *get_drv_button(char *name)
|
||||
{
|
||||
struct list_head *i;
|
||||
list_for_each(i, &sim_buttons) {
|
||||
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
|
||||
if (! strcmp(node->drv->name, name))
|
||||
return node->drv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int sim_set_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__SIM_MAX];
|
||||
DBG(1, "");
|
||||
|
||||
blobmsg_parse(sim_policy, ARRAY_SIZE(sim_policy), tb, blob_data(msg), blob_len(msg));
|
||||
|
||||
if ( tb[SIM_NAME] ) {
|
||||
if ( tb[SIM_STATE] ) {
|
||||
struct button_drv *bt = get_drv_button((char *)blobmsg_data(tb[SIM_NAME]));
|
||||
DBG(1," name = %s",(char *)blobmsg_data(tb[SIM_NAME]));
|
||||
DBG(1," state = %s",(char *)blobmsg_data(tb[SIM_STATE]));
|
||||
|
||||
if (bt) {
|
||||
struct sim_data *p = (struct sim_data *)bt->priv;
|
||||
|
||||
if(!strcasecmp("pressed", (char *)blobmsg_data(tb[SIM_STATE]))){
|
||||
p->state = BUTTON_PRESSED;
|
||||
}
|
||||
if(!strcasecmp("released", (char *)blobmsg_data(tb[SIM_STATE]))){
|
||||
p->state = BUTTON_RELEASED;
|
||||
}
|
||||
}else
|
||||
DBG(1," button = %s not found",(char *)blobmsg_data(tb[SIM_NAME]));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_status_method(struct ubus_context *ubus_ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
struct blob_buf blob;
|
||||
struct list_head *i;
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
memset(&blob,0,sizeof(struct blob_buf));
|
||||
blob_buf_init(&blob, 0);
|
||||
|
||||
list_for_each(i, &sim_buttons) {
|
||||
struct drv_button_list *node = list_entry(i, struct drv_button_list, list);
|
||||
const char *state;
|
||||
struct sim_data *p = (struct sim_data *)node->drv->priv;
|
||||
|
||||
if(p->state == BUTTON_RELEASED)
|
||||
state = "Released";
|
||||
else
|
||||
state = "Pressed";
|
||||
|
||||
blobmsg_add_string(&blob, node->drv->name, state);
|
||||
}
|
||||
ubus_send_reply(ubus_ctx, req, blob.head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const struct ubus_method sim_methods[] = {
|
||||
UBUS_METHOD("set", sim_set_method, sim_policy),
|
||||
{ .name = "status",
|
||||
.handler = sim_status_method },
|
||||
};
|
||||
|
||||
static struct ubus_object_type sim_object_type =
|
||||
UBUS_OBJECT_TYPE("sim", sim_methods);
|
||||
|
||||
#define SIM_OBJECTS 1
|
||||
static struct ubus_object sim_objects[SIM_OBJECTS] = {
|
||||
{ .name = "button",
|
||||
.type = &sim_object_type,
|
||||
.methods = sim_methods,
|
||||
.n_methods = ARRAY_SIZE(sim_methods),
|
||||
},
|
||||
};
|
||||
|
||||
void sim_button_init(struct server_ctx *s_ctx) {
|
||||
int i,ret;
|
||||
struct ucilist *node;
|
||||
LIST_HEAD(buttons);
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"sim_buttons", "buttons", &buttons);
|
||||
list_for_each_entry(node, &buttons, list) {
|
||||
struct sim_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct sim_data));
|
||||
memset(data,0,sizeof(struct sim_data));
|
||||
|
||||
data->button.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s){
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "active");
|
||||
data->active = -1;
|
||||
if (s){
|
||||
if (!strncasecmp("hi",s,2))
|
||||
data->active = 1;
|
||||
else if (!strncasecmp("low",s,3))
|
||||
data->active = 0;
|
||||
|
||||
}
|
||||
DBG(1, "active = %d", data->active);
|
||||
|
||||
data->button.func = &func;
|
||||
data->button.priv = data;
|
||||
|
||||
button_add(&data->button);
|
||||
|
||||
{ /* save button in internal list, we need this for ubus set/status */
|
||||
struct drv_button_list *bt = malloc(sizeof(struct drv_button_list));
|
||||
memset(bt, 0, sizeof(struct drv_button_list));
|
||||
bt->drv = &data->button;
|
||||
list_add(&bt->list, &sim_buttons);
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0 ; i<SIM_OBJECTS ; i++) {
|
||||
ret = ubus_add_object(s_ctx->ubus_ctx, &sim_objects[i]);
|
||||
if (ret)
|
||||
DBG(1,"Failed to add object: %s", ubus_strerror(ret));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include "led.h"
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
|
||||
void sim_led_init(struct server_ctx *s_ctx);
|
||||
|
||||
static int sim_set_state(struct led_drv *drv, led_state_t state)
|
||||
{
|
||||
DBG(1, "state %x on %s", state, drv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static led_state_t sim_get_state(struct led_drv *drv)
|
||||
{
|
||||
DBG(1, "state for %s", drv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_set_color(struct led_drv *drv, led_color_t color)
|
||||
{
|
||||
DBG(1, "color %d on %s", color, drv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static led_color_t sim_get_color(struct led_drv *drv)
|
||||
{
|
||||
DBG(1, "color for %s", drv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct led_drv_func func = {
|
||||
.set_state = sim_set_state,
|
||||
.get_state = sim_get_state,
|
||||
.set_color = sim_set_color,
|
||||
.get_color = sim_get_color,
|
||||
};
|
||||
|
||||
struct sim_data {
|
||||
int addr;
|
||||
led_color_t color;
|
||||
int state;
|
||||
int pulsing;
|
||||
struct led_drv led;
|
||||
};
|
||||
|
||||
void sim_led_init(struct server_ctx *s_ctx) {
|
||||
|
||||
LIST_HEAD(leds);
|
||||
struct ucilist *node;
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"sim_leds", "leds", &leds);
|
||||
list_for_each_entry(node,&leds,list){
|
||||
struct sim_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct sim_data));
|
||||
memset(data,0,sizeof(struct sim_data));
|
||||
|
||||
data->led.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s){
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "color");
|
||||
if (s){
|
||||
if (!strncasecmp("red",s,3))
|
||||
data->color = RED;
|
||||
else if (!strncasecmp("green",s,5))
|
||||
data->color = GREEN;
|
||||
else if (!strncasecmp("blue",s,4))
|
||||
data->color = BLUE;
|
||||
else if (!strncasecmp("yellow",s,6))
|
||||
data->color = YELLOW;
|
||||
else if (!strncasecmp("white",s,5))
|
||||
data->color = WHITE;
|
||||
}
|
||||
DBG(1, "color = [%s]=(%d)", s,data->color);
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "pulsing");
|
||||
DBG(1, "pulsing = [%s]", s);
|
||||
if (s){
|
||||
if (!strncasecmp("yes",s,3))
|
||||
data->pulsing = 1;
|
||||
}
|
||||
data->led.func = &func;
|
||||
data->led.priv = data;
|
||||
led_add(&data->led);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,224 +0,0 @@
|
|||
/*
|
||||
smbus.c - SMBus level access helper functions
|
||||
|
||||
Copyright (C) 1995-1997 Simon G. Vogl
|
||||
Copyright (C) 1998-1999 Frodo Looijaard <frodol@dds.nl>
|
||||
Copyright (C) 2012-2013 Jean Delvare <jdelvare@suse.de>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include "smbus.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
|
||||
/* Compatibility defines */
|
||||
#ifndef I2C_SMBUS_I2C_BLOCK_BROKEN
|
||||
#define I2C_SMBUS_I2C_BLOCK_BROKEN I2C_SMBUS_I2C_BLOCK_DATA
|
||||
#endif
|
||||
#ifndef I2C_FUNC_SMBUS_PEC
|
||||
#define I2C_FUNC_SMBUS_PEC I2C_FUNC_SMBUS_HWPEC_CALC
|
||||
#endif
|
||||
|
||||
__s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||
int size, union i2c_smbus_data *data)
|
||||
{
|
||||
struct i2c_smbus_ioctl_data args;
|
||||
__s32 err;
|
||||
|
||||
args.read_write = read_write;
|
||||
args.command = command;
|
||||
args.size = size;
|
||||
args.data = data;
|
||||
|
||||
err = ioctl(file, I2C_SMBUS, &args);
|
||||
if (err == -1)
|
||||
err = -errno;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
__s32 i2c_smbus_write_quick(int file, __u8 value)
|
||||
{
|
||||
return i2c_smbus_access(file, value, 0, I2C_SMBUS_QUICK, NULL);
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_read_byte(int file)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int err;
|
||||
|
||||
err = i2c_smbus_access(file, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &data);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0x0FF & data.byte;
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_write_byte(int file, __u8 value)
|
||||
{
|
||||
return i2c_smbus_access(file, I2C_SMBUS_WRITE, value,
|
||||
I2C_SMBUS_BYTE, NULL);
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_read_byte_data(int file, __u8 command)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int err;
|
||||
|
||||
err = i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
I2C_SMBUS_BYTE_DATA, &data);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0x0FF & data.byte;
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
data.byte = value;
|
||||
return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
I2C_SMBUS_BYTE_DATA, &data);
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_read_word_data(int file, __u8 command)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int err;
|
||||
|
||||
err = i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
I2C_SMBUS_WORD_DATA, &data);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return 0x0FFFF & data.word;
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
data.word = value;
|
||||
return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
I2C_SMBUS_WORD_DATA, &data);
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
data.word = value;
|
||||
if (i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
I2C_SMBUS_PROC_CALL, &data))
|
||||
return -1;
|
||||
else
|
||||
return 0x0FFFF & data.word;
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
__s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i, err;
|
||||
|
||||
err = i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
I2C_SMBUS_BLOCK_DATA, &data);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length,
|
||||
const __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
if (length > I2C_SMBUS_BLOCK_MAX)
|
||||
length = I2C_SMBUS_BLOCK_MAX;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
I2C_SMBUS_BLOCK_DATA, &data);
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||
ask for less than 32 bytes, your code will only work with kernels
|
||||
2.6.23 and later. */
|
||||
__s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 length,
|
||||
__u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i, err;
|
||||
|
||||
if (length > I2C_SMBUS_BLOCK_MAX)
|
||||
length = I2C_SMBUS_BLOCK_MAX;
|
||||
data.block[0] = length;
|
||||
|
||||
err = i2c_smbus_access(file, I2C_SMBUS_READ, command,
|
||||
length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
|
||||
I2C_SMBUS_I2C_BLOCK_DATA, &data);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
|
||||
__s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, __u8 length,
|
||||
const __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
if (length > I2C_SMBUS_BLOCK_MAX)
|
||||
length = I2C_SMBUS_BLOCK_MAX;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
return i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
__s32 i2c_smbus_block_process_call(int file, __u8 command, __u8 length,
|
||||
__u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i, err;
|
||||
|
||||
if (length > I2C_SMBUS_BLOCK_MAX)
|
||||
length = I2C_SMBUS_BLOCK_MAX;
|
||||
for (i = 1; i <= length; i++)
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
|
||||
err = i2c_smbus_access(file, I2C_SMBUS_WRITE, command,
|
||||
I2C_SMBUS_BLOCK_PROC_CALL, &data);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
for (i = 1; i <= data.block[0]; i++)
|
||||
values[i-1] = data.block[i];
|
||||
return data.block[0];
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
smbus.h - SMBus level access helper functions
|
||||
|
||||
Copyright (C) 1995-97 Simon G. Vogl
|
||||
Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef LIB_I2C_SMBUS_H
|
||||
#define LIB_I2C_SMBUS_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/i2c.h>
|
||||
|
||||
extern __s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||
int size, union i2c_smbus_data *data);
|
||||
|
||||
extern __s32 i2c_smbus_write_quick(int file, __u8 value);
|
||||
extern __s32 i2c_smbus_read_byte(int file);
|
||||
extern __s32 i2c_smbus_write_byte(int file, __u8 value);
|
||||
extern __s32 i2c_smbus_read_byte_data(int file, __u8 command);
|
||||
extern __s32 i2c_smbus_write_byte_data(int file, __u8 command, __u8 value);
|
||||
extern __s32 i2c_smbus_read_word_data(int file, __u8 command);
|
||||
extern __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value);
|
||||
extern __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value);
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
extern __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values);
|
||||
extern __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length,
|
||||
const __u8 *values);
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||
ask for less than 32 bytes, your code will only work with kernels
|
||||
2.6.23 and later. */
|
||||
extern __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 length,
|
||||
__u8 *values);
|
||||
extern __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, __u8 length,
|
||||
const __u8 *values);
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
extern __s32 i2c_smbus_block_process_call(int file, __u8 command, __u8 length,
|
||||
__u8 *values);
|
||||
|
||||
#endif /* LIB_I2C_SMBUS_H */
|
||||
|
|
@ -1,348 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <error.h>
|
||||
#include <errno.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include "sx9512.h"
|
||||
#include "smbus.h"
|
||||
#include "i2c.h"
|
||||
#include "gpio.h"
|
||||
|
||||
|
||||
#define X(name, reserved, default) { #name, reserved, default },
|
||||
const struct sx9512_reg_data sx9512_reg_data[] = { SX9512_REGS };
|
||||
#undef X
|
||||
|
||||
|
||||
//! init the sx9512 and optionally program the registers
|
||||
|
||||
//! @param addr I2C address (0=0x2c)
|
||||
//! @param nvm compare and if different program the registers and flash the NVM with these contents
|
||||
//! @return file descriptor for SX9512 I2C device
|
||||
//! @retval -1 error
|
||||
int sx9512_init(const char *dev, int addr, struct sx9512_reg_nvm *nvm)
|
||||
{
|
||||
int fd, i;
|
||||
struct sx9512_reg_nvm nvm_read;
|
||||
if(!addr)
|
||||
addr=SX9512_I2C_ADDRESS;
|
||||
if((fd=i2c_open_dev(dev, addr, I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE))<0)
|
||||
return -1;
|
||||
/*fd = open(dev, O_RDWR);
|
||||
if(fd < 0) {
|
||||
error(0, errno, "could not open %s", dev);
|
||||
return -1;
|
||||
}
|
||||
if(ioctl(fd, I2C_SLAVE, addr) < 0) {
|
||||
error(0, errno, "could not set address %x for i2c chip", SX9512_I2C_ADDRESS);
|
||||
close(fd);
|
||||
return -1;
|
||||
}*/
|
||||
if(nvm) {
|
||||
if(sx9512_reg_nvm_read(fd, &nvm_read)) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
for(i=0;(unsigned int)i<sizeof(struct sx9512_reg_nvm);i++) {
|
||||
if(sx9512_reg_reserved(i+SX9512_REG_NVM_AREA_START))
|
||||
continue;
|
||||
if(((uint8_t *)nvm)[i] != ((uint8_t *)&nvm_read)[i]) {
|
||||
fprintf(stderr, "sx9512_init: register mismatch, setting default values and burning to NVM\n");
|
||||
if(sx9512_reg_nvm_write(fd, nvm)) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
sx9512_reg_nvm_store(fd); //store to NVM
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
const char *sx9512_reg_name(sx9512_reg_t reg)
|
||||
{
|
||||
return sx9512_reg_data[reg].name;
|
||||
}
|
||||
|
||||
|
||||
//! SX9512 check if reg is reserved
|
||||
int sx9512_reg_reserved(sx9512_reg_t reg)
|
||||
{
|
||||
if(reg==SX9512_REG_I2C_SOFT_RESET)
|
||||
return 0;
|
||||
if(reg>=SX9512_REGS_AMOUNT)
|
||||
return 1;
|
||||
return sx9512_reg_data[reg].reserved;
|
||||
}
|
||||
|
||||
|
||||
//! send reset command
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_reset(int fd)
|
||||
{
|
||||
if(i2c_smbus_write_byte_data(fd, SX9512_REG_I2C_SOFT_RESET, 0xde)<0)
|
||||
return -1;
|
||||
if(i2c_smbus_write_byte_data(fd, SX9512_REG_I2C_SOFT_RESET, 0x00)<0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! send reset command but retain LED values
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_reset_restore_led_state(int fd)
|
||||
{
|
||||
int r;
|
||||
uint8_t p[4];
|
||||
if((r=i2c_smbus_read_i2c_block_data(fd, SX9512_REG_LED1_ON, 4, (__u8 *)&p))<0)
|
||||
return r;
|
||||
if(sx9512_reset(fd))
|
||||
return -1;
|
||||
if((r=i2c_smbus_write_i2c_block_data(fd, SX9512_REG_LED1_ON, 4, (__u8 *)&p))<0)
|
||||
return r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! read interrupt reg
|
||||
|
||||
//! @retval -1 error
|
||||
int sx9512_read_interrupt(int fd)
|
||||
{
|
||||
int r;
|
||||
if((r=i2c_smbus_read_byte_data(fd, SX9512_REG_IRQ_SRC))<0)
|
||||
return -1;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//! read touch reg
|
||||
|
||||
//! @retval -1 error
|
||||
int sx9512_read_buttons(int fd)
|
||||
{
|
||||
int r;
|
||||
if((r=i2c_smbus_read_byte_data(fd, SX9512_REG_TOUCH_STATUS))<0)
|
||||
return -1;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//! read prox reg
|
||||
|
||||
//! @retval -1 error
|
||||
int sx9512_read_proximity(int fd)
|
||||
{
|
||||
int r;
|
||||
if((r=i2c_smbus_read_byte_data(fd, SX9512_REG_PROX_STATUS))<0)
|
||||
return -1;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
//! read status regs
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_read_status(int fd, struct sx9512_reg_status *status)
|
||||
{
|
||||
//REG_IRQ_SRC not working if using block read for some reason.
|
||||
//if(i2c_smbus_read_i2c_block_data(fd, SX9512_REG_IRQ_SRC, sizeof(struct sx9512_reg_status), (uint8_t *)status)<0)
|
||||
//return -1;
|
||||
int r;
|
||||
if((r=i2c_smbus_read_byte_data(fd, SX9512_REG_IRQ_SRC))<0)
|
||||
return -1;
|
||||
((uint8_t *)status)[0]=r;
|
||||
if((r=i2c_smbus_read_byte_data(fd, SX9512_REG_TOUCH_STATUS))<0)
|
||||
return -1;
|
||||
((uint8_t *)status)[1]=r;
|
||||
if((r=i2c_smbus_read_byte_data(fd, SX9512_REG_PROX_STATUS))<0)
|
||||
return -1;
|
||||
((uint8_t *)status)[2]=r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! read status cached
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_read_status_cached(int fd, struct sx9512_touch_state *touch_state)
|
||||
{
|
||||
static uint8_t last_state=0;
|
||||
struct sx9512_reg_status status;
|
||||
touch_state->touched=0;
|
||||
touch_state->released=0;
|
||||
if(sx9512_read_status(fd, &status))
|
||||
error(-1, errno, "I2C read error");
|
||||
touch_state->state=status.touch_status | !!((*(uint8_t *)&status.prox_status) & 0xc0);
|
||||
if(*(uint8_t *)&status.irq_src) {
|
||||
if(status.irq_src.touch || status.irq_src.prox_near)
|
||||
touch_state->touched = (last_state ^ touch_state->state) & touch_state->state;
|
||||
if(status.irq_src.release || status.irq_src.prox_far)
|
||||
touch_state->released = (last_state ^ touch_state->state) & last_state;
|
||||
}
|
||||
last_state=touch_state->state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! send cmd to load values from NVM to RAM
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_reg_nvm_load(int fd)
|
||||
{
|
||||
if(i2c_smbus_write_byte_data(fd, SX9512_REG_NVM_CTRL, 0x08)<0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! send cmd to store RAM to NVM
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_reg_nvm_store(int fd)
|
||||
{
|
||||
if(i2c_smbus_write_byte_data(fd, SX9512_REG_NVM_CTRL, 0x50)<0)
|
||||
return -1;
|
||||
if(i2c_smbus_write_byte_data(fd, SX9512_REG_NVM_CTRL, 0xa0)<0)
|
||||
return -1;
|
||||
//Wait 500ms then power off/on
|
||||
sleep(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! read whole NVM region
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_reg_nvm_read(int fd, struct sx9512_reg_nvm *p)
|
||||
{
|
||||
int r, s, i, rl;
|
||||
s=sizeof(struct sx9512_reg_nvm);
|
||||
for(i=0; i<s; i+=32) {
|
||||
rl=s-i;
|
||||
if(rl>32)
|
||||
rl=32;
|
||||
if((r=i2c_smbus_read_i2c_block_data(fd, SX9512_REG_NVM_AREA_START+i, rl, (uint8_t *)p+i))<0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! write whole NVM region
|
||||
|
||||
//! @retval 0 ok
|
||||
int sx9512_reg_nvm_write(int fd, struct sx9512_reg_nvm *p)
|
||||
{
|
||||
int r, s, i, rl;
|
||||
s=sizeof(struct sx9512_reg_nvm);
|
||||
for(i=0; i<s; i+=32) {
|
||||
rl=s-i;
|
||||
if(rl>32)
|
||||
rl=32;
|
||||
if((r=i2c_smbus_write_i2c_block_data(fd, SX9512_REG_NVM_AREA_START+i, rl, (uint8_t *)p+i))<0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! init NVM struct
|
||||
void sx9512_reg_nvm_init(struct sx9512_reg_nvm *p)
|
||||
{
|
||||
memset(p, 0, sizeof(struct sx9512_reg_nvm));
|
||||
p->cap_sense_op.set_to_0x14=0x14;
|
||||
}
|
||||
|
||||
|
||||
//! init NVM struct to defaults
|
||||
void sx9512_reg_nvm_init_defaults(struct sx9512_reg_nvm *p, uint8_t capsense_channels, uint8_t led_channels)
|
||||
{
|
||||
int i;
|
||||
sx9512_reg_nvm_init(p);
|
||||
p->irq_mask.touch=1;
|
||||
p->irq_mask.release=1;
|
||||
p->irq_mask.prox_near=1;
|
||||
p->irq_mask.prox_far=1;
|
||||
if(led_channels) {
|
||||
p->led_map[0]=0x00;
|
||||
//p->led_map[1]=led_channels;
|
||||
p->led_map[1]=0x00; //default all leds off
|
||||
p->led_pwm_freq=0x10;
|
||||
p->led_idle=0xff;
|
||||
p->led1_on=0xff;
|
||||
p->led2_on=0xff;
|
||||
p->led_pwr_idle=0xff;
|
||||
p->led_pwr_on=0xff;
|
||||
}
|
||||
p->cap_sense_enable=capsense_channels;
|
||||
for(i=0;i<SX9512_CHANNELS+1;i++) {
|
||||
p->cap_sense_range[i].ls_control=0x01;
|
||||
p->cap_sense_range[i].delta_cin_range=0x03;
|
||||
p->cap_sense_thresh[i]=0x04;
|
||||
}
|
||||
p->cap_sense_thresh[0]=0x02;
|
||||
p->cap_sense_op.auto_compensation=0;
|
||||
p->cap_sense_op.proximity_bl0=1;
|
||||
p->cap_sense_op.proximity_combined_channels=0;
|
||||
p->cap_sense_mode.raw_filter=0x03;
|
||||
p->cap_sense_mode.touch_reporting=1;
|
||||
p->cap_sense_mode.cap_sense_digital_gain=0;
|
||||
p->cap_sense_mode.cap_sense_report_mode=0;
|
||||
p->cap_sense_debounce.cap_sense_prox_near_debounce=0;
|
||||
p->cap_sense_debounce.cap_sense_prox_far_debounce=0;
|
||||
p->cap_sense_debounce.cap_sense_touch_debounce=0;
|
||||
p->cap_sense_debounce.cap_sense_release_debounce=1;
|
||||
p->cap_sense_neg_comp_thresh=0x80;
|
||||
p->cap_sense_pos_comp_thresh=0x80;
|
||||
p->cap_sense_pos_filt.cap_sense_prox_hyst=0;
|
||||
p->cap_sense_pos_filt.cap_sense_pos_comp_debounce=2;
|
||||
p->cap_sense_pos_filt.cap_sense_avg_pos_filt_coef=7;
|
||||
p->cap_sense_neg_filt.cap_sense_touch_hyst=0;
|
||||
p->cap_sense_neg_filt.cap_sense_neg_comp_debounce=2;
|
||||
p->cap_sense_neg_filt.cap_sense_avg_neg_filt_coef=5;
|
||||
p->spo_chan_map=0xff;
|
||||
}
|
||||
|
||||
|
||||
void sx9512_reg_nvm_init_cg300(struct sx9512_reg_nvm *p)
|
||||
{
|
||||
int i;
|
||||
sx9512_reg_nvm_init_defaults(p, 0x0f, 0x3c);
|
||||
p->led_map[0]=0x01;
|
||||
p->led_map[1]=0x3c;
|
||||
for(i=0;i<SX9512_CHANNELS+1;i++) {
|
||||
p->cap_sense_range[i].delta_cin_range=0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sx9512_reg_nvm_init_cg301(struct sx9512_reg_nvm *p)
|
||||
{
|
||||
int i;
|
||||
sx9512_reg_nvm_init_defaults(p, 0x3b, 0x7f);
|
||||
p->led_map[1]=0x7f;
|
||||
for(i=0;i<SX9512_CHANNELS+1;i++) {
|
||||
p->cap_sense_range[i].delta_cin_range=0x01;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sx9512_reg_nvm_init_eg300(struct sx9512_reg_nvm *p)
|
||||
{
|
||||
sx9512_reg_nvm_init_defaults(p, 0x0f, 0xff);
|
||||
}
|
||||
|
||||
|
||||
void sx9512_reg_nvm_init_dg400(struct sx9512_reg_nvm *p)
|
||||
{
|
||||
sx9512_reg_nvm_init_defaults(p, 0x3f, 0x00);
|
||||
}
|
||||
|
|
@ -1,605 +0,0 @@
|
|||
#ifndef _SX9512_H
|
||||
#define _SX9512_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define BIT_ORDER_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#define SX9512_I2C_ADDRESS 0x2b
|
||||
#define SX9512B_I2C_ADDRESS 0x2d
|
||||
#define SX9512_CHANNELS 8
|
||||
|
||||
#define SX9512_REG_NVM_AREA_START 0x07
|
||||
#define SX9512_REG_NVM_AREA_END 0x62
|
||||
|
||||
#define SX9512_REG_I2C_SOFT_RESET 0xff
|
||||
|
||||
//Name, reserved, default value
|
||||
#define SX9512_REGS \
|
||||
X(IRQ_SRC, 0, 0x00) \
|
||||
X(TOUCH_STATUS, 0, 0x00) \
|
||||
X(PROX_STATUS, 0, 0x00) \
|
||||
X(COMP_STATUS, 0, 0x00) \
|
||||
X(NVM_CTRL, 0, 0x00) \
|
||||
X(R_05, 1, 0x00) \
|
||||
X(R_06, 1, 0x00) \
|
||||
X(SPO2_MODE, 0, 0x00) \
|
||||
X(PWR_KEY, 0, 0x00) \
|
||||
X(IRQ_MASK, 0, 0x00) \
|
||||
X(R_0A, 1, 0x00) \
|
||||
X(R_0B, 1, 0x00) \
|
||||
X(LED_MAP1, 0, 0x00) \
|
||||
X(LED_MAP2, 0, 0x00) \
|
||||
X(LED_PWM_FREQ, 0, 0x00) \
|
||||
X(LED_MODE, 0, 0x00) \
|
||||
X(LED_IDLE, 0, 0x00) \
|
||||
X(LED_OFF_DELAY, 0, 0x00) \
|
||||
X(LED1_ON, 0, 0x00) \
|
||||
X(LED1_FADE, 0, 0x00) \
|
||||
X(LED2_ON, 0, 0x00) \
|
||||
X(LED2_FADE, 0, 0x00) \
|
||||
X(LED_PWR_IDLE, 0, 0x00) \
|
||||
X(LED_PWR_ON, 0, 0x00) \
|
||||
X(LED_PWR_OFF, 0, 0x00) \
|
||||
X(LED_PWR_FADE, 0, 0x00) \
|
||||
X(LED_PWR_ON_PW, 0, 0x00) \
|
||||
X(LED_PWR_MODE, 0, 0x00) \
|
||||
X(R_1C, 1, 0x00) \
|
||||
X(R_1D, 1, 0x00) \
|
||||
X(CAP_SENSE_ENABLE, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE0, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE1, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE2, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE3, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE4, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE5, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE6, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE7, 0, 0x00) \
|
||||
X(CAP_SENSE_RANGE_ALL, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH0, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH1, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH2, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH3, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH4, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH5, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH6, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH7, 0, 0x00) \
|
||||
X(CAP_SENSE_THRESH_COMB, 0, 0x00) \
|
||||
X(CAP_SENSE_OP, 0, 0x00) \
|
||||
X(CAP_SENSE_MODE, 0, 0x00) \
|
||||
X(CAP_SENSE_DEBOUNCE, 0, 0x00) \
|
||||
X(CAP_SENSE_NEG_COMP_THRESH, 0, 0x00) \
|
||||
X(CAP_SENSE_POS_COMP_THRESH, 0, 0x00) \
|
||||
X(CAP_SENSE_POS_FILT, 0, 0x00) \
|
||||
X(CAP_SENSE_NEG_FILT, 0, 0x00) \
|
||||
X(CAP_SENSE_STUCK, 0, 0x00) \
|
||||
X(CAP_SENSE_FRAME_SKIP, 0, 0x00) \
|
||||
X(CAP_SENSE_MISC, 0, 0x00) \
|
||||
X(PROX_COMB_CHAN_MASK, 0, 0x00) \
|
||||
X(R_3C, 1, 0x00) \
|
||||
X(R_3D, 1, 0x00) \
|
||||
X(SPO_CHAN_MAP, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL0, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL1, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL2, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL3, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL4, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL5, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL6, 0, 0x00) \
|
||||
X(SPO_LEVEL_BL7, 0, 0x00) \
|
||||
X(SPO_LEVEL_IDLE, 0, 0x00) \
|
||||
X(SPO_LEVEL_PROX, 0, 0x00) \
|
||||
X(R_49, 1, 0x00) \
|
||||
X(R_4A, 1, 0x00) \
|
||||
X(BUZZER_TRIGGER, 0, 0x00) \
|
||||
X(BUZZER_FREQ, 0, 0x00) \
|
||||
X(R_4D, 1, 0x00) \
|
||||
X(R_4E, 1, 0x00) \
|
||||
X(R_4F, 1, 0x00) \
|
||||
X(R_50, 1, 0x00) \
|
||||
X(R_51, 1, 0x00) \
|
||||
X(R_52, 1, 0x00) \
|
||||
X(R_53, 1, 0x00) \
|
||||
X(R_54, 1, 0x00) \
|
||||
X(R_55, 1, 0x00) \
|
||||
X(R_56, 1, 0x00) \
|
||||
X(R_57, 1, 0x00) \
|
||||
X(R_58, 1, 0x00) \
|
||||
X(R_59, 1, 0x00) \
|
||||
X(R_5A, 1, 0x00) \
|
||||
X(R_5B, 1, 0x00) \
|
||||
X(R_5C, 1, 0x00) \
|
||||
X(R_5D, 1, 0x00) \
|
||||
X(R_5E, 1, 0x00) \
|
||||
X(R_5F, 1, 0x00) \
|
||||
X(R_60, 1, 0x00) \
|
||||
X(R_61, 1, 0x00) \
|
||||
X(CAP_SENSE_CHAN_SELECT, 0, 0x00) \
|
||||
X(CAP_SENSE_USEFUL_DATA_MSB, 0, 0x00) \
|
||||
X(CAP_SENSE_USEFUL_DATA_LSB, 0, 0x00) \
|
||||
X(CAP_SENSE_AVERAGE_DATA_MSB, 0, 0x00) \
|
||||
X(CAP_SENSE_AVERAGE_DATA_LSB, 0, 0x00) \
|
||||
X(CAP_SENSE_DIFF_DATA_MSB, 0, 0x00) \
|
||||
X(CAP_SENSE_DIFF_DATA_LSB, 0, 0x00) \
|
||||
X(CAP_SENSE_COMP_MSB, 0, 0x00) \
|
||||
X(CAP_SENSE_COMP_LSB, 0, 0x00)
|
||||
|
||||
|
||||
#define X(name, reserved, default) SX9512_REG_##name,
|
||||
typedef enum { SX9512_REGS SX9512_REGS_AMOUNT } sx9512_reg_t;
|
||||
#undef X
|
||||
|
||||
|
||||
struct sx9512_reg_data {
|
||||
const char *name;
|
||||
uint8_t reserved, default_value;
|
||||
};
|
||||
|
||||
|
||||
//! Interrupt source
|
||||
|
||||
//! The Irq Source register will indicate that the specified event has occurred since the last read of this register. If the
|
||||
//! NIRQ function is selected for SPO2 then it will indicate the occurrence of any of these events that are not masked
|
||||
//! out in register 0x09.
|
||||
//! The Irq mask in register 0x09 will prevent an Irq from being indicated by the NIRQ pin but it will not prevent the
|
||||
//! IRQ from being noted in this register.
|
||||
struct sx9512_reg_irq_src {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t reset:1;
|
||||
uint8_t touch:1;
|
||||
uint8_t release:1;
|
||||
uint8_t prox_near:1; //!< proximity on
|
||||
uint8_t prox_far:1; //!< proximity off
|
||||
uint8_t compensation_done:1; //!< write 1 to trigger compensation on all channels
|
||||
uint8_t conversion_done:1;
|
||||
uint8_t :1;
|
||||
#else
|
||||
uint8_t :1;
|
||||
uint8_t conversion_done:1;
|
||||
uint8_t compensation_done:1; //!< write 1 to trigger compensation on all channels
|
||||
uint8_t prox_far:1; //!< proximity off
|
||||
uint8_t prox_near:1; //!< proximity on
|
||||
uint8_t release:1;
|
||||
uint8_t touch:1;
|
||||
uint8_t reset:1;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! Proximity status
|
||||
struct sx9512_reg_prox_status {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t prox_bl0:1; //!< proximity detected on BL0
|
||||
uint8_t prox_multi:1; //!< proximity detected on combined channels
|
||||
uint8_t prox_multi_comp_pending:1; //!< compensation pending for combined channel prox sensing
|
||||
uint8_t :5;
|
||||
#else
|
||||
uint8_t :5;
|
||||
uint8_t prox_multi_comp_pending:1; //!< compensation pending for combined channel prox sensing
|
||||
uint8_t prox_multi:1; //!< proximity detected on combined channels
|
||||
uint8_t prox_bl0:1; //!< proximity detected on BL0
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! NVM Control
|
||||
|
||||
//! The NVM Area field indicates which of the user NVM areas are currently programmed and active (1, 2 or 3). The
|
||||
//! NVM Read bit gives the ability to manually request that the contents of the NVM be transferred to the registers
|
||||
//! and NVM Burn field gives the ability to burn the current registers to the next available NVM area.
|
||||
//! Normally, the transfer of data from the NVM to the registers is done automatically on power up and upon a reset
|
||||
//! but occasionally a user might want to force a read manually.
|
||||
//! Registers 0x07 through 0x62 are stored to NVM and loaded from NVM.
|
||||
//! After writing 0xA0 (ie NVM burn), wait for at least 500ms and then power off-on the IC for changes to be effective.
|
||||
//! Caution, there are only three user areas and attempts to burn values beyond user area 3 will be ignored.
|
||||
struct sx9512_reg_nvm_ctrl {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t nvm_burn:4; //!< write 0x50 followed by 0xA0 to initiate transfer of reg 0x07-0x62 to NVM
|
||||
uint8_t nvm_read:1; //!< trigger NVM read to registers
|
||||
uint8_t nvm_area:3; //!< indicates current active NVM area
|
||||
#else
|
||||
uint8_t nvm_area:3; //!< indicates current active NVM area
|
||||
uint8_t nvm_read:1; //!< trigger NVM read to registers
|
||||
uint8_t nvm_burn:4; //!< write 0x50 followed by 0xA0 to initiate transfer of reg 0x07-0x62 to NVM
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! SPO2 Mode Control
|
||||
|
||||
//! The SPO2 Config field will specify the functionality of the SPO pin. When selected as NIRQ, the open drain output
|
||||
//! will go low whenever a non-masked Irq occurs and the NIRQ will go back high after a register 0x00 is read over
|
||||
//! the I2C. When selected as Buzzer, the SPO2 pin will drive a 2 phase 2 frequency signal onto an external buzzer
|
||||
//! for each specified event (see Buzzer section). When selected as SPO2, pin operates as an analog output similar
|
||||
//! to SPO1 (see SPO section). If selected as TV power state, the pin is driven from the system PMIC with a high
|
||||
//! (SPO2 = SVDD) indicating that the system power is on and a low (SPO2 = GND) when the system power is off.
|
||||
//! The TV Power State bit reads back the current state of SPO2 if SPO2 is selected for TV power state, otherwise
|
||||
//! the system should write to this bit to indicate the current system power state. The SX9512/12B/13/13B needs to
|
||||
//! know the current state in able to correctly process some of the LED modes for the Power Button (see LED
|
||||
//! modes).
|
||||
struct sx9512_reg_spo2_mode {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t :1;
|
||||
uint8_t spo2_config:2; //!< set function of SPO2 pin
|
||||
uint8_t tv_power_state:1; //!< if SPO2 set to TV power state input then TV power state indicated by this bit.
|
||||
uint8_t :4;
|
||||
#else
|
||||
uint8_t :4;
|
||||
uint8_t tv_power_state:1; //!< if SPO2 set to TV power state input then TV power state indicated by this bit.
|
||||
uint8_t spo2_config:2; //!< set function of SPO2 pin
|
||||
uint8_t :1;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! Interrupt Request Mask
|
||||
|
||||
//! Set which Irqs will trigger an NIRQ (if enabled on SPO2) and report in reg 0x00
|
||||
//! 0=Disable IRQ
|
||||
//! 1=Enable IRQ
|
||||
struct sx9512_reg_irq_mask {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t reset:1;
|
||||
uint8_t touch:1;
|
||||
uint8_t release:1;
|
||||
uint8_t prox_near:1; //!< proximity on
|
||||
uint8_t prox_far:1; //!< proximity off
|
||||
uint8_t compensation_done:1;
|
||||
uint8_t :2;
|
||||
#else
|
||||
uint8_t :2;
|
||||
uint8_t compensation_done:1;
|
||||
uint8_t prox_far:1; //!< proximity off
|
||||
uint8_t prox_near:1; //!< proximity on
|
||||
uint8_t release:1;
|
||||
uint8_t touch:1;
|
||||
uint8_t reset:1;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! LED Mode
|
||||
struct sx9512_reg_led_mode {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t led_fade_repeat:4;
|
||||
uint8_t :1;
|
||||
uint8_t led_fading:1;
|
||||
uint8_t led_mode:2;
|
||||
#else
|
||||
uint8_t led_mode:2;
|
||||
uint8_t led_fading:1;
|
||||
uint8_t :1;
|
||||
uint8_t led_fade_repeat:4;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! LED off delay
|
||||
struct sx9512_reg_led_off_delay {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t led_engine1_delay_off_time:4;
|
||||
uint8_t led_engine2_delay_off_time:4;
|
||||
#else
|
||||
uint8_t led_engine2_delay_off_time:4;
|
||||
uint8_t led_engine1_delay_off_time:4;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! LED Engine fade in/out timing
|
||||
struct sx9512_reg_led_fade {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t led_engine_fade_in_time:4;
|
||||
uint8_t led_engine_fade_out_time:4;
|
||||
#else
|
||||
uint8_t led_engine_fade_out_time:4;
|
||||
uint8_t led_engine_fade_in_time:4;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! LED power button mode
|
||||
struct sx9512_reg_led_pwr_mode {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t power_led_off_mode:1;
|
||||
uint8_t power_led_max_level:1;
|
||||
uint8_t power_led_breath_max:1;
|
||||
uint8_t power_led_waveform:1;
|
||||
uint8_t :2;
|
||||
uint8_t power_button_enable:1;
|
||||
uint8_t led_touch_poarity_invert:1;
|
||||
#else
|
||||
uint8_t led_touch_poarity_invert:1;
|
||||
uint8_t power_button_enable:1;
|
||||
uint8_t :2;
|
||||
uint8_t power_led_waveform:1;
|
||||
uint8_t power_led_breath_max:1;
|
||||
uint8_t power_led_max_level:1;
|
||||
uint8_t power_led_off_mode:1;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense delta Cin range and LS control
|
||||
struct sx9512_reg_cap_sense_range {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t ls_control:2;
|
||||
uint8_t :4;
|
||||
uint8_t delta_cin_range:2;
|
||||
#else
|
||||
uint8_t delta_cin_range:2;
|
||||
uint8_t :4;
|
||||
uint8_t ls_control:2;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense auto compensation, proximity on BL0 and combined channel proximity
|
||||
struct sx9512_reg_cap_sense_op {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t auto_compensation:1;
|
||||
uint8_t proximity_bl0:1;
|
||||
uint8_t proximity_combined_channels:1;
|
||||
uint8_t set_to_0x14:5;
|
||||
#else
|
||||
uint8_t set_to_0x14:5;
|
||||
uint8_t proximity_combined_channels:1;
|
||||
uint8_t proximity_bl0:1;
|
||||
uint8_t auto_compensation:1;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense raw data filter coef, digital gain, I2C touch reporting and CapSense
|
||||
struct sx9512_reg_cap_sense_mode {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t raw_filter:3;
|
||||
uint8_t touch_reporting:1;
|
||||
uint8_t cap_sense_digital_gain:2;
|
||||
uint8_t cap_sense_report_mode:2;
|
||||
#else
|
||||
uint8_t cap_sense_report_mode:2;
|
||||
uint8_t cap_sense_digital_gain:2;
|
||||
uint8_t touch_reporting:1;
|
||||
uint8_t raw_filter:3;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense debounce
|
||||
struct sx9512_reg_cap_sense_debounce {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t cap_sense_prox_near_debounce:2;
|
||||
uint8_t cap_sense_prox_far_debounce:2;
|
||||
uint8_t cap_sense_touch_debounce:2;
|
||||
uint8_t cap_sense_release_debounce:2;
|
||||
#else
|
||||
uint8_t cap_sense_release_debounce:2;
|
||||
uint8_t cap_sense_touch_debounce:2;
|
||||
uint8_t cap_sense_prox_far_debounce:2;
|
||||
uint8_t cap_sense_prox_near_debounce:2;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense positive filter coef, positive auto compensation debounce and proximity hyst
|
||||
struct sx9512_reg_cap_sense_pos_filt {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t cap_sense_prox_hyst:3;
|
||||
uint8_t cap_sense_pos_comp_debounce:2;
|
||||
uint8_t cap_sense_avg_pos_filt_coef:3;
|
||||
#else
|
||||
uint8_t cap_sense_avg_pos_filt_coef:3;
|
||||
uint8_t cap_sense_pos_comp_debounce:2;
|
||||
uint8_t cap_sense_prox_hyst:3;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense negative filter coef, negative auto compensation debounce and touch hyst
|
||||
struct sx9512_reg_cap_sense_neg_filt {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t cap_sense_touch_hyst:3;
|
||||
uint8_t cap_sense_neg_comp_debounce:2;
|
||||
uint8_t cap_sense_avg_neg_filt_coef:3;
|
||||
#else
|
||||
uint8_t cap_sense_avg_neg_filt_coef:3;
|
||||
uint8_t cap_sense_neg_comp_debounce:2;
|
||||
uint8_t cap_sense_touch_hyst:3;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense stuck-at timer and periodic compensation timer
|
||||
struct sx9512_reg_cap_sense_stuck {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t cap_sense_stuck_at_timer:4;
|
||||
uint8_t cap_sense_periodic_comp:4;
|
||||
#else
|
||||
uint8_t cap_sense_periodic_comp:4;
|
||||
uint8_t cap_sense_stuck_at_timer:4;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense frame skip setting from active and sleep
|
||||
struct sx9512_reg_cap_sense_frame_skip {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t cap_sense_active_frame_skip:4;
|
||||
uint8_t cap_sense_sleep_frame_skip:4;
|
||||
#else
|
||||
uint8_t cap_sense_sleep_frame_skip:4;
|
||||
uint8_t cap_sense_active_frame_skip:4;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! CapSense sleep enable, auto compensation channels threshold, inactive BL control
|
||||
struct sx9512_reg_cap_sense_misc {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t :2;
|
||||
uint8_t comp_chan_num_thresh:2;
|
||||
uint8_t cap_sense_sleep_mode_enable:1;
|
||||
uint8_t :1;
|
||||
uint8_t cap_sense_inactive_bl_mode:2;
|
||||
#else
|
||||
uint8_t cap_sense_inactive_bl_mode:2;
|
||||
uint8_t :1;
|
||||
uint8_t cap_sense_sleep_mode_enable:1;
|
||||
uint8_t comp_chan_num_thresh:2;
|
||||
uint8_t :2;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! SPO analog output for proximity
|
||||
struct sx9512_reg_spo_level_prox {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t spo_report_prox:1;
|
||||
uint8_t spo_prox_channel_mapping:1;
|
||||
uint8_t spo_level_prox:6;
|
||||
#else
|
||||
uint8_t spo_level_prox:6;
|
||||
uint8_t spo_prox_channel_mapping:1;
|
||||
uint8_t spo_report_prox:1;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! Buzzer trigger event selection
|
||||
struct sx9512_reg_buzzer_trigger {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t :3;
|
||||
uint8_t buzzer_near:1;
|
||||
uint8_t buzzer_far:1;
|
||||
uint8_t buzzer_touch:1;
|
||||
uint8_t buzzer_release:1;
|
||||
uint8_t buzzer_idle_level:1;
|
||||
#else
|
||||
uint8_t buzzer_idle_level:1;
|
||||
uint8_t buzzer_release:1;
|
||||
uint8_t buzzer_touch:1;
|
||||
uint8_t buzzer_far:1;
|
||||
uint8_t buzzer_near:1;
|
||||
uint8_t :3;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
//! Buzzer duration frequency
|
||||
struct sx9512_reg_buzzer_freq {
|
||||
#ifdef BIT_ORDER_BIG_ENDIAN
|
||||
uint8_t buzzer_phase1_duration:2;
|
||||
uint8_t buzzer_phase1_freq:2;
|
||||
uint8_t buzzer_phase2_duration:2;
|
||||
uint8_t buzzer_phase2_freq:2;
|
||||
#else
|
||||
uint8_t buzzer_phase2_freq:2;
|
||||
uint8_t buzzer_phase2_duration:2;
|
||||
uint8_t buzzer_phase1_freq:2;
|
||||
uint8_t buzzer_phase1_duration:2;
|
||||
#endif
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
struct sx9512_reg_nvm {
|
||||
struct sx9512_reg_spo2_mode spo2_mode; //!< SPO2 mode control
|
||||
uint8_t pwr_key; //!< Power key control
|
||||
struct sx9512_reg_irq_mask irq_mask; //!< Interrupt request mask
|
||||
uint8_t reserved_0a[2];
|
||||
uint8_t led_map[2]; //!< LED map for engine 1/2
|
||||
uint8_t led_pwm_freq; //!< LED PWM frequency
|
||||
struct sx9512_reg_led_mode led_mode; //!< LED mode
|
||||
uint8_t led_idle; //!< LED idle level
|
||||
struct sx9512_reg_led_off_delay led_off_delay; //!< LED off delay
|
||||
uint8_t led1_on; //!< LED engine 1 on level
|
||||
struct sx9512_reg_led_fade led1_fade; //!< LED engine 1 fade in/out time
|
||||
uint8_t led2_on; //!< LED engine 2 on level
|
||||
struct sx9512_reg_led_fade led2_fade; //!< LED engine 2 fade in/out time
|
||||
uint8_t led_pwr_idle; //!< LED power button idle level
|
||||
uint8_t led_pwr_on; //!< LED power button on level
|
||||
uint8_t led_pwr_off; //!< LED power button off level
|
||||
uint8_t led_pwr_fade; //!< LED power button fade in/out time
|
||||
uint8_t led_pwr_on_pw; //!< LED power on pulse width
|
||||
struct sx9512_reg_led_pwr_mode led_pwr_mode; //!< LED power button mode
|
||||
uint8_t reserved_1c[2];
|
||||
uint8_t cap_sense_enable; //!< CapSense enable
|
||||
struct sx9512_reg_cap_sense_range cap_sense_range[9]; //!< CapSense delta Cin range and LS control chan 0-7
|
||||
//struct sx9512_reg_cap_sense_range cap_sense_range_all; //!< CapSense delta Cin range and LS control for prox sensor (combined channels)
|
||||
uint8_t cap_sense_thresh[9]; //!< CapSense detection threshold for chan 0-7
|
||||
//uint8_t cap_sense_thesh_comb; //!< CapSense detection threshold for prox sensor (combined channels)
|
||||
struct sx9512_reg_cap_sense_op cap_sense_op; //!< CapSense auto compensation, proximity on BL0 and combined channel proximity enable
|
||||
struct sx9512_reg_cap_sense_mode cap_sense_mode; //!< CapSense raw data filter coef, digital gain, I2C touch reporting and CapSense reporting
|
||||
struct sx9512_reg_cap_sense_debounce cap_sense_debounce; //!< CapSense debounce
|
||||
uint8_t cap_sense_neg_comp_thresh; //!< CapSense negative auto compensation threshold
|
||||
uint8_t cap_sense_pos_comp_thresh; //!< CapSense positive auto compensation threshold
|
||||
struct sx9512_reg_cap_sense_pos_filt cap_sense_pos_filt; //!< CapSense positive filter coef, positive auto compensation debounce and proximity hyst
|
||||
struct sx9512_reg_cap_sense_neg_filt cap_sense_neg_filt; //!< CapSense negative filter coef, negative auto compensation debounce and touch hyst
|
||||
struct sx9512_reg_cap_sense_stuck cap_sense_stuck; //!< CapSense stuck-at timer and periodic compensation timer
|
||||
struct sx9512_reg_cap_sense_frame_skip cap_sense_frame_skip; //!< CapSense frame skip setting from active and sleep
|
||||
struct sx9512_reg_cap_sense_misc cap_sense_misc; //!< CapSense sleep enable, auto compensation channels threshold, inactive BL control
|
||||
uint8_t prox_comb_chan_mask; //!< Proximity combined channel mode channel mapping
|
||||
uint8_t reserved_3c[2];
|
||||
uint8_t spo_chan_map; //!< SPO channel mapping
|
||||
uint8_t spo_level_bl[8]; //!< SPO analog output levels
|
||||
uint8_t spo_level_idle; //!< SPO analog output level for idle
|
||||
struct sx9512_reg_spo_level_prox spo_level_prox; //!< SPO analog output for proximity
|
||||
uint8_t reserved_49[2];
|
||||
struct sx9512_reg_buzzer_trigger buzzer_trigger; //!< Buzzer trigger event selection
|
||||
struct sx9512_reg_buzzer_freq buzzer_freq; //!< Buzzer duration frequency
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
struct sx9512_reg {
|
||||
struct sx9512_reg_irq_src irq_src; //!< Interrupt source
|
||||
uint8_t touch_status; //!< Touch status
|
||||
struct sx9512_reg_prox_status prox_status; //!< Proximity status
|
||||
uint8_t comp_status; //!< Compensation status
|
||||
struct sx9512_reg_nvm_ctrl nvm_ctrl; //!< NVM control
|
||||
struct sx9512_reg_nvm nvm; //!< Non-volatile memory
|
||||
uint8_t cap_sense_chan_select; //!< CapSense channel select for readback
|
||||
uint16_t cap_sense_useful_data; //!< CapSense useful data
|
||||
uint16_t cap_sense_average_data; //!< CapSense average data
|
||||
uint16_t cap_sense_diff_data; //!< CapSense diff data
|
||||
uint16_t cap_sense_comp; //!< CapSense compensation DAC value
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
struct sx9512_reg_status {
|
||||
struct sx9512_reg_irq_src irq_src; //!< Interrupt source
|
||||
uint8_t touch_status; //!< Touch status
|
||||
struct sx9512_reg_prox_status prox_status; //!< Proximity status
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
struct sx9512_touch_state {
|
||||
uint8_t state;
|
||||
uint8_t touched;
|
||||
uint8_t released;
|
||||
};
|
||||
|
||||
|
||||
int sx9512_init(const char *dev, int addr, struct sx9512_reg_nvm *nvm);
|
||||
const char *sx9512_reg_name(sx9512_reg_t reg);
|
||||
int sx9512_reg_reserved(sx9512_reg_t reg);
|
||||
int sx9512_reset(int fd);
|
||||
int sx9512_reset_restore_led_state(int fd);
|
||||
int sx9512_read_interrupt(int fd);
|
||||
int sx9512_read_buttons(int fd);
|
||||
int sx9512_read_proximity(int fd);
|
||||
int sx9512_read_status(int fd, struct sx9512_reg_status *status);
|
||||
int sx9512_read_status_cached(int fd, struct sx9512_touch_state *touch_state);
|
||||
int sx9512_reg_nvm_load(int fd);
|
||||
int sx9512_reg_nvm_store(int fd);
|
||||
int sx9512_reg_nvm_read(int fd, struct sx9512_reg_nvm *p);
|
||||
int sx9512_reg_nvm_write(int fd, struct sx9512_reg_nvm *p);
|
||||
void sx9512_reg_nvm_init(struct sx9512_reg_nvm *p);
|
||||
void sx9512_reg_nvm_init_defaults(struct sx9512_reg_nvm *p, uint8_t capsense_channels, uint8_t led_channels);
|
||||
void sx9512_reg_nvm_init_cg300(struct sx9512_reg_nvm *p);
|
||||
void sx9512_reg_nvm_init_cg301(struct sx9512_reg_nvm *p);
|
||||
void sx9512_reg_nvm_init_eg300(struct sx9512_reg_nvm *p);
|
||||
void sx9512_reg_nvm_init_dg400(struct sx9512_reg_nvm *p);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,447 +0,0 @@
|
|||
#include <syslog.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <board.h>
|
||||
#include "button.h"
|
||||
#include "led.h"
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
|
||||
#include "smbus.h"
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
#include "ucix.h"
|
||||
#include "i2c.h"
|
||||
|
||||
#include "touch_sx9512.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define SX9512_IRQ_RESET 1<<7
|
||||
#define SX9512_IRQ_TOUCH 1<<6
|
||||
#define SX9512_IRQ_RELEASE 1<<5
|
||||
#define SX9512_IRQ_NEAR 1<<4
|
||||
#define SX9512_IRQ_FAR 1<<3
|
||||
#define SX9512_IRQ_COM 1<<2
|
||||
#define SX9512_IRQ_CONV 1<<1
|
||||
|
||||
|
||||
struct i2c_reg_tab {
|
||||
char addr;
|
||||
char value;
|
||||
char range; /* if set registers starting from addr to addr+range will be set to the same value */
|
||||
};
|
||||
|
||||
struct i2c_touch{
|
||||
int dev;
|
||||
int shadow_irq;
|
||||
int shadow_touch;
|
||||
int shadow_proximity;
|
||||
int addr;
|
||||
int irq_button;
|
||||
};
|
||||
|
||||
struct led_data {
|
||||
int addr;
|
||||
led_state_t state;
|
||||
struct led_drv led;
|
||||
};
|
||||
|
||||
struct sx9512_list{
|
||||
struct list_head list;
|
||||
struct led_data *drv;
|
||||
};
|
||||
|
||||
/* holds all leds that is configured to be used. needed for reset */
|
||||
static LIST_HEAD(sx9512_leds);
|
||||
static struct i2c_touch i2c_touch_current; /* pointer to current active table */
|
||||
static int sx9512_led_set_state(struct led_drv *drv, led_state_t state);
|
||||
static led_state_t sx9512_led_get_state(struct led_drv *drv);
|
||||
static int sx9512_set_state(struct led_data *p, led_state_t state);
|
||||
extern struct uloop_timeout i2c_touch_reset_timer;
|
||||
|
||||
|
||||
/* sx9512 needs a reset every 30 minutes. to recalibrate the touch detection */
|
||||
#define I2C_RESET_TIME (1000 * 60 * 30) /* 30 min in ms */
|
||||
static void sx9512_reset_handler(struct uloop_timeout *timeout);
|
||||
struct uloop_timeout i2c_touch_reset_timer = { .cb = sx9512_reset_handler };
|
||||
|
||||
static void sx9512_reset_handler(struct uloop_timeout *timeout)
|
||||
{
|
||||
struct list_head *i;
|
||||
//do_init_tab(i2c_touch_current);
|
||||
sx9512_reset_restore_led_state(i2c_touch_current.dev);
|
||||
|
||||
list_for_each(i, &sx9512_leds) {
|
||||
struct sx9512_list *node = list_entry(i, struct sx9512_list, list);
|
||||
sx9512_set_state(node->drv, node->drv->state);
|
||||
}
|
||||
|
||||
uloop_timeout_set(&i2c_touch_reset_timer, I2C_RESET_TIME);
|
||||
}
|
||||
|
||||
/* set state regardless of previous state */
|
||||
static int sx9512_set_state(struct led_data *p, led_state_t state)
|
||||
{
|
||||
int ret;
|
||||
int bit = 1 << p->addr;
|
||||
|
||||
ret = i2c_smbus_read_byte_data(i2c_touch_current.dev, SX9512_REG_LED_MAP2);
|
||||
if (ret < 0 )
|
||||
syslog(LOG_ERR, "Could not read from i2c device, LedMap2 register\n");
|
||||
|
||||
if (state == ON)
|
||||
ret = ret | bit;
|
||||
else if (state == OFF)
|
||||
ret = ret & ~bit;
|
||||
else{
|
||||
syslog(LOG_ERR,"%s: Led %s: Set to not supported state %d\n",__func__, p->led.name, state);
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->state = state;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(i2c_touch_current.dev, SX9512_REG_LED_MAP2, ret);
|
||||
if (ret < 0 ) {
|
||||
syslog(LOG_ERR, "Could not write to i2c device, LedMap2 register\n");
|
||||
return -1;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/* set state if not same as current state */
|
||||
static int sx9512_led_set_state(struct led_drv *drv, led_state_t state)
|
||||
{
|
||||
struct led_data *p = (struct led_data *)drv->priv;
|
||||
|
||||
if (!i2c_touch_current.dev)
|
||||
return -1;
|
||||
|
||||
if (p->addr > 7){
|
||||
DBG(1,"Led %s:with address %d outside range 0-7\n",drv->name, p->addr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (state == p->state ) {
|
||||
DBG(3,"skipping set");
|
||||
return state;
|
||||
}
|
||||
|
||||
return sx9512_set_state(p, state);
|
||||
}
|
||||
|
||||
static led_state_t sx9512_led_get_state(struct led_drv *drv)
|
||||
{
|
||||
struct led_data *p = (struct led_data *)drv->priv;
|
||||
DBG(1, "state for %s", drv->name);
|
||||
return p->state;
|
||||
}
|
||||
|
||||
static struct led_drv_func led_func = {
|
||||
.set_state = sx9512_led_set_state,
|
||||
.get_state = sx9512_led_get_state,
|
||||
};
|
||||
|
||||
struct button_data {
|
||||
int addr;
|
||||
int state;
|
||||
struct button_drv button;
|
||||
};
|
||||
|
||||
void sx9512_check(void)
|
||||
{
|
||||
// DBG(1, "state for %s", drv->name);
|
||||
|
||||
int got_irq = 0;
|
||||
int ret;
|
||||
|
||||
if (!i2c_touch_current.dev)
|
||||
return;
|
||||
|
||||
if (i2c_touch_current.irq_button) {
|
||||
int button;
|
||||
button = board_ioctl( BOARD_IOCTL_GET_GPIO, 0, 0, NULL, i2c_touch_current.irq_button, 0);
|
||||
if (button == 0)
|
||||
got_irq = 1;
|
||||
}
|
||||
if ( got_irq ) {
|
||||
|
||||
ret = i2c_smbus_read_byte_data(i2c_touch_current.dev, SX9512_REG_IRQ_SRC);
|
||||
if (ret < 0 )
|
||||
syslog(LOG_ERR, "Could not read from i2c device, irq status register\n");
|
||||
i2c_touch_current.shadow_irq = ret;
|
||||
|
||||
ret = i2c_smbus_read_byte_data(i2c_touch_current.dev, SX9512_REG_TOUCH_STATUS);
|
||||
if (ret < 0 )
|
||||
syslog(LOG_ERR, "Could not read from i2c device, touch register\n");
|
||||
i2c_touch_current.shadow_touch = ret;
|
||||
|
||||
|
||||
ret = i2c_smbus_read_byte_data(i2c_touch_current.dev, SX9512_REG_PROX_STATUS);
|
||||
if (ret < 0 )
|
||||
syslog(LOG_ERR, "Could not read from i2c device, proximity register\n");
|
||||
i2c_touch_current.shadow_proximity = ret;
|
||||
}
|
||||
#if 0
|
||||
DEBUG_PRINT("%02x %02x %02x: irq ->",
|
||||
i2c_touch->shadow_irq ,
|
||||
i2c_touch->shadow_touch,
|
||||
i2c_touch->shadow_proximity);
|
||||
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_RESET )
|
||||
DEBUG_PRINT_RAW(" Reset ");
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_TOUCH )
|
||||
DEBUG_PRINT_RAW(" Touch ");
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_RELEASE )
|
||||
DEBUG_PRINT_RAW(" Release ");
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_NEAR )
|
||||
DEBUG_PRINT_RAW(" Near ");
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_FAR )
|
||||
DEBUG_PRINT_RAW(" Far ");
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_COM )
|
||||
DEBUG_PRINT_RAW(" Com ");
|
||||
if (i2c_touch->shadow_irq & SX9512_IRQ_CONV )
|
||||
DEBUG_PRINT_RAW(" Conv ");
|
||||
|
||||
DEBUG_PRINT_RAW("\n");
|
||||
#endif
|
||||
|
||||
return ;
|
||||
}
|
||||
/*
|
||||
button address 0- 7 maps to touch event 0-7
|
||||
button address 8 proximity BL0 NEAR
|
||||
button address 9 proximity BL0 FAR
|
||||
|
||||
return BUTTON_RELEASED = no action on this button
|
||||
return BUTTON_PRESSED = button pressed
|
||||
return -1 = error
|
||||
*/
|
||||
|
||||
static button_state_t sx9512_button_get_state(struct button_drv *drv)
|
||||
{
|
||||
struct button_data *p = (struct button_data *)drv->priv;
|
||||
int bit = 1 << p->addr;
|
||||
|
||||
if (!i2c_touch_current.dev)
|
||||
return -1;
|
||||
|
||||
if (p->addr < 8) {
|
||||
if ( bit & i2c_touch_current.shadow_touch ) {
|
||||
i2c_touch_current.shadow_touch = i2c_touch_current.shadow_touch & ~bit;
|
||||
return p->state = BUTTON_PRESSED;
|
||||
}
|
||||
|
||||
/* if the button was already pressed and we don't have a release irq report it as still pressed */
|
||||
if( p->state == BUTTON_PRESSED){
|
||||
if (! (i2c_touch_current.shadow_irq & SX9512_IRQ_RELEASE) ) {
|
||||
return BUTTON_PRESSED;
|
||||
}
|
||||
}
|
||||
return p->state = BUTTON_RELEASED;
|
||||
|
||||
/* proximity NEAR */
|
||||
}else if (p->addr == 8 ) {
|
||||
bit = 1<<7;
|
||||
if( i2c_touch_current.shadow_irq & SX9512_IRQ_NEAR ) {
|
||||
i2c_touch_current.shadow_irq &= ~SX9512_IRQ_NEAR;
|
||||
if ( bit & i2c_touch_current.shadow_proximity ) {
|
||||
i2c_touch_current.shadow_proximity = i2c_touch_current.shadow_proximity & ~bit;
|
||||
return p->state = BUTTON_PRESSED;
|
||||
}
|
||||
}
|
||||
return BUTTON_RELEASED;
|
||||
|
||||
/* proximity FAR */
|
||||
}else if (p->addr == 9) {
|
||||
if( i2c_touch_current.shadow_irq & SX9512_IRQ_FAR ) {
|
||||
i2c_touch_current.shadow_irq &= ~SX9512_IRQ_FAR;
|
||||
return p->state = BUTTON_PRESSED;
|
||||
}
|
||||
return BUTTON_RELEASED;
|
||||
}else {
|
||||
DBG(1,"Button address out of range %d\n",p->addr);
|
||||
return BUTTON_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
static struct button_drv_func button_func = {
|
||||
.get_state = sx9512_button_get_state,
|
||||
};
|
||||
|
||||
|
||||
static void sx9512_button_init(struct server_ctx *s_ctx)
|
||||
{
|
||||
struct ucilist *node;
|
||||
LIST_HEAD(buttons);
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"9512_buttons", "buttons", &buttons);
|
||||
list_for_each_entry(node, &buttons, list) {
|
||||
struct button_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct button_data));
|
||||
memset(data,0,sizeof(struct button_data));
|
||||
|
||||
data->button.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->button.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s){
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
data->button.func = &button_func;
|
||||
data->button.priv = data;
|
||||
|
||||
button_add(&data->button);
|
||||
}
|
||||
}
|
||||
|
||||
static void sx9512_led_init(struct server_ctx *s_ctx) {
|
||||
|
||||
LIST_HEAD(leds);
|
||||
struct ucilist *node;
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"9512_leds", "leds", &leds);
|
||||
list_for_each_entry(node,&leds,list){
|
||||
struct led_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct led_data));
|
||||
memset(data,0,sizeof(struct led_data));
|
||||
|
||||
data->led.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s) {
|
||||
data->addr = strtol(s,0,0);
|
||||
}
|
||||
|
||||
data->led.func = &led_func;
|
||||
data->led.priv = data;
|
||||
led_add(&data->led);
|
||||
|
||||
{ /* save leds in internal list, we need this for handling reset, we need to restore state */
|
||||
struct sx9512_list *ll = malloc(sizeof(struct sx9512_list));
|
||||
memset(ll, 0, sizeof( struct sx9512_list));
|
||||
ll->drv = data;
|
||||
list_add(&ll->list, &sx9512_leds);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void sx9512_handler_init(struct server_ctx *s_ctx)
|
||||
{
|
||||
char *s, *sx9512_i2c_device;
|
||||
int i, fd, sx9512_i2c_address, sx9512_irq_pin, sx9512_active_capsense_channels, sx9512_active_led_channels;
|
||||
struct sx9512_reg_nvm nvm;
|
||||
struct list_head *il;
|
||||
|
||||
if(!(sx9512_i2c_device = ucix_get_option(s_ctx->uci_ctx, "hw", "board", "sx9512_i2c_device"))) {
|
||||
DBG(0, "Error: option is missing: sx9512_i2c_device");
|
||||
return;
|
||||
}
|
||||
DBG(1, "sx9512_i2c_device = [%s]", sx9512_i2c_device);
|
||||
|
||||
if(!(s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "sx9512_i2c_address"))) {
|
||||
DBG(0, "Warning: option is missing: sx9512_i2c_address, setting to default (%02X)", SX9512_I2C_ADDRESS);
|
||||
sx9512_i2c_address = SX9512_I2C_ADDRESS;
|
||||
} else
|
||||
sx9512_i2c_address = strtol(s,0,16);
|
||||
DBG(1, "sx9512_i2c_address = [%02X]", sx9512_i2c_address);
|
||||
|
||||
if(!(s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "sx9512_irq_pin"))) {
|
||||
DBG(0, "Error: option is missing: sx9512_irq_pin");
|
||||
return;
|
||||
}
|
||||
sx9512_irq_pin = strtol(s,0,0);
|
||||
DBG(1, "sx9512_irq_pin = [%d]", sx9512_irq_pin);
|
||||
|
||||
if(!(s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "sx9512_active_capsense_channels"))) {
|
||||
DBG(0, "Error: option is missing: sx9512_active_capsense_channels");
|
||||
return;
|
||||
}
|
||||
sx9512_active_capsense_channels = strtol(s,0,16);
|
||||
DBG(1, "sx9512_active_capsense_channels = [%02X]", sx9512_active_capsense_channels);
|
||||
|
||||
if(!(s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "sx9512_active_led_channels"))) {
|
||||
DBG(0, "Error: option is missing: sx9512_active_led_channels");
|
||||
return;
|
||||
}
|
||||
sx9512_active_led_channels = strtol(s,0,16);
|
||||
DBG(1, "sx9512_active_led_channels = [%02X]", sx9512_active_led_channels);
|
||||
|
||||
sx9512_reg_nvm_init_defaults(&nvm, sx9512_active_capsense_channels, sx9512_active_led_channels);
|
||||
|
||||
if((s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", "sx9512_led_intensity"))) {
|
||||
nvm.led2_on = nvm.led1_on = strtol(s,0,16);
|
||||
DBG(1, "sx9512_led_intensity = [%02X]", nvm.led1_on);
|
||||
}
|
||||
|
||||
for(i=0;i<8;i++) {
|
||||
char tmpstr[22];
|
||||
sprintf(tmpstr, "sx9512_threshold_bl%d", i);
|
||||
if((s=ucix_get_option(s_ctx->uci_ctx, "hw", "board", tmpstr))) {
|
||||
nvm.cap_sense_thresh[i] = strtol(s,0,16);
|
||||
DBG(1, "sx9512_threshold_bl%d = [%02X]", i, nvm.cap_sense_thresh[i]);
|
||||
}
|
||||
}
|
||||
|
||||
LIST_HEAD(sx9512_init_regs);
|
||||
struct ucilist *node;
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw","sx9512_init_regs", "regs", &sx9512_init_regs);
|
||||
list_for_each_entry(node,&sx9512_init_regs,list) {
|
||||
sx9512_reg_t reg;
|
||||
uint8_t val;
|
||||
int repeat;
|
||||
reg = strtol(node->val,0,16);
|
||||
if(sx9512_reg_reserved(reg)) {
|
||||
DBG(0, "Error: invalid sx9512 reg [%02X]", reg);
|
||||
return;
|
||||
}
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw", node->val, "val");
|
||||
val = strtol(s,0,16);
|
||||
if(!(s = ucix_get_option(s_ctx->uci_ctx, "hw", node->val, "repeat")))
|
||||
repeat=1;
|
||||
else
|
||||
repeat=strtol(s,0,0);
|
||||
for(i=0;i<repeat;i++) {
|
||||
DBG(1, "sx9512_init_reg[%02X:%s=%02X]", reg, sx9512_reg_name(reg), val);
|
||||
((uint8_t *)&nvm)[reg-SX9512_REG_NVM_AREA_START] = val;
|
||||
reg++;
|
||||
}
|
||||
}
|
||||
|
||||
if((fd = sx9512_init(sx9512_i2c_device, sx9512_i2c_address, &nvm))<1)
|
||||
return;
|
||||
i2c_touch_current.dev=fd;
|
||||
i2c_touch_current.addr=sx9512_i2c_address;
|
||||
i2c_touch_current.irq_button=sx9512_irq_pin;
|
||||
|
||||
sx9512_button_init(s_ctx);
|
||||
sx9512_led_init(s_ctx);
|
||||
/* Force set of initial state for leds. */
|
||||
list_for_each(il, &sx9512_leds) {
|
||||
struct sx9512_list *node = list_entry(il, struct sx9512_list, list);
|
||||
sx9512_set_state(node->drv, node->drv->state);
|
||||
}
|
||||
/* start reset timer */
|
||||
uloop_timeout_set(&i2c_touch_reset_timer, I2C_RESET_TIME);
|
||||
}
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef TOUCH_SX9512_H
|
||||
#define TOUCH_SX9512_H
|
||||
|
||||
#include "server.h"
|
||||
#include "sx9512.h"
|
||||
|
||||
void sx9512_handler_init(struct server_ctx *);
|
||||
void sx9512_check(void);
|
||||
|
||||
#endif /* TOUCH_SX9512_H */
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
* ucix
|
||||
* Copyright (C) 2010 John Crispin <blogic@openwrt.org>
|
||||
* Copyright (C) 2010 Steven Barth <steven@midlink.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ucix.h"
|
||||
|
||||
struct uci_ptr uci_ptr;
|
||||
|
||||
int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
memset(&uci_ptr, 0, sizeof(uci_ptr));
|
||||
uci_ptr.package = p;
|
||||
uci_ptr.section = s;
|
||||
uci_ptr.option = o;
|
||||
uci_ptr.value = t;
|
||||
return uci_lookup_ptr(ctx, &uci_ptr, NULL, true);
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init(const char *config_file, int state)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
uci_set_confdir(ctx, "/etc/config");
|
||||
if(state)
|
||||
uci_set_savedir(ctx, "/var/state/");
|
||||
else
|
||||
uci_set_savedir(ctx, "/tmp/.uci/");
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
printf("%s/%s is missing or corrupt\n", ctx->confdir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init_path(const char *vpath, const char *config_file, int state)
|
||||
{
|
||||
struct uci_context *ctx;
|
||||
char buf[256];
|
||||
if(!vpath)
|
||||
return ucix_init(config_file, state);
|
||||
ctx = uci_alloc_context();
|
||||
buf[255] = '\0';
|
||||
snprintf(buf, 255, "%s", vpath);
|
||||
uci_set_confdir(ctx, buf);
|
||||
// snprintf(buf, 255, "%s%s", vpath, (state)?("/var/state"):("/tmp/.uci"));
|
||||
// uci_add_delta_path(ctx, buf);
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
printf("%s/%s is missing or corrupt\n", ctx->confdir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int ucix_get_option_list(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o, struct list_head *l)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
if(ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
return 1;
|
||||
if (!(uci_ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return 1;
|
||||
e = uci_ptr.last;
|
||||
switch (e->type)
|
||||
{
|
||||
case UCI_TYPE_OPTION:
|
||||
switch(uci_ptr.o->type) {
|
||||
case UCI_TYPE_LIST:
|
||||
uci_foreach_element(&uci_ptr.o->v.list, e)
|
||||
{
|
||||
struct ucilist *ul = malloc(sizeof(struct ucilist));
|
||||
ul->val = strdup((e->name)?(e->name):(""));
|
||||
list_add_tail(&ul->list, l);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
const char *value = NULL;
|
||||
if(ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
return NULL;
|
||||
if (!(uci_ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return NULL;
|
||||
e = uci_ptr.last;
|
||||
switch (e->type)
|
||||
{
|
||||
case UCI_TYPE_SECTION:
|
||||
value = uci_to_section(e)->type;
|
||||
break;
|
||||
case UCI_TYPE_OPTION:
|
||||
switch(uci_ptr.o->type) {
|
||||
case UCI_TYPE_STRING:
|
||||
value = uci_ptr.o->v.string;
|
||||
break;
|
||||
default:
|
||||
value = NULL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (value) ? (strdup(value)):(NULL);
|
||||
}
|
||||
|
||||
void ucix_add_list(struct uci_context *ctx, const char *p, const char *s, const char *o, struct list_head *vals)
|
||||
{
|
||||
struct list_head *q;
|
||||
list_for_each(q, vals)
|
||||
{
|
||||
struct ucilist *ul = container_of(q, struct ucilist, list);
|
||||
if(ucix_get_ptr(ctx, p, s, o, (ul->val)?(ul->val):("")))
|
||||
return;
|
||||
uci_add_list(ctx, &uci_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
||||
const char *p, const char *t,
|
||||
void (*cb)(const char*, void*), void *priv)
|
||||
{
|
||||
struct uci_element *e;
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_foreach_element(&uci_ptr.p->sections, e)
|
||||
if (!strcmp(t, uci_to_section(e)->type))
|
||||
cb(e->name, priv);
|
||||
}
|
||||
|
||||
void ucix_for_each_section_option(struct uci_context *ctx,
|
||||
const char *p, const char *s,
|
||||
void (*cb)(const char*, const char*, void*), void *priv)
|
||||
{
|
||||
struct uci_element *e;
|
||||
if(ucix_get_ptr(ctx, p, s, NULL, NULL))
|
||||
return;
|
||||
uci_foreach_element(&uci_ptr.s->options, e)
|
||||
{
|
||||
struct uci_option *o = uci_to_option(e);
|
||||
cb(o->e.name, o->v.string, priv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
* ucix
|
||||
* Copyright (C) 2010 John Crispin <blogic@openwrt.org>
|
||||
* Copyright (C) 2010 Steven Barth <steven@midlink.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _UCI_H__
|
||||
#define _UCI_H__
|
||||
#include <uci.h>
|
||||
#include <libubox/list.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef uci_to_delta
|
||||
// Support older version of uci, where this function was named
|
||||
// differently
|
||||
#define uci_add_delta_path uci_add_history_path
|
||||
#endif
|
||||
|
||||
struct ucilist {
|
||||
struct list_head list;
|
||||
char *val;
|
||||
};
|
||||
|
||||
extern struct uci_ptr uci_ptr;
|
||||
|
||||
int ucix_get_ptr(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o, const char *t);
|
||||
struct uci_context* ucix_init(const char *config_file, int state);
|
||||
struct uci_context* ucix_init_path(const char *vpath, const char *config_file, int state);
|
||||
int ucix_save_state(struct uci_context *ctx, const char *p);
|
||||
char* ucix_get_option(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o);
|
||||
int ucix_get_option_list(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o, struct list_head *l);
|
||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
||||
const char *p, const char *t,
|
||||
void (*cb)(const char*, void*), void *priv);
|
||||
void ucix_for_each_section_option(struct uci_context *ctx,
|
||||
const char *p, const char *s,
|
||||
void (*cb)(const char*, const char*, void*), void *priv);
|
||||
void ucix_add_list(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o, struct list_head *vals);
|
||||
|
||||
static inline void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
if (!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_delete(ctx, &uci_ptr);
|
||||
}
|
||||
|
||||
static inline void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
if (!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_revert(ctx, &uci_ptr);
|
||||
}
|
||||
|
||||
static inline void ucix_add_list_single(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
if (ucix_get_ptr(ctx, p, s, o, t))
|
||||
return;
|
||||
uci_add_list(ctx, &uci_ptr);
|
||||
}
|
||||
|
||||
static inline void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
if (ucix_get_ptr(ctx, p, s, o, t))
|
||||
return;
|
||||
uci_set(ctx, &uci_ptr);
|
||||
}
|
||||
|
||||
static inline void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, NULL, t))
|
||||
return;
|
||||
uci_set(ctx, &uci_ptr);
|
||||
}
|
||||
|
||||
static inline void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
|
||||
{
|
||||
char tmp[64];
|
||||
snprintf(tmp, 64, "%d", t);
|
||||
ucix_add_option(ctx, p, s, o, tmp);
|
||||
}
|
||||
|
||||
static inline void ucix_add_list_single_int(struct uci_context *ctx, const char *p, const char *s, const char *o, const int t)
|
||||
{
|
||||
char tmp[64];
|
||||
snprintf(tmp, 64, "%d", t);
|
||||
ucix_add_list_single(ctx, p, s, o, tmp);
|
||||
}
|
||||
|
||||
static inline int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def)
|
||||
{
|
||||
char *tmp = ucix_get_option(ctx, p, s, o);
|
||||
int ret = def;
|
||||
|
||||
if (tmp)
|
||||
{
|
||||
ret = atoi(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int ucix_save(struct uci_context *ctx, const char *p)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return 1;
|
||||
uci_save(ctx, uci_ptr.p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ucix_commit(struct uci_context *ctx, const char *p)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return 1;
|
||||
return uci_commit(ctx, &uci_ptr.p, false);
|
||||
}
|
||||
|
||||
static inline void ucix_cleanup(struct uci_context *ctx)
|
||||
{
|
||||
uci_free_context(ctx);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <board.h>
|
||||
#include "log.h"
|
||||
#include "server.h"
|
||||
#include "led.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define SPI_SLAVE_SELECT 1
|
||||
|
||||
struct vox_data {
|
||||
int addr;
|
||||
led_state_t state;
|
||||
int brightness;
|
||||
struct led_drv led;
|
||||
};
|
||||
|
||||
void vox_init(struct server_ctx *s_ctx);
|
||||
|
||||
static int vox_set_state(struct led_drv *drv, led_state_t state)
|
||||
{
|
||||
struct vox_data *p = (struct vox_data *)drv->priv;
|
||||
char spi_data[6] = {0,0,0,0,0,0};
|
||||
|
||||
if (p->state == state)
|
||||
return state;
|
||||
|
||||
memset(spi_data, 0, 6);
|
||||
|
||||
spi_data[0] = p->addr;
|
||||
|
||||
if (state == ON) {
|
||||
spi_data[1] = 1;
|
||||
spi_data[2] = 0x0;
|
||||
spi_data[3] = 0x0;
|
||||
spi_data[4] = 0x0;
|
||||
spi_data[4] = 0x0;
|
||||
} else if(state == PULSING) {
|
||||
spi_data[1] = 3;
|
||||
spi_data[2] = 0xa0;
|
||||
} else if(state == FLASH_SLOW) {
|
||||
spi_data[1] = 2;
|
||||
spi_data[3] = 0x95;
|
||||
} else if(state == FLASH_FAST) {
|
||||
spi_data[1] = 2;
|
||||
spi_data[3] = 0x20;
|
||||
}
|
||||
|
||||
DBG(2,"vox_set_state %x %x %x %x",spi_data[0],spi_data[1],spi_data[2],spi_data[3]);
|
||||
board_ioctl(BOARD_IOCTL_SPI_WRITE, SPI_SLAVE_SELECT, 0, spi_data, 6, 0);
|
||||
|
||||
p->state = state;
|
||||
return state;
|
||||
}
|
||||
|
||||
static led_state_t vox_get_state(struct led_drv *drv)
|
||||
{
|
||||
struct vox_data *p = (struct vox_data *)drv->priv;
|
||||
return p->state;
|
||||
}
|
||||
|
||||
/* input brightness is in %. 0-100 */
|
||||
/* internal brightness is 5 steps. 0-4 */
|
||||
/*
|
||||
step, level percent mapping.
|
||||
0 0 -> 20
|
||||
1 21 -> 40
|
||||
2 41 -> 60
|
||||
3 61 -> 80
|
||||
4 81 -> 100
|
||||
|
||||
*/
|
||||
|
||||
static int vox_set_brightness(struct led_drv *drv, int level)
|
||||
{
|
||||
struct vox_data *p = (struct vox_data *)drv->priv;
|
||||
int new = (level * 5)/101; /* really level/(101/5) */
|
||||
char spi_data[6] = {0,0,0,0,0,0};
|
||||
|
||||
if (new == p->brightness)
|
||||
return level;
|
||||
|
||||
p->brightness = new;
|
||||
|
||||
memset(spi_data, 0, 6);
|
||||
|
||||
spi_data[0] = p->addr;
|
||||
spi_data[1] = 6;
|
||||
spi_data[2] = p->brightness;
|
||||
|
||||
DBG(2,"vox_set_state %x %x %x %x",spi_data[0],spi_data[1],spi_data[2],spi_data[3]);
|
||||
board_ioctl(BOARD_IOCTL_SPI_WRITE, SPI_SLAVE_SELECT, 0, spi_data, 6, 0);
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
static int vox_get_brightness(struct led_drv *drv)
|
||||
{
|
||||
struct vox_data *p = (struct vox_data *)drv->priv;
|
||||
return p->brightness * (100/5);
|
||||
}
|
||||
|
||||
static int vox_support(struct led_drv *drv, led_state_t state)
|
||||
{
|
||||
switch (state) {
|
||||
|
||||
case OFF:
|
||||
case ON:
|
||||
case FLASH_SLOW:
|
||||
case FLASH_FAST:
|
||||
case PULSING:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct led_drv_func func = {
|
||||
.set_state = vox_set_state,
|
||||
.get_state = vox_get_state,
|
||||
.set_brightness = vox_set_brightness,
|
||||
.get_brightness = vox_get_brightness,
|
||||
.support = vox_support,
|
||||
};
|
||||
|
||||
void vox_init(struct server_ctx *s_ctx) {
|
||||
LIST_HEAD(leds);
|
||||
struct ucilist *node;
|
||||
int register_spi = 0;
|
||||
|
||||
DBG(1, "");
|
||||
|
||||
ucix_get_option_list(s_ctx->uci_ctx, "hw" ,"vox_leds", "leds", &leds);
|
||||
list_for_each_entry(node,&leds,list){
|
||||
struct vox_data *data;
|
||||
const char *s;
|
||||
|
||||
DBG(1, "value = [%s]",node->val);
|
||||
|
||||
data = malloc(sizeof(struct vox_data));
|
||||
memset(data,0,sizeof(struct vox_data));
|
||||
|
||||
data->led.name = node->val;
|
||||
|
||||
s = ucix_get_option(s_ctx->uci_ctx, "hw" , data->led.name, "addr");
|
||||
DBG(1, "addr = [%s]", s);
|
||||
if (s) {
|
||||
data->addr = strtol(s,0,0);
|
||||
}else
|
||||
syslog(LOG_ERR,"vox_led config needs addr option\n");
|
||||
|
||||
data->led.func = &func;
|
||||
data->led.priv = data;
|
||||
data->state = NEED_INIT;
|
||||
data->brightness = 4;
|
||||
led_add(&data->led);
|
||||
register_spi = 1;
|
||||
}
|
||||
|
||||
/* if config entries for vox leds exist register the spi as used. */
|
||||
if(register_spi) {
|
||||
/* arg 4 is the spi mode encoded in a string pointer */
|
||||
/* mode is decribed i/bcm963xx/shared/opensource/include/bcm963xx/bcmSpiRes.h */
|
||||
board_ioctl(BOARD_IOCTL_SPI_INIT, SPI_SLAVE_SELECT, 0, (char*)0, 0, 391000);
|
||||
board_ioctl_init();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <board.h>
|
||||
#include "gpio.h"
|
||||
|
||||
|
||||
int debug_level;
|
||||
struct termios orig_termios;
|
||||
|
||||
#define SPI_SLAVE_SELECT 1
|
||||
|
||||
void reset_terminal_mode(void);
|
||||
void set_conio_terminal_mode( void );
|
||||
int kbhit( void );
|
||||
int getch( void );
|
||||
void display(void);
|
||||
void inc(void);
|
||||
void dec(void);
|
||||
|
||||
void reset_terminal_mode( void)
|
||||
{
|
||||
tcsetattr(0, TCSANOW, &orig_termios);
|
||||
}
|
||||
|
||||
void set_conio_terminal_mode( void )
|
||||
{
|
||||
struct termios new_termios;
|
||||
|
||||
/* take two copies - one for now, one for later */
|
||||
tcgetattr(0, &orig_termios);
|
||||
memcpy(&new_termios, &orig_termios, sizeof(new_termios));
|
||||
|
||||
/* register cleanup handler, and set the new terminal mode */
|
||||
atexit(reset_terminal_mode);
|
||||
cfmakeraw(&new_termios);
|
||||
tcsetattr(0, TCSANOW, &new_termios);
|
||||
}
|
||||
|
||||
int kbhit( void )
|
||||
{
|
||||
struct timeval tv = { 0L, 0L };
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(0, &fds);
|
||||
return select(1, &fds, NULL, NULL, &tv);
|
||||
}
|
||||
|
||||
int getch( void )
|
||||
{
|
||||
int r = 0;
|
||||
int c = 0;
|
||||
if ((r = read(0, &c, sizeof(c))) < 0) {
|
||||
return r;
|
||||
} else {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
int ret = 0;
|
||||
ret |= (c >> 24) & 0x000000ff;
|
||||
ret |= (c >> 8) & 0x0000ff00;
|
||||
ret |= (c << 8) & 0x00ff0000;
|
||||
ret |= (c << 24) & 0xff000000;
|
||||
return ret;
|
||||
#else
|
||||
return c;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char spi_data [6] = {8,3,0,0,0,0};
|
||||
int pos;
|
||||
|
||||
void display(void){
|
||||
|
||||
printf("\r");
|
||||
printf("%02x %02x %02x %02x %02x %02x \r",
|
||||
spi_data[0],
|
||||
spi_data[1],
|
||||
spi_data[2],
|
||||
spi_data[3],
|
||||
spi_data[4],
|
||||
spi_data[5]
|
||||
);
|
||||
|
||||
|
||||
if (pos){
|
||||
int jump = pos/2;
|
||||
printf("\e[%dC",pos+jump);
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void inc(void){
|
||||
|
||||
int byte = pos/2;
|
||||
int nibble = pos%2;
|
||||
|
||||
int val_hi = (spi_data[byte] >> 4 ) & 0xF;
|
||||
int val_lo = spi_data[byte] & 0xF;
|
||||
|
||||
if(!nibble) {
|
||||
val_hi++;
|
||||
if(val_hi > 0xF )
|
||||
val_hi = 0xf;
|
||||
}else{
|
||||
val_lo++;
|
||||
if(val_lo > 0xF )
|
||||
val_lo = 0xf;
|
||||
}
|
||||
|
||||
spi_data[byte] = val_hi << 4 | val_lo;
|
||||
}
|
||||
|
||||
void dec(void){
|
||||
int byte = pos/2;
|
||||
int nibble = pos%2;
|
||||
|
||||
int val_hi = (spi_data[byte] >> 4 ) & 0xF;
|
||||
int val_lo = spi_data[byte] & 0xF;
|
||||
|
||||
if(!nibble) {
|
||||
val_hi--;
|
||||
if(val_hi < 0 )
|
||||
val_hi = 0;
|
||||
}else{
|
||||
val_lo--;
|
||||
if(val_lo < 0 )
|
||||
val_lo = 0;
|
||||
}
|
||||
|
||||
spi_data[byte] = val_hi << 4 | val_lo;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ch;
|
||||
|
||||
board_ioctl_init();
|
||||
/* arg 4 is the spi mode encoded in a string pointer */
|
||||
/* mode is decribed i/bcm963xx/shared/opensource/include/bcm963xx/bcmSpiRes.h */
|
||||
board_ioctl(BOARD_IOCTL_SPI_INIT, SPI_SLAVE_SELECT, 0, (char *)0, 0, 391000);
|
||||
set_conio_terminal_mode();
|
||||
fflush(stdout);
|
||||
|
||||
display();
|
||||
|
||||
while ( 'q' != (char)(ch = getch())) {
|
||||
/* right */
|
||||
if (ch == 4414235) {
|
||||
pos++;
|
||||
if (pos > 11)
|
||||
pos = 11;
|
||||
}
|
||||
/* left */
|
||||
if (ch == 4479771) {
|
||||
pos--;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
}
|
||||
/* up */
|
||||
if (ch == 4283163) {
|
||||
inc();
|
||||
}
|
||||
/* down */
|
||||
if (ch == 4348699) {
|
||||
dec();
|
||||
}
|
||||
/* enter */
|
||||
if (ch == '\r') {
|
||||
board_ioctl(BOARD_IOCTL_SPI_WRITE, SPI_SLAVE_SELECT, 0, (char*)spi_data, 6, 0);
|
||||
}
|
||||
display();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2013 Inteno
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=questd
|
||||
PKG_VERSION:=2.0.3
|
||||
PKG_RELEASE:=3
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
|
||||
BCMKERNEL_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx
|
||||
else
|
||||
BCMKERNEL_DIR:=$(BUILD_DIR)/bcmopen-consumer/bcm963xx
|
||||
endif
|
||||
export BCMKERNEL_DIR
|
||||
|
||||
define Package/questd
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+libuci +libubox +ubus +libpthread
|
||||
TITLE:=router info daemon
|
||||
endef
|
||||
|
||||
define Package/questd/description
|
||||
questd collects system and network information and presents
|
||||
this information via ubus
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Package/questd/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/tmp
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/questd $(1)/sbin/
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,questd))
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=14
|
||||
STOP=96
|
||||
|
||||
USE_PROCD=1
|
||||
NAME=questd
|
||||
PROG=/sbin/questd
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /sbin/questd
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger network wireless
|
||||
}
|
||||
|
||||
reload() {
|
||||
ubus call router reload
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
igmp snooping 2 proxy 1 lan2lan-snooping 0/0, rate-limit 0pps, priority -1
|
||||
bridge device src-dev #tags lan-tci wan-tci group mode RxGroup source reporter timeout Index ExcludPt
|
||||
br-lan eth5 eth2.1 00 0x0000 0xffffffff 0xe0027ffe EX 0xe0027ffe 0x00000000 0xc0a801f1 258 0x401e0001 -1
|
||||
br-lan eth5 eth2.1 00 0x0000 0xffffffff 0xefc3ffff EX 0xefc3ffff 0x00000000 0xc0a801f1 258 0x400e0001 -1
|
||||
br-lan eth5 eth2.1 00 0x0000 0xffffffff 0xefffffff EX 0xefffffff 0x00000000 0xc0a801f1 258 0x40070001 -1
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
CC = gcc
|
||||
CFLAGS = -g -Wall
|
||||
LOCLIBS =
|
||||
LIBS = -luci -lubus -lubox -lpthread
|
||||
OBJS = questd.o dumper.o port.o arping.o usb.o ndisc.o dslstats.o tools.o igmp.o
|
||||
SRCS = questd.c dumper.c port.c arping.c usb.c ndisc.c dslstats.c tools.c igmp.c
|
||||
LIBSRCS =
|
||||
ISRCS = questd.h
|
||||
|
||||
all: questd
|
||||
|
||||
questd: ${OBJS}
|
||||
${CC} ${LDFLAGS} ${LIBSRCS} -o questd ${OBJS} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f questd *.o
|
||||
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
/*
|
||||
* arping -- arping tool for questd
|
||||
*
|
||||
* Author: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
|
||||
* Author: Sukru Senli sukru.senli@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netpacket/packet.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "questd.h"
|
||||
|
||||
|
||||
struct in_addr src;
|
||||
struct in_addr dst;
|
||||
struct sockaddr_ll me;
|
||||
struct sockaddr_ll he;
|
||||
int sock_fd;
|
||||
|
||||
//void *mempcpy(void *dst, const void *src, size_t n);
|
||||
|
||||
static int
|
||||
send_pack(struct in_addr *src_addr, struct in_addr *dst_addr, struct sockaddr_ll *ME, struct sockaddr_ll *HE)
|
||||
{
|
||||
int err;
|
||||
unsigned char buf[256];
|
||||
struct arphdr *ah = (struct arphdr *) buf;
|
||||
unsigned char *p = (unsigned char *) (ah + 1);
|
||||
|
||||
ah->ar_hrd = htons(ARPHRD_ETHER);
|
||||
ah->ar_pro = htons(ETH_P_IP);
|
||||
ah->ar_hln = ME->sll_halen;
|
||||
ah->ar_pln = 4;
|
||||
ah->ar_op = htons(ARPOP_REQUEST);
|
||||
|
||||
p = mempcpy(p, &ME->sll_addr, ah->ar_hln);
|
||||
p = mempcpy(p, src_addr, 4);
|
||||
|
||||
p = mempcpy(p, &HE->sll_addr, ah->ar_hln);
|
||||
p = mempcpy(p, dst_addr, 4);
|
||||
|
||||
err = sendto(sock_fd, buf, p - buf, 0, (struct sockaddr *) HE, sizeof(*HE));
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool
|
||||
recv_pack(char *buf, int len, struct sockaddr_ll *FROM)
|
||||
{
|
||||
struct arphdr *ah = (struct arphdr *) buf;
|
||||
unsigned char *p = (unsigned char *) (ah + 1);
|
||||
struct in_addr src_ip, dst_ip;
|
||||
|
||||
/* Filter out wild packets */
|
||||
if (FROM->sll_pkttype != PACKET_HOST
|
||||
&& FROM->sll_pkttype != PACKET_BROADCAST
|
||||
&& FROM->sll_pkttype != PACKET_MULTICAST)
|
||||
return false;
|
||||
|
||||
/* Only these types are recognized */
|
||||
if (ah->ar_op != htons(ARPOP_REPLY))
|
||||
return false;
|
||||
|
||||
/* ARPHRD check and this darned FDDI hack here :-( */
|
||||
if (ah->ar_hrd != htons(FROM->sll_hatype)
|
||||
&& (FROM->sll_hatype != ARPHRD_FDDI || ah->ar_hrd != htons(ARPHRD_ETHER)))
|
||||
return false;
|
||||
|
||||
/* Protocol must be IP. */
|
||||
if (ah->ar_pro != htons(ETH_P_IP)
|
||||
|| (ah->ar_pln != 4)
|
||||
|| (ah->ar_hln != me.sll_halen)
|
||||
|| (len < (int)(sizeof(*ah) + 2 * (4 + ah->ar_hln))))
|
||||
return false;
|
||||
|
||||
(src_ip.s_addr) = *(uint32_t*)(p + ah->ar_hln);
|
||||
(dst_ip.s_addr) = *(uint32_t*)(p + ah->ar_hln + 4 + ah->ar_hln);
|
||||
|
||||
if (dst.s_addr != src_ip.s_addr)
|
||||
return false;
|
||||
|
||||
if ((src.s_addr != dst_ip.s_addr) || (memcmp(p + ah->ar_hln + 4, &me.sll_addr, ah->ar_hln)))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
arping(char *targetIP, char *device, int toms)
|
||||
{
|
||||
struct sockaddr_in saddr;
|
||||
struct ifreq ifr;
|
||||
int probe_fd;
|
||||
|
||||
sock_fd = socket(AF_PACKET, SOCK_DGRAM, 0);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, device, IF_NAMESIZE);
|
||||
|
||||
if (ioctl(sock_fd, SIOCGIFINDEX, &ifr, sizeof(ifr)) < 0) {
|
||||
close(sock_fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
me.sll_family = AF_PACKET;
|
||||
me.sll_ifindex = ifr.ifr_ifindex;
|
||||
me.sll_protocol = htons(ETH_P_ARP);
|
||||
bind(sock_fd, (struct sockaddr *) &me, sizeof(me));
|
||||
|
||||
socklen_t mlen = sizeof(me);
|
||||
getsockname(sock_fd, (struct sockaddr *) &me, &mlen);
|
||||
|
||||
he = me;
|
||||
memset(he.sll_addr, -1, he.sll_halen);
|
||||
|
||||
inet_pton(AF_INET, targetIP, &(dst.s_addr));
|
||||
|
||||
/* Get the sender IP address */
|
||||
probe_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
|
||||
memset(&saddr, 0, sizeof(saddr));
|
||||
saddr.sin_family = AF_INET;
|
||||
socklen_t slen = sizeof(saddr);
|
||||
saddr.sin_port = htons(1025);
|
||||
saddr.sin_addr = dst;
|
||||
connect(probe_fd, (struct sockaddr *) &saddr, sizeof(saddr));
|
||||
getsockname(probe_fd, (struct sockaddr *) &saddr, &slen);
|
||||
src = saddr.sin_addr;
|
||||
close(probe_fd);
|
||||
|
||||
send_pack(&src, &dst, &me, &he);
|
||||
|
||||
char packet[64];
|
||||
struct sockaddr_ll from;
|
||||
socklen_t alen = sizeof(from);
|
||||
bool connected = false;
|
||||
int cc = -1;
|
||||
|
||||
fd_set read_fds, write_fds, except_fds;
|
||||
FD_ZERO(&read_fds);
|
||||
FD_ZERO(&write_fds);
|
||||
FD_ZERO(&except_fds);
|
||||
FD_SET(sock_fd, &read_fds);
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = toms * 1000;
|
||||
|
||||
if (select(sock_fd + 1, &read_fds, &write_fds, &except_fds, &timeout) == 1)
|
||||
{
|
||||
cc = recvfrom(sock_fd, packet, sizeof(packet), 0, (struct sockaddr *) &from, &alen);
|
||||
}
|
||||
|
||||
if (cc >= 0)
|
||||
connected = recv_pack(packet, cc, &from);
|
||||
|
||||
close(sock_fd);
|
||||
|
||||
return connected;
|
||||
}
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
/*
|
||||
* dslstats -- collects adsl information for questd
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: martin.schroder@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "questd.h"
|
||||
|
||||
#define DSLDEBUG(...) {} //printf(__VA_ARGS__)
|
||||
|
||||
void dslstats_init(struct dsl_stats *self){
|
||||
*self = (struct dsl_stats){0};
|
||||
}
|
||||
|
||||
void dslstats_load(struct dsl_stats *self){
|
||||
FILE *fp;
|
||||
char line[128];
|
||||
char name[64];
|
||||
char sep[64];
|
||||
char arg1[64];
|
||||
char arg2[64];
|
||||
|
||||
// start with default bearer 0 (we can support more later)
|
||||
DSLBearer *bearer = &self->bearers[0];
|
||||
DSLCounters *counters = &self->counters[0];
|
||||
int done = 0;
|
||||
|
||||
if(!(fp = popen("xdslctl info --stats", "r"))) return;
|
||||
|
||||
while(!done && fgets(line, sizeof(line), fp) != NULL) {
|
||||
DSLDEBUG("LINE: %d, %s, args:%d\n", strlen(line), line, narg);
|
||||
name[0] = 0; arg1[0] = 0; arg2[0] = 0;
|
||||
remove_newline(line);
|
||||
int narg = sscanf(line, "%[^\t]%[\t ]%[^\t]%[\t]%[^\t]", name, sep, arg1, sep, arg2);
|
||||
switch(narg){
|
||||
case 0: { // sections
|
||||
if(strstr(line, "Bearer")){
|
||||
int id = 0;
|
||||
if(sscanf(strstr(line, "Bearer"), "Bearer %d", &id) > 0){
|
||||
if(id < DSLSTATS_BEARER_COUNT){
|
||||
bearer = &self->bearers[id];
|
||||
DSLDEBUG("Switching bearer: %d\n", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// it is possible to add more stats like this though
|
||||
/*
|
||||
else if(strstr(name, "Latest 15 minutes time =") == name) counters = &self->counters[DSLSTATS_COUNTERS_CURRENT_15];
|
||||
else if(strstr(name, "Previous 15 minutes time =") == name) counters = &self->counters[DSLSTATS_COUNTERS_PREVIOUS_15];
|
||||
else if(strstr(name, "Latest 1 day time =") == name) counters = &self->counters[DSLSTATS_COUNTERS_CURRENT_DAY];
|
||||
else if(strstr(name, "Previous 1 day time =") == name) counters = &self->counters[DSLSTATS_COUNTERS_PREVIOUS_DAY];
|
||||
else if(strstr(name, "Since Link time =") == name) counters = &self->counters[DSLSTATS_COUNTERS_SINCE_LINK]; */
|
||||
} break;
|
||||
case 1: { // various one liners
|
||||
if(strstr(line, "Total time =") == line) counters = &self->counters[DSLSTATS_COUNTER_TOTALS];
|
||||
else if(strstr(line, "Latest 15 minutes time =") == line) done = 1; // we stop parsing at this right now
|
||||
else if(strstr(line, "Status") == line && strlen(line) > 9) strncpy(self->status, line + 8, sizeof(self->status));
|
||||
} break;
|
||||
case 3: {
|
||||
if(strstr(name, "Link Power State") == name) strncpy(self->link_power_state, arg1, sizeof(self->link_power_state));
|
||||
else if(strstr(name, "Mode") == name) strncpy(self->mode, arg1, sizeof(self->mode));
|
||||
else if(strstr(name, "VDSL2 Profile") == name) strncpy(self->vdsl2_profile, arg1, sizeof(self->vdsl2_profile));
|
||||
else if(strstr(name, "TPS") == name) strncpy(self->traffic, arg1, sizeof(self->traffic));
|
||||
else if(strstr(name, "Trellis") == name){
|
||||
char tmp[2][64];
|
||||
if(sscanf(arg1, "U:%s /D:%s", tmp[0], tmp[1])){
|
||||
DSLDEBUG("TRELLIS: %s %s\n", tmp[0], tmp[1]);
|
||||
if(strcmp(tmp[0], "ON") == 0) self->trellis.down = 1;
|
||||
else self->trellis.down = 0;
|
||||
if(strcmp(tmp[1], "ON") == 0) self->trellis.up = 1;
|
||||
else self->trellis.up = 0;
|
||||
}
|
||||
}
|
||||
else if(strstr(name, "Line Status") == name) strncpy(self->line_status, arg1, sizeof(self->line_status));
|
||||
else if(strstr(name, "Bearer") == name){
|
||||
unsigned long id, up, down, ret;
|
||||
if((ret = sscanf(arg1, "%lu, Upstream rate = %lu Kbps, Downstream rate = %lu Kbps", &id, &up, &down)) == 3){
|
||||
if(id < DSLSTATS_BEARER_COUNT){
|
||||
bearer = &self->bearers[id];
|
||||
bearer->rate.up = up;
|
||||
bearer->rate.down = down;
|
||||
DSLDEBUG("Switching bearer: %d\n", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strstr(name, "Max") == name) {
|
||||
sscanf(arg1, "Upstream rate = %lf Kbps, Downstream rate = %lf Kbps", &bearer->max_rate.up, &bearer->max_rate.down);
|
||||
}
|
||||
DSLDEBUG("PARSED: name:%s, arg1:%s\n", name, arg1);
|
||||
} break;
|
||||
case 5: {
|
||||
if(strstr(name, "SNR") == name) {
|
||||
self->snr.down = atof(arg1);
|
||||
self->snr.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "Attn") == name){
|
||||
self->attn.down = atof(arg1);
|
||||
self->attn.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "Pwr") == name){
|
||||
self->pwr.down = atof(arg1);
|
||||
self->pwr.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "MSGc") == name){
|
||||
bearer->msgc.down = atof(arg1);
|
||||
bearer->msgc.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "B:") == name){
|
||||
bearer->b.down = atof(arg1);
|
||||
bearer->b.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "M:") == name){
|
||||
bearer->m.down = atof(arg1);
|
||||
bearer->m.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "T:") == name){
|
||||
bearer->t.down = atof(arg1);
|
||||
bearer->t.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "R:") == name){
|
||||
bearer->r.down = atof(arg1);
|
||||
bearer->r.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "S:") == name){
|
||||
bearer->s.down = atof(arg1);
|
||||
bearer->s.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "L:") == name){
|
||||
bearer->l.down = atof(arg1);
|
||||
bearer->l.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "D:") == name){
|
||||
bearer->d.down = atof(arg1);
|
||||
bearer->d.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "delay:") == name){
|
||||
bearer->delay.down = atof(arg1);
|
||||
bearer->delay.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "INP:") == name){
|
||||
bearer->inp.down = atof(arg1);
|
||||
bearer->inp.up = atof(arg2);
|
||||
}
|
||||
else if(strstr(name, "SF:") == name){
|
||||
bearer->sf.down = atoll(arg1);
|
||||
bearer->sf.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "SFErr:") == name){
|
||||
bearer->sf_err.down = atoll(arg1);
|
||||
bearer->sf_err.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "RS:") == name){
|
||||
bearer->rs.down = atoll(arg1);
|
||||
bearer->rs.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "RSCorr:") == name){
|
||||
bearer->rs_corr.down = atoll(arg1);
|
||||
bearer->rs_corr.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "RSUnCorr:") == name){
|
||||
bearer->rs_uncorr.down = atoll(arg1);
|
||||
bearer->rs_uncorr.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "HEC:") == name){
|
||||
bearer->hec.down = atoll(arg1);
|
||||
bearer->hec.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "OCD:") == name){
|
||||
bearer->ocd.down = atoll(arg1);
|
||||
bearer->ocd.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "LCD:") == name){
|
||||
bearer->lcd.down = atoll(arg1);
|
||||
bearer->lcd.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "Total Cells:") == name){
|
||||
bearer->total_cells.down = atoll(arg1);
|
||||
bearer->total_cells.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "Data Cells:") == name){
|
||||
bearer->data_cells.down = atoll(arg1);
|
||||
bearer->data_cells.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "Bit Errors:") == name){
|
||||
bearer->bit_errors.down = atoll(arg1);
|
||||
bearer->bit_errors.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "ES:") == name){
|
||||
counters->es.down = atoll(arg1);
|
||||
counters->es.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "SES:") == name){
|
||||
counters->ses.down = atoll(arg1);
|
||||
counters->ses.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "UAS:") == name){
|
||||
counters->uas.down = atoll(arg1);
|
||||
counters->uas.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "FEC:") == name){
|
||||
counters->fec.down = atoll(arg1);
|
||||
counters->fec.up = atoll(arg2);
|
||||
}
|
||||
else if(strstr(name, "CRC:") == name){
|
||||
counters->crc.down = atoll(arg1);
|
||||
counters->crc.up = atoll(arg2);
|
||||
}
|
||||
DSLDEBUG("PARSED: name:%s, arg1:%s, arg2:%s\n", name, arg1, arg2);
|
||||
} break;
|
||||
default: {
|
||||
DSLDEBUG("ERROR: line:%s, fcnt:%d, name:%s, arg1:%s, arg2:%s\n", line, narg, name, arg1, arg2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
}
|
||||
|
||||
void dslstats_free(struct dsl_stats *self){
|
||||
|
||||
}
|
||||
|
||||
void dslstats_to_blob_buffer(struct dsl_stats *self, struct blob_buf *b){
|
||||
void *t, *array, *obj;
|
||||
DSLBearer *bearer = &self->bearers[0];
|
||||
DSLCounters *counter = &self->counters[DSLSTATS_COUNTER_TOTALS];
|
||||
//dslstats_load(self);
|
||||
|
||||
t = blobmsg_open_table(b, "dslstats");
|
||||
blobmsg_add_string(b, "mode", self->mode);
|
||||
blobmsg_add_string(b, "traffic", self->traffic);
|
||||
blobmsg_add_string(b, "status", self->status);
|
||||
blobmsg_add_string(b, "link_power_state", self->link_power_state);
|
||||
blobmsg_add_string(b, "line_status", self->line_status);
|
||||
blobmsg_add_u8(b, "trellis_up", self->trellis.up);
|
||||
blobmsg_add_u8(b, "trellis_down", self->trellis.down);
|
||||
blobmsg_add_u32(b, "snr_up_x100", self->snr.up * 100);
|
||||
blobmsg_add_u32(b, "snr_down_x100", self->snr.down * 100);
|
||||
blobmsg_add_u32(b, "pwr_up_x100", self->pwr.up * 100);
|
||||
blobmsg_add_u32(b, "pwr_down_x100", self->pwr.down * 100);
|
||||
blobmsg_add_u32(b, "attn_up_x100", self->attn.up * 100);
|
||||
blobmsg_add_u32(b, "attn_down_x100", self->attn.down * 100);
|
||||
|
||||
// add bearer data (currently only one bearer)
|
||||
array = blobmsg_open_array(b, "bearers");
|
||||
obj = blobmsg_open_table(b, NULL);
|
||||
blobmsg_add_u32(b, "max_rate_up", bearer->max_rate.up);
|
||||
blobmsg_add_u32(b, "max_rate_down", bearer->max_rate.down);
|
||||
blobmsg_add_u32(b, "rate_up", bearer->rate.up);
|
||||
blobmsg_add_u32(b, "rate_down", bearer->rate.down);
|
||||
blobmsg_add_u32(b, "msgc_up", bearer->msgc.up);
|
||||
blobmsg_add_u32(b, "msgc_down", bearer->msgc.down);
|
||||
blobmsg_add_u32(b, "b_down", bearer->b.down);
|
||||
blobmsg_add_u32(b, "b_up", bearer->b.up);
|
||||
blobmsg_add_u32(b, "m_down", bearer->m.down);
|
||||
blobmsg_add_u32(b, "m_up", bearer->m.up);
|
||||
blobmsg_add_u32(b, "t_down", bearer->t.down);
|
||||
blobmsg_add_u32(b, "t_up", bearer->t.up);
|
||||
blobmsg_add_u32(b, "r_down", bearer->r.down);
|
||||
blobmsg_add_u32(b, "r_up", bearer->r.up);
|
||||
blobmsg_add_u32(b, "s_down_x10000", bearer->s.down * 10000);
|
||||
blobmsg_add_u32(b, "s_up_x10000", bearer->s.up * 10000);
|
||||
blobmsg_add_u32(b, "l_down", bearer->l.down);
|
||||
blobmsg_add_u32(b, "l_up", bearer->l.up);
|
||||
blobmsg_add_u32(b, "d_down", bearer->d.down);
|
||||
blobmsg_add_u32(b, "d_up", bearer->d.up);
|
||||
blobmsg_add_u32(b, "delay_down", bearer->delay.down);
|
||||
blobmsg_add_u32(b, "delay_up", bearer->delay.up);
|
||||
blobmsg_add_u32(b, "inp_down_x100", bearer->inp.down * 100);
|
||||
blobmsg_add_u32(b, "inp_up_x100", bearer->inp.up * 100);
|
||||
blobmsg_add_u64(b, "sf_down", bearer->sf.down);
|
||||
blobmsg_add_u64(b, "sf_up", bearer->sf.up);
|
||||
blobmsg_add_u64(b, "sf_err_down", bearer->sf_err.down);
|
||||
blobmsg_add_u64(b, "sf_err_up", bearer->sf_err.up);
|
||||
blobmsg_add_u64(b, "rs_down", bearer->rs.down);
|
||||
blobmsg_add_u64(b, "rs_up", bearer->rs.up);
|
||||
blobmsg_add_u64(b, "rs_corr_down", bearer->rs_corr.down);
|
||||
blobmsg_add_u64(b, "rs_corr_up", bearer->rs_corr.up);
|
||||
blobmsg_add_u64(b, "rs_uncorr_down", bearer->rs_uncorr.down);
|
||||
blobmsg_add_u64(b, "rs_uncorr_up", bearer->rs_uncorr.up);
|
||||
blobmsg_add_u64(b, "hec_down", bearer->hec.down);
|
||||
blobmsg_add_u64(b, "hec_up", bearer->hec.up);
|
||||
blobmsg_add_u64(b, "ocd_down", bearer->ocd.down);
|
||||
blobmsg_add_u64(b, "ocd_up", bearer->ocd.up);
|
||||
blobmsg_add_u64(b, "lcd_down", bearer->lcd.down);
|
||||
blobmsg_add_u64(b, "lcd_up", bearer->lcd.up);
|
||||
blobmsg_add_u64(b, "total_cells_down", bearer->total_cells.down);
|
||||
blobmsg_add_u64(b, "total_cells_up", bearer->total_cells.up);
|
||||
blobmsg_add_u64(b, "data_cells_down", bearer->data_cells.down);
|
||||
blobmsg_add_u64(b, "data_cells_up", bearer->data_cells.up);
|
||||
blobmsg_add_u64(b, "bit_errors_down", bearer->bit_errors.down);
|
||||
blobmsg_add_u64(b, "bit_errors_up", bearer->bit_errors.up);
|
||||
blobmsg_close_table(b, obj);
|
||||
blobmsg_close_array(b, array);
|
||||
|
||||
// add counter data (currently only totals)
|
||||
//counter = &self->counters[DSLSTATS_COUNTER_TOTALS];
|
||||
array = blobmsg_open_table(b, "counters");
|
||||
obj = blobmsg_open_table(b, "totals");
|
||||
blobmsg_add_u64(b, "fec_down", counter->fec.down);
|
||||
blobmsg_add_u64(b, "fec_up", counter->fec.up);
|
||||
blobmsg_add_u64(b, "crc_down", counter->crc.down);
|
||||
blobmsg_add_u64(b, "crc_up", counter->crc.up);
|
||||
blobmsg_add_u64(b, "es_down", counter->es.down);
|
||||
blobmsg_add_u64(b, "es_up", counter->es.up);
|
||||
blobmsg_add_u64(b, "ses_down", counter->ses.down);
|
||||
blobmsg_add_u64(b, "ses_up", counter->ses.up);
|
||||
blobmsg_add_u64(b, "uas_down", counter->uas.down);
|
||||
blobmsg_add_u64(b, "uas_up", counter->uas.up);
|
||||
blobmsg_close_table(b, obj);
|
||||
blobmsg_close_array(b, array);
|
||||
|
||||
blobmsg_close_table(b, t);
|
||||
}
|
||||
|
||||
|
||||
int dslstats_rpc(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg){
|
||||
static struct blob_buf bb;
|
||||
static struct dsl_stats dslstats;
|
||||
|
||||
dslstats_init(&dslstats);
|
||||
blob_buf_init(&bb, 0);
|
||||
|
||||
dslstats_load(&dslstats);
|
||||
dslstats_to_blob_buffer(&dslstats, &bb);
|
||||
|
||||
ubus_send_reply(ctx, req, bb.head);
|
||||
|
||||
dslstats_free(&dslstats);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* dslstats -- collects adsl information for questd
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: martin.schroder@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
enum {
|
||||
DSLSTATS_BEARER_0 = 0,
|
||||
DSLSTATS_BEARER_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
DSLSTATS_COUNTER_TOTALS,
|
||||
DSLSTATS_COUNTER_CURRENT_15,
|
||||
DSLSTATS_COUNTER_PREVIOUS_15,
|
||||
DSLSTATS_COUNTER_CURRENT_DAY,
|
||||
DSLSTATS_COUNTER_PREVIOUS_DAY,
|
||||
DSLSTATS_COUNTER_SINCE_LINK,
|
||||
DSLSTATS_COUNTER_COUNT
|
||||
};
|
||||
|
||||
typedef struct { double up; double down; } UpDown;
|
||||
typedef struct dsl_bearer {
|
||||
|
||||
UpDown max_rate;
|
||||
UpDown rate;
|
||||
UpDown msgc;
|
||||
UpDown b,m,t,r,s,l,d;
|
||||
UpDown delay;
|
||||
UpDown inp;
|
||||
UpDown sf, sf_err;
|
||||
UpDown rs, rs_corr, rs_uncorr;
|
||||
UpDown hec, ocd, lcd;
|
||||
UpDown total_cells, data_cells, bit_errors;
|
||||
|
||||
} DSLBearer;
|
||||
|
||||
typedef struct dsl_counters {
|
||||
UpDown es, ses, uas;
|
||||
UpDown fec, crc;
|
||||
} DSLCounters;
|
||||
|
||||
typedef struct dsl_stats {
|
||||
char mode[64];
|
||||
char traffic[64];
|
||||
char status[64];
|
||||
char link_power_state[64];
|
||||
char line_status[64];
|
||||
char vdsl2_profile[64];
|
||||
UpDown trellis;
|
||||
UpDown snr;
|
||||
UpDown pwr;
|
||||
UpDown attn;
|
||||
DSLBearer bearers[DSLSTATS_BEARER_COUNT];
|
||||
DSLCounters counters[DSLSTATS_COUNTER_COUNT];
|
||||
} DSLStats;
|
||||
|
||||
void dslstats_init(struct dsl_stats *self);
|
||||
void dslstats_load(struct dsl_stats *self);
|
||||
void dslstats_to_blob_buffer(struct dsl_stats *self, struct blob_buf *b);
|
||||
int dslstats_rpc(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg);
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
/*
|
||||
* dumper -- collects router device and system info for questd
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: sukru.senli@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "questd.h"
|
||||
|
||||
struct uci_context *db_ctx;
|
||||
static bool dbLoaded = false;
|
||||
static struct uci_ptr ptr;
|
||||
|
||||
void
|
||||
init_db_hw_config(void)
|
||||
{
|
||||
db_ctx = uci_alloc_context();
|
||||
uci_set_confdir(db_ctx, "/lib/db/config/");
|
||||
if(uci_load(db_ctx, "hw", NULL) == UCI_OK)
|
||||
dbLoaded = true;
|
||||
}
|
||||
|
||||
static void
|
||||
get_db_hw_value(char *opt, char **val)
|
||||
{
|
||||
memset(&ptr, 0, sizeof(ptr));
|
||||
ptr.package = "hw";
|
||||
ptr.section = "board";
|
||||
ptr.value = NULL;
|
||||
|
||||
*val = "";
|
||||
|
||||
if (!dbLoaded)
|
||||
return;
|
||||
|
||||
ptr.option = opt;
|
||||
if (uci_lookup_ptr(db_ctx, &ptr, NULL, true) != UCI_OK)
|
||||
return;
|
||||
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return;
|
||||
|
||||
if(!ptr.o->v.string)
|
||||
return;
|
||||
|
||||
*val = ptr.o->v.string;
|
||||
}
|
||||
|
||||
void
|
||||
get_jif_val(jiffy_counts_t *p_jif)
|
||||
{
|
||||
FILE *file;
|
||||
char line[128];
|
||||
int ret;
|
||||
|
||||
if ((file = fopen("/proc/stat", "r"))) {
|
||||
while(fgets(line, sizeof(line), file) != NULL)
|
||||
{
|
||||
remove_newline(line);
|
||||
ret = sscanf(line, "cpu %llu %llu %llu %llu %llu %llu %llu %llu", &p_jif->usr, &p_jif->nic, &p_jif->sys, &p_jif->idle,
|
||||
&p_jif->iowait, &p_jif->irq, &p_jif->softirq, &p_jif->steal);
|
||||
|
||||
if (ret >= 4) {
|
||||
p_jif->total = p_jif->usr + p_jif->nic + p_jif->sys + p_jif->idle
|
||||
+ p_jif->iowait + p_jif->irq + p_jif->softirq + p_jif->steal;
|
||||
|
||||
p_jif->busy = p_jif->total - p_jif->idle - p_jif->iowait;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dump_specs(Spec *spec)
|
||||
{
|
||||
char *val;
|
||||
|
||||
spec->wifi = false;
|
||||
spec->adsl = false;
|
||||
spec->vdsl = false;
|
||||
spec->voice = false;
|
||||
spec->dect = false;
|
||||
spec->vports = 0;
|
||||
spec->eports = 0;
|
||||
|
||||
get_db_hw_value("hasWifi", &val);
|
||||
if (!strcmp(val, "1")) spec->wifi = true;
|
||||
|
||||
get_db_hw_value("hasAdsl", &val);
|
||||
if (!strcmp(val, "1")) spec->adsl = true;
|
||||
|
||||
get_db_hw_value("hasVdsl", &val);
|
||||
if (!strcmp(val, "1")) spec->vdsl = true;
|
||||
|
||||
get_db_hw_value("hasVoice", &val);
|
||||
if (!strcmp(val, "1")) spec->voice = true;
|
||||
|
||||
get_db_hw_value("hasDect", &val);
|
||||
if (!strcmp(val, "1")) spec->dect = true;
|
||||
|
||||
get_db_hw_value("VoicePorts", &val);
|
||||
if (spec->voice) spec->vports = atoi(val);
|
||||
|
||||
get_db_hw_value("ethernetPorts", &val);
|
||||
spec->eports = atoi(val);
|
||||
}
|
||||
|
||||
void
|
||||
dump_keys(Key *keys)
|
||||
{
|
||||
get_db_hw_value("authKey", &keys->auth);
|
||||
get_db_hw_value("desKey", &keys->des);
|
||||
get_db_hw_value("wpaKey", &keys->wpa);
|
||||
}
|
||||
|
||||
void
|
||||
dump_static_router_info(Router *router)
|
||||
{
|
||||
get_db_hw_value("boardId", &router->boardid);
|
||||
get_db_hw_value("hardwareVersion", &router->hardware);
|
||||
get_db_hw_value("routerModel", &router->model);
|
||||
get_db_hw_value("iopVersion", &router->firmware);
|
||||
get_db_hw_value("brcmVersion", &router->brcmver);
|
||||
get_db_hw_value("filesystem", &router->filesystem);
|
||||
get_db_hw_value("socModel", &router->socmod);
|
||||
get_db_hw_value("socRevision", &router->socrev);
|
||||
get_db_hw_value("cfeVersion", &router->cfever);
|
||||
get_db_hw_value("kernelVersion", &router->kernel);
|
||||
get_db_hw_value("BaseMacAddr", &router->basemac);
|
||||
get_db_hw_value("serialNumber", &router->serialno);
|
||||
}
|
||||
|
||||
void
|
||||
dump_hostname(Router *router)
|
||||
{
|
||||
FILE *file;
|
||||
char line[64];
|
||||
char name[64];
|
||||
|
||||
strcpy(router->name, "");
|
||||
if ((file = fopen("/proc/sys/kernel/hostname", "r"))) {
|
||||
while(fgets(line, sizeof(line), file) != NULL)
|
||||
{
|
||||
remove_newline(line);
|
||||
if (sscanf(line, "%s", name) == 1)
|
||||
break;
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
strcpy(router->name, name);
|
||||
}
|
||||
|
||||
void
|
||||
dump_sysinfo(Router *router, Memory *memory)
|
||||
{
|
||||
struct sysinfo sinfo;
|
||||
long int seconds;
|
||||
int days, hours, minutes;
|
||||
|
||||
if (sysinfo(&sinfo) == 0) {
|
||||
seconds = sinfo.uptime;
|
||||
days = seconds / (60 * 60 * 24);
|
||||
seconds -= days * (60 * 60 * 24);
|
||||
hours = seconds / (60 * 60);
|
||||
seconds -= hours * (60 * 60);
|
||||
minutes = seconds / 60;
|
||||
seconds -= minutes * 60;
|
||||
sprintf(router->uptime, "%dd %dh %dm %lds", days, hours, minutes, seconds);
|
||||
|
||||
router->procs = sinfo.procs;
|
||||
|
||||
memory->total = (sinfo.totalram / 1024);
|
||||
memory->free = (sinfo.freeram / 1024);
|
||||
memory->used = ((sinfo.totalram - sinfo.freeram) / 1024);
|
||||
memory->shared = (sinfo.sharedram / 1024);
|
||||
memory->buffers = (sinfo.bufferram / 1024);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dump_cpuinfo(Router *router, jiffy_counts_t *prev_jif, jiffy_counts_t *cur_jif)
|
||||
{
|
||||
unsigned total_diff, cpu;
|
||||
|
||||
total_diff = (unsigned)(cur_jif->total - prev_jif->total);
|
||||
|
||||
if (total_diff == 0) total_diff = 1;
|
||||
|
||||
cpu = 100 * (unsigned)(cur_jif->usr - prev_jif->usr) / total_diff;
|
||||
|
||||
router->cpu = cpu;
|
||||
}
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "questd.h"
|
||||
#include "igmp.h"
|
||||
|
||||
char* convert_to_ipaddr(int ip)
|
||||
{
|
||||
struct in_addr ip_addr;
|
||||
ip_addr.s_addr = ip;
|
||||
return inet_ntoa(ip_addr);
|
||||
}
|
||||
|
||||
char* single_space(char* str){
|
||||
char *from, *to;
|
||||
int space = 0;
|
||||
from = to = str;
|
||||
while(1) {
|
||||
if(space && *from == ' ' && to[-1] == ' ') {
|
||||
++from;
|
||||
} else {
|
||||
space = (*from == ' ') ? 1 : 0;
|
||||
*to++ = *from++;
|
||||
if(!to[-1])
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg) {
|
||||
|
||||
struct blob_buf bb;
|
||||
IGMPtable table[MAX_IGMP_ENTRY];
|
||||
FILE *snptable;
|
||||
char line[256];
|
||||
int idx = 0;
|
||||
void *t, *a;
|
||||
|
||||
if ((snptable = fopen("/proc/net/igmp_snooping", "r"))) {
|
||||
while(fgets(line, sizeof(line), snptable) != NULL)
|
||||
{
|
||||
remove_newline(line);
|
||||
table[idx].exists = false;
|
||||
if(sscanf(single_space(line),"%s %s %s %s %x %x %x %s %x %x %x %d %x %d",
|
||||
table[idx].bridge, table[idx].device, table[idx].srcdev, table[idx].tags, &(table[idx].lantci), &(table[idx].wantci),
|
||||
&(table[idx].group), table[idx].mode, &(table[idx].RxGroup), &(table[idx].source), &(table[idx].reporter),
|
||||
&(table[idx].timeout), &(table[idx].Index), &(table[idx].ExcludPt)) == 14)
|
||||
{
|
||||
table[idx].exists = true;
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
fclose(snptable);
|
||||
} else
|
||||
return UBUS_STATUS_NOT_FOUND;
|
||||
|
||||
blob_buf_init(&bb, 0);
|
||||
|
||||
a = blobmsg_open_array(&bb, "table");
|
||||
for (idx = 0; idx < MAX_IGMP_ENTRY; idx++) {
|
||||
if (!table[idx].exists)
|
||||
break;
|
||||
t = blobmsg_open_table(&bb, NULL);
|
||||
blobmsg_add_string(&bb,"bridge", table[idx].bridge);
|
||||
blobmsg_add_string(&bb,"device", table[idx].device);
|
||||
blobmsg_add_string(&bb,"srcdev", table[idx].srcdev);
|
||||
blobmsg_add_string(&bb,"tags", table[idx].tags);
|
||||
blobmsg_add_u32(&bb,"lantci", table[idx].lantci);
|
||||
blobmsg_add_u32(&bb,"wantci", table[idx].wantci);
|
||||
blobmsg_add_string(&bb,"group", convert_to_ipaddr(table[idx].group));
|
||||
blobmsg_add_string(&bb,"mode", table[idx].mode);
|
||||
blobmsg_add_string(&bb,"rxgroup", convert_to_ipaddr(table[idx].RxGroup));
|
||||
blobmsg_add_string(&bb,"source", convert_to_ipaddr(table[idx].source));
|
||||
blobmsg_add_string(&bb,"reporter", convert_to_ipaddr(table[idx].reporter));
|
||||
blobmsg_add_u32(&bb,"timeout", table[idx].timeout);
|
||||
blobmsg_add_u32(&bb,"index", table[idx].Index);
|
||||
blobmsg_add_u32(&bb,"excludpt", table[idx].ExcludPt);
|
||||
blobmsg_close_table(&bb, t);
|
||||
}
|
||||
blobmsg_close_array(&bb, a);
|
||||
|
||||
ubus_send_reply(ctx, req, bb.head);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* igmp.h
|
||||
*
|
||||
* Created on: May 5, 2015
|
||||
* Author: stefan
|
||||
*/
|
||||
|
||||
#ifndef IGMP_H_
|
||||
#define IGMP_H_
|
||||
#ifndef NULL
|
||||
#define NULL ((void *) 0)
|
||||
#endif
|
||||
|
||||
#define MAX_IGMP_ENTRY 128
|
||||
|
||||
int igmp_rpc(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg);
|
||||
|
||||
|
||||
typedef struct igmp_table {
|
||||
bool exists;
|
||||
char bridge[32];
|
||||
char device[32];
|
||||
char srcdev[32];
|
||||
char tags[32];
|
||||
int lantci;
|
||||
int wantci;
|
||||
int group;
|
||||
char mode[32];
|
||||
int RxGroup;
|
||||
int source;
|
||||
int reporter;
|
||||
int timeout;
|
||||
int Index;
|
||||
int ExcludPt;
|
||||
|
||||
}IGMPtable;
|
||||
#endif /* IGMP_H_ */
|
||||
|
|
@ -1,507 +0,0 @@
|
|||
/*
|
||||
* ndisc.c - ICMPv6 neighbour discovery command line tool
|
||||
*
|
||||
* Author: Rémi Denis-Courmont
|
||||
* questd port: Sukru Senli sukru.senli@inteno.se
|
||||
*
|
||||
* Copyright © 2004-2007 Rémi Denis-Courmont.
|
||||
* This program is free software: you can redistribute and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, versions 2 of the license.
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h> /* div() */
|
||||
#include <inttypes.h> /* uint8_t */
|
||||
#include <limits.h> /* UINT_MAX */
|
||||
#include <locale.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <errno.h> /* EMFILE */
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h> /* close() */
|
||||
#include <time.h> /* clock_gettime() */
|
||||
#include <poll.h> /* poll() */
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sys/times.h> /* times() fallback */
|
||||
|
||||
#include <netdb.h> /* getaddrinfo() */
|
||||
#include <arpa/inet.h> /* inet_ntop() */
|
||||
#include <net/if.h> /* if_nametoindex() */
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/icmp6.h>
|
||||
|
||||
#ifndef IPV6_RECVHOPLIMIT
|
||||
/* Using obsolete RFC 2292 instead of RFC 3542 */
|
||||
# define IPV6_RECVHOPLIMIT IPV6_HOPLIMIT
|
||||
#endif
|
||||
|
||||
#ifndef AI_IDN
|
||||
# define AI_IDN 0
|
||||
#endif
|
||||
|
||||
enum ndisc_flags
|
||||
{
|
||||
NDISC_VERBOSE1=0x1,
|
||||
NDISC_VERBOSE2=0x2,
|
||||
NDISC_VERBOSE3=0x3,
|
||||
NDISC_VERBOSE =0x3,
|
||||
NDISC_NUMERIC =0x4,
|
||||
NDISC_SINGLE =0x8,
|
||||
};
|
||||
|
||||
#if defined (CLOCK_HIGHRES) && !defined (CLOCK_MONOTONIC)
|
||||
# define CLOCK_MONOTONIC CLOCK_HIGHRES
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
mono_gettime (struct timespec *ts)
|
||||
{
|
||||
#ifdef CLOCK_MONOTONIC
|
||||
if (clock_gettime (CLOCK_MONOTONIC, ts))
|
||||
#endif
|
||||
{
|
||||
static long freq = 0;
|
||||
if (freq == 0)
|
||||
freq = sysconf (_SC_CLK_TCK);
|
||||
|
||||
struct tms dummy;
|
||||
clock_t t = times (&dummy);
|
||||
ts->tv_sec = t / freq;
|
||||
ts->tv_nsec = (t % freq) * (1000000000 / freq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
getipv6byname (const char *name, const char *ifname, int numeric, struct sockaddr_in6 *addr)
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
hints.ai_family = PF_INET6;
|
||||
hints.ai_socktype = SOCK_DGRAM; /* dummy */
|
||||
hints.ai_flags = numeric ? AI_NUMERICHOST : 0;
|
||||
|
||||
int val = getaddrinfo (name, NULL, &hints, &res);
|
||||
if (val)
|
||||
{
|
||||
fprintf (stderr, "%s: %s\n", name, gai_strerror (val));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy (addr, res->ai_addr, sizeof (struct sockaddr_in6));
|
||||
freeaddrinfo (res);
|
||||
|
||||
val = if_nametoindex (ifname);
|
||||
if (val == 0)
|
||||
{
|
||||
perror (ifname);
|
||||
return -1;
|
||||
}
|
||||
addr->sin6_scope_id = val;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline int
|
||||
sethoplimit (int fd, int value)
|
||||
{
|
||||
return (setsockopt (fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
|
||||
&value, sizeof (value))
|
||||
|| setsockopt (fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
|
||||
&value, sizeof (value))) ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
static char MACADDR[24];
|
||||
|
||||
void
|
||||
clear_macaddr() {
|
||||
memset(MACADDR, '\0', sizeof(MACADDR));
|
||||
}
|
||||
|
||||
char *
|
||||
get_macaddr()
|
||||
{
|
||||
return MACADDR;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
printmacaddress (const uint8_t *ptr, size_t len)
|
||||
{
|
||||
char mac[4];
|
||||
while (len > 1)
|
||||
{
|
||||
sprintf(mac, "%02X:", *ptr);
|
||||
strcat(MACADDR, mac);
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
|
||||
if (len == 1) {
|
||||
sprintf(mac, "%02X", *ptr);
|
||||
strcat(MACADDR, mac);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# ifdef __linux__
|
||||
# include <sys/ioctl.h>
|
||||
# endif
|
||||
|
||||
static int
|
||||
getmacaddress (const char *ifname, uint8_t *addr)
|
||||
{
|
||||
# ifdef SIOCGIFHWADDR
|
||||
struct ifreq req;
|
||||
memset (&req, 0, sizeof (req));
|
||||
|
||||
if (((unsigned)strlen (ifname)) >= (unsigned)IFNAMSIZ)
|
||||
return -1; /* buffer overflow = local root */
|
||||
strcpy (req.ifr_name, ifname);
|
||||
|
||||
int fd = socket (AF_INET6, SOCK_DGRAM, 0);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
||||
if (ioctl (fd, SIOCGIFHWADDR, &req))
|
||||
{
|
||||
perror (ifname);
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
close (fd);
|
||||
|
||||
memcpy (addr, req.ifr_hwaddr.sa_data, 6);
|
||||
return 0;
|
||||
# else
|
||||
(void)ifname;
|
||||
(void)addr;
|
||||
return -1;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static const uint8_t nd_type_advert = ND_NEIGHBOR_ADVERT;
|
||||
static const unsigned nd_delay_ms = 1000;
|
||||
static const unsigned ndisc_default = NDISC_VERBOSE1 | NDISC_SINGLE;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct nd_neighbor_solicit hdr;
|
||||
struct nd_opt_hdr opt;
|
||||
uint8_t hw_addr[6];
|
||||
} solicit_packet;
|
||||
|
||||
|
||||
static ssize_t
|
||||
buildsol (solicit_packet *ns, struct sockaddr_in6 *tgt, const char *ifname)
|
||||
{
|
||||
/* builds ICMPv6 Neighbor Solicitation packet */
|
||||
ns->hdr.nd_ns_type = ND_NEIGHBOR_SOLICIT;
|
||||
ns->hdr.nd_ns_code = 0;
|
||||
ns->hdr.nd_ns_cksum = 0; /* computed by the kernel */
|
||||
ns->hdr.nd_ns_reserved = 0;
|
||||
memcpy (&ns->hdr.nd_ns_target, &tgt->sin6_addr, 16);
|
||||
|
||||
/* determines actual multicast destination address */
|
||||
memcpy (tgt->sin6_addr.s6_addr, "\xff\x02\x00\x00\x00\x00\x00\x00"
|
||||
"\x00\x00\x00\x01\xff", 13);
|
||||
|
||||
/* gets our own interface's link-layer address (MAC) */
|
||||
if (getmacaddress (ifname, ns->hw_addr))
|
||||
return sizeof (ns->hdr);
|
||||
|
||||
ns->opt.nd_opt_type = ND_OPT_SOURCE_LINKADDR;
|
||||
ns->opt.nd_opt_len = 1; /* 8 bytes */
|
||||
return sizeof (*ns);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
parseadv (const uint8_t *buf, size_t len, const struct sockaddr_in6 *tgt, bool verbose)
|
||||
{
|
||||
const struct nd_neighbor_advert *na =
|
||||
(const struct nd_neighbor_advert *)buf;
|
||||
const uint8_t *ptr;
|
||||
|
||||
/* checks if the packet is a Neighbor Advertisement, and
|
||||
* if the target IPv6 address is the right one */
|
||||
if ((len < sizeof (struct nd_neighbor_advert))
|
||||
|| (na->nd_na_type != ND_NEIGHBOR_ADVERT)
|
||||
|| (na->nd_na_code != 0)
|
||||
|| memcmp (&na->nd_na_target, &tgt->sin6_addr, 16))
|
||||
return -1;
|
||||
|
||||
len -= sizeof (struct nd_neighbor_advert);
|
||||
|
||||
/* looks for Target Link-layer address option */
|
||||
ptr = buf + sizeof (struct nd_neighbor_advert);
|
||||
|
||||
while (len >= 8)
|
||||
{
|
||||
uint16_t optlen;
|
||||
|
||||
optlen = ((uint16_t)(ptr[1])) << 3;
|
||||
if (optlen == 0)
|
||||
break; /* invalid length */
|
||||
|
||||
if (len < optlen) /* length > remaining bytes */
|
||||
break;
|
||||
len -= optlen;
|
||||
|
||||
|
||||
/* skips unrecognized option */
|
||||
if (ptr[0] != ND_OPT_TARGET_LINKADDR)
|
||||
{
|
||||
ptr += optlen;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Found! displays link-layer address */
|
||||
ptr += 2;
|
||||
optlen -= 2;
|
||||
if (verbose)
|
||||
fputs ("Target link-layer address: ", stdout);
|
||||
|
||||
printmacaddress (ptr, optlen);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
static ssize_t
|
||||
recvfromLL (int fd, void *buf, size_t len, int flags, struct sockaddr_in6 *addr)
|
||||
{
|
||||
char cbuf[CMSG_SPACE (sizeof (int))];
|
||||
struct iovec iov =
|
||||
{
|
||||
.iov_base = buf,
|
||||
.iov_len = len
|
||||
};
|
||||
struct msghdr hdr =
|
||||
{
|
||||
.msg_name = addr,
|
||||
.msg_namelen = sizeof (*addr),
|
||||
.msg_iov = &iov,
|
||||
.msg_iovlen = 1,
|
||||
.msg_control = cbuf,
|
||||
.msg_controllen = sizeof (cbuf)
|
||||
};
|
||||
|
||||
ssize_t val = recvmsg (fd, &hdr, flags);
|
||||
if (val == -1)
|
||||
return val;
|
||||
|
||||
/* ensures the hop limit is 255 */
|
||||
struct cmsghdr *cmsg;
|
||||
for (cmsg = CMSG_FIRSTHDR (&hdr);
|
||||
cmsg != NULL;
|
||||
cmsg = CMSG_NXTHDR (&hdr, cmsg))
|
||||
{
|
||||
if ((cmsg->cmsg_level == IPPROTO_IPV6)
|
||||
&& (cmsg->cmsg_type == IPV6_HOPLIMIT))
|
||||
{
|
||||
if (255 != *(int *)CMSG_DATA (cmsg))
|
||||
{
|
||||
// pretend to be a spurious wake-up
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
recvadv (int fd, const struct sockaddr_in6 *tgt, unsigned wait_ms, unsigned flags)
|
||||
{
|
||||
struct timespec now, end;
|
||||
unsigned responses = 0;
|
||||
|
||||
/* computes deadline time */
|
||||
mono_gettime (&now);
|
||||
{
|
||||
div_t d;
|
||||
|
||||
d = div (wait_ms, 1000);
|
||||
end.tv_sec = now.tv_sec + d.quot;
|
||||
end.tv_nsec = now.tv_nsec + (d.rem * 1000000);
|
||||
}
|
||||
|
||||
/* receive loop */
|
||||
for (;;)
|
||||
{
|
||||
/* waits for reply until deadline */
|
||||
ssize_t val = 0;
|
||||
if (end.tv_sec >= now.tv_sec)
|
||||
{
|
||||
val = (end.tv_sec - now.tv_sec) * 1000
|
||||
+ (int)((end.tv_nsec - now.tv_nsec) / 1000000);
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
}
|
||||
|
||||
val = poll (&(struct pollfd){ .fd = fd, .events = POLLIN }, 1, val);
|
||||
if (val < 0)
|
||||
break;
|
||||
|
||||
if (val == 0)
|
||||
return responses;
|
||||
|
||||
/* receives an ICMPv6 packet */
|
||||
// TODO: use interface MTU as buffer size
|
||||
union
|
||||
{
|
||||
uint8_t b[1460];
|
||||
uint64_t align;
|
||||
} buf;
|
||||
struct sockaddr_in6 addr;
|
||||
|
||||
val = recvfromLL (fd, &buf, sizeof (buf), MSG_DONTWAIT, &addr);
|
||||
if (val == -1)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
perror ("Receiving ICMPv6 packet");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* ensures the response came through the right interface */
|
||||
if (addr.sin6_scope_id
|
||||
&& (addr.sin6_scope_id != tgt->sin6_scope_id))
|
||||
continue;
|
||||
|
||||
if (parseadv (buf.b, val, tgt, (flags & NDISC_VERBOSE) != 0) == 0)
|
||||
{
|
||||
if (flags & NDISC_VERBOSE)
|
||||
{
|
||||
char str[INET6_ADDRSTRLEN];
|
||||
|
||||
if (inet_ntop (AF_INET6, &addr.sin6_addr, str,
|
||||
sizeof (str)) != NULL)
|
||||
printf (" from %s\n", str);
|
||||
}
|
||||
|
||||
if (responses < INT_MAX)
|
||||
responses++;
|
||||
|
||||
if (flags & NDISC_SINGLE)
|
||||
return 1 /* = responses */;
|
||||
}
|
||||
mono_gettime (&now);
|
||||
}
|
||||
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
bool
|
||||
ndisc (const char *name, const char *ifname, unsigned flags, unsigned retry, unsigned wait_ms)
|
||||
{
|
||||
struct sockaddr_in6 tgt;
|
||||
|
||||
int fd = socket (PF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
perror ("Raw IPv6 socket");
|
||||
return false;
|
||||
}
|
||||
|
||||
fcntl (fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
/* set ICMPv6 filter */
|
||||
{
|
||||
struct icmp6_filter f;
|
||||
|
||||
ICMP6_FILTER_SETBLOCKALL (&f);
|
||||
ICMP6_FILTER_SETPASS (nd_type_advert, &f);
|
||||
setsockopt (fd, IPPROTO_ICMPV6, ICMP6_FILTER, &f, sizeof (f));
|
||||
}
|
||||
|
||||
setsockopt (fd, SOL_SOCKET, SO_DONTROUTE, &(int){ 1 }, sizeof (int));
|
||||
|
||||
/* sets Hop-by-hop limit to 255 */
|
||||
sethoplimit (fd, 255);
|
||||
setsockopt (fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
|
||||
&(int){ 1 }, sizeof (int));
|
||||
|
||||
/* resolves target's IPv6 address */
|
||||
if (getipv6byname (name, ifname, (flags & NDISC_NUMERIC) ? 1 : 0, &tgt))
|
||||
goto error;
|
||||
else
|
||||
{
|
||||
char s[INET6_ADDRSTRLEN];
|
||||
|
||||
inet_ntop (AF_INET6, &tgt.sin6_addr, s, sizeof (s));
|
||||
if (flags & NDISC_VERBOSE)
|
||||
printf ("Soliciting %s (%s) on %s...\n", name, s, ifname);
|
||||
}
|
||||
|
||||
{
|
||||
solicit_packet packet;
|
||||
struct sockaddr_in6 dst;
|
||||
ssize_t plen;
|
||||
|
||||
memcpy (&dst, &tgt, sizeof (dst));
|
||||
plen = buildsol (&packet, &dst, ifname);
|
||||
if (plen == -1)
|
||||
goto error;
|
||||
|
||||
while (retry > 0)
|
||||
{
|
||||
/* sends a Solitication */
|
||||
if (sendto (fd, &packet, plen, 0,
|
||||
(const struct sockaddr *)&dst,
|
||||
sizeof (dst)) != plen)
|
||||
{
|
||||
//perror ("Sending ICMPv6 packet");
|
||||
goto error;
|
||||
}
|
||||
retry--;
|
||||
|
||||
/* receives an Advertisement */
|
||||
ssize_t val = recvadv (fd, &tgt, wait_ms, flags);
|
||||
if (val > 0)
|
||||
{
|
||||
close (fd);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (val == 0)
|
||||
{
|
||||
if (flags & NDISC_VERBOSE)
|
||||
puts ("Timed out.");
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
close (fd);
|
||||
if (flags & NDISC_VERBOSE)
|
||||
puts ("No response.");
|
||||
return false;
|
||||
|
||||
error:
|
||||
close (fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
/*
|
||||
* port -- collects port info for questd
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: sukru.senli@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "questd.h"
|
||||
#include <linux/if_bridge.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define CHUNK 128
|
||||
|
||||
static long
|
||||
get_port_stat(char *dev, char *stat)
|
||||
{
|
||||
FILE *in;
|
||||
char cmnd[64];
|
||||
char result[32];
|
||||
|
||||
sprintf(cmnd, "/sys/class/net/%s/statistics/%s", dev, stat);
|
||||
if ((in = fopen(cmnd, "r"))) {
|
||||
fgets(result, sizeof(result), in);
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
return atoi(result);
|
||||
}
|
||||
|
||||
void
|
||||
get_port_stats(Port *port)
|
||||
{
|
||||
port->stat.rx_bytes = get_port_stat(port->device, "rx_bytes");
|
||||
port->stat.rx_packets = get_port_stat(port->device, "rx_packets");
|
||||
port->stat.rx_errors = get_port_stat(port->device, "rx_errors");
|
||||
port->stat.tx_bytes = get_port_stat(port->device, "tx_bytes");
|
||||
port->stat.tx_packets =get_port_stat(port->device, "tx_packets");
|
||||
port->stat.tx_errors = get_port_stat(port->device, "tx_errors");
|
||||
}
|
||||
|
||||
void
|
||||
get_port_name(Port *port)
|
||||
{
|
||||
FILE *in;
|
||||
char buf[32];
|
||||
char cmnd[80];
|
||||
|
||||
sprintf(cmnd, ". /lib/network/config.sh && interfacename %s 2>/dev/null", port->device);
|
||||
if (!(in = popen(cmnd, "r")))
|
||||
exit(1);
|
||||
|
||||
fgets(buf, sizeof(buf), in);
|
||||
pclose(in);
|
||||
remove_newline(buf);
|
||||
strcpy(port->name, buf);
|
||||
|
||||
memset(cmnd, '\0', sizeof(cmnd));
|
||||
memset(buf, '\0', sizeof(buf));
|
||||
|
||||
if(!strncmp(port->device, "wl", 2)) {
|
||||
sprintf(cmnd, "wlctl -i %s ssid | awk '{print$3}' | sed 's/\"//g' 2>/dev/null", port->device);
|
||||
if (!(in = popen(cmnd, "r")))
|
||||
exit(1);
|
||||
|
||||
fgets(buf, sizeof(buf), in);
|
||||
pclose(in);
|
||||
remove_newline(buf);
|
||||
strcpy(port->ssid, buf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
get_bridge_ports(char *bridge, char **ports)
|
||||
{
|
||||
FILE *in;
|
||||
char buf[64];
|
||||
char cmnd[128];
|
||||
|
||||
*ports = "";
|
||||
|
||||
sprintf(cmnd, "brctl showbr %s | awk '{print$NF}' | grep -v interfaces | tr '\n' ' '", bridge);
|
||||
if (!(in = popen(cmnd, "r")))
|
||||
exit(1);
|
||||
|
||||
fgets(buf, sizeof(buf), in);
|
||||
pclose(in);
|
||||
*ports = strdup(buf);
|
||||
}
|
||||
|
||||
static int
|
||||
compare_fdbs(const void *_f0, const void *_f1)
|
||||
{
|
||||
const struct fdb_entry *f0 = _f0;
|
||||
const struct fdb_entry *f1 = _f1;
|
||||
|
||||
return memcmp(f0->mac_addr, f1->mac_addr, 6);
|
||||
}
|
||||
|
||||
static inline void
|
||||
copy_fdb(struct fdb_entry *ent, const struct __fdb_entry *f)
|
||||
{
|
||||
memcpy(ent->mac_addr, f->mac_addr, 6);
|
||||
ent->port_no = f->port_no;
|
||||
ent->is_local = f->is_local;
|
||||
}
|
||||
|
||||
static int
|
||||
bridge_read_fdb(const char *bridge, struct fdb_entry *fdbs, unsigned long offset, int num)
|
||||
{
|
||||
FILE *f;
|
||||
int i, n;
|
||||
struct __fdb_entry fe[num];
|
||||
char path[256];
|
||||
|
||||
snprintf(path, 256, "/sys/class/net/%s/brforward", bridge);
|
||||
f = fopen(path, "r");
|
||||
if (f) {
|
||||
fseek(f, offset*sizeof(struct __fdb_entry), SEEK_SET);
|
||||
n = fread(fe, sizeof(struct __fdb_entry), num, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
copy_fdb(fdbs+i, fe+i);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
get_clients_onport(char *bridge, int portno, char **macaddr)
|
||||
{
|
||||
int i, n;
|
||||
struct fdb_entry *fdb = NULL;
|
||||
int offset = 0;
|
||||
char tmpmac[2400];
|
||||
char mac[24];
|
||||
|
||||
*macaddr = "";
|
||||
|
||||
for(;;) {
|
||||
fdb = realloc(fdb, (offset + CHUNK) * sizeof(struct fdb_entry));
|
||||
if (!fdb) {
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
n = bridge_read_fdb(bridge, fdb+offset, offset, CHUNK);
|
||||
if (n == 0)
|
||||
break;
|
||||
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "read of forward table failed: %s\n",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
offset += n;
|
||||
}
|
||||
|
||||
qsort(fdb, offset, sizeof(struct fdb_entry), compare_fdbs);
|
||||
|
||||
for (i = 0; i < offset; i++) {
|
||||
const struct fdb_entry *f = fdb + i;
|
||||
if (f->port_no == portno && !f->is_local) {
|
||||
sprintf(mac, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", f->mac_addr[0], f->mac_addr[1], f->mac_addr[2], f->mac_addr[3], f->mac_addr[4], f->mac_addr[5]);
|
||||
strcat(tmpmac, " ");
|
||||
strcat(tmpmac, mac);
|
||||
}
|
||||
}
|
||||
*macaddr = strdup(tmpmac);
|
||||
|
||||
free(fdb);
|
||||
memset(tmpmac, '\0', sizeof(tmpmac));
|
||||
}
|
||||
2167
questd/src/questd.c
2167
questd/src/questd.c
File diff suppressed because it is too large
Load diff
|
|
@ -1,219 +0,0 @@
|
|||
//#define _GNU_SOURCE
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sys/sysinfo.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <uci.h>
|
||||
|
||||
#include <libubox/blobmsg.h>
|
||||
#include <libubox/uloop.h>
|
||||
#include <libubox/ustream.h>
|
||||
#include <libubox/utils.h>
|
||||
|
||||
#include <libubus.h>
|
||||
|
||||
#include "dslstats.h"
|
||||
#include "igmp.h"
|
||||
|
||||
#define MAX_RADIO 4
|
||||
#define MAX_VIF 8
|
||||
#define MAX_NETWORK 16
|
||||
#define MAX_CLIENT 128
|
||||
#define MAX_PORT 8
|
||||
#define MAX_USB 18
|
||||
|
||||
typedef struct {
|
||||
const char *vif;
|
||||
const char *device;
|
||||
const char *ssid;
|
||||
const char *network;
|
||||
int noise;
|
||||
} Wireless;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *band;
|
||||
int frequency;
|
||||
const char *hwmodes[6];
|
||||
int channels[16];
|
||||
const char *pcid;
|
||||
int bwcaps[4];
|
||||
bool is_ac;
|
||||
} Radio;
|
||||
|
||||
typedef struct {
|
||||
int connum;
|
||||
int idle;
|
||||
int in_network;
|
||||
long tx_bytes;
|
||||
long rx_bytes;
|
||||
int tx_rate;
|
||||
int rx_rate;
|
||||
int snr;
|
||||
} Detail;
|
||||
|
||||
typedef struct {
|
||||
bool exists;
|
||||
bool local;
|
||||
bool dhcp;
|
||||
char leaseno[24];
|
||||
char macaddr[24];
|
||||
char ipaddr[24];
|
||||
char hostname[64];
|
||||
char network[32];
|
||||
char device[32];
|
||||
bool wireless;
|
||||
char wdev[8];
|
||||
bool connected;
|
||||
} Client;
|
||||
|
||||
typedef struct {
|
||||
bool exists;
|
||||
char macaddr[24];
|
||||
char wdev[8];
|
||||
int snr;
|
||||
} Sta;
|
||||
|
||||
typedef struct {
|
||||
bool exists;
|
||||
char ip6addr[128];
|
||||
char macaddr[24];
|
||||
char hostname[64];
|
||||
char duid[64];
|
||||
char device[32];
|
||||
bool wireless;
|
||||
char wdev[8];
|
||||
bool connected;
|
||||
} Client6;
|
||||
|
||||
typedef struct {
|
||||
unsigned long rx_bytes;
|
||||
unsigned long rx_packets;
|
||||
unsigned long rx_errors;
|
||||
unsigned long tx_bytes;
|
||||
unsigned long tx_packets;
|
||||
unsigned long tx_errors;
|
||||
} Statistic;
|
||||
|
||||
typedef struct {
|
||||
char name[16];
|
||||
char ssid[32];
|
||||
char device[32];
|
||||
Statistic stat;
|
||||
Client client[MAX_CLIENT];
|
||||
} Port;
|
||||
|
||||
typedef struct {
|
||||
bool exists;
|
||||
bool is_lan;
|
||||
const char *name;
|
||||
const char *type;
|
||||
const char *proto;
|
||||
const char *ipaddr;
|
||||
const char *netmask;
|
||||
char ifname[128];
|
||||
Port port[MAX_PORT];
|
||||
bool ports_populated;
|
||||
} Network;
|
||||
|
||||
typedef struct {
|
||||
char name[64];
|
||||
char *hardware;
|
||||
char *model;
|
||||
char *boardid;
|
||||
char *firmware;
|
||||
char *brcmver;
|
||||
char *filesystem;
|
||||
char *socmod;
|
||||
char *socrev;
|
||||
char *cfever;
|
||||
char *kernel;
|
||||
char *basemac;
|
||||
char *serialno;
|
||||
char uptime[64];
|
||||
unsigned int procs;
|
||||
unsigned int cpu;
|
||||
} Router;
|
||||
|
||||
typedef struct {
|
||||
unsigned long total;
|
||||
unsigned long used;
|
||||
unsigned long free;
|
||||
unsigned long shared;
|
||||
unsigned long buffers;
|
||||
} Memory;
|
||||
|
||||
typedef struct {
|
||||
char *auth;
|
||||
char *des;
|
||||
char *wpa;
|
||||
} Key;
|
||||
|
||||
typedef struct {
|
||||
bool wifi;
|
||||
bool adsl;
|
||||
bool vdsl;
|
||||
bool voice;
|
||||
bool dect;
|
||||
int vports;
|
||||
int eports;
|
||||
} Spec;
|
||||
|
||||
typedef struct {
|
||||
char mount[64];
|
||||
char product[64];
|
||||
char no[8];
|
||||
char name[8];
|
||||
unsigned long size;
|
||||
char *device;
|
||||
char *vendor;
|
||||
char *serial;
|
||||
char *speed;
|
||||
char *maxchild;
|
||||
} USB;
|
||||
|
||||
typedef struct jiffy_counts_t {
|
||||
unsigned long long usr, nic, sys, idle;
|
||||
unsigned long long iowait, irq, softirq, steal;
|
||||
unsigned long long total;
|
||||
unsigned long long busy;
|
||||
} jiffy_counts_t;
|
||||
|
||||
struct fdb_entry
|
||||
{
|
||||
u_int8_t mac_addr[6];
|
||||
u_int16_t port_no;
|
||||
unsigned char is_local;
|
||||
};
|
||||
|
||||
void recalc_sleep_time(bool calc, int toms);
|
||||
void init_db_hw_config(void);
|
||||
bool arping(char *target, char *device, int toms);
|
||||
void remove_newline(char *buf);
|
||||
void replace_char(char *buf, char a, char b);
|
||||
void runCmd(const char *pFmt, ...);
|
||||
const char *chrCmd(const char *pFmt, ...);
|
||||
void get_jif_val(jiffy_counts_t *p_jif);
|
||||
void dump_keys(Key *keys);
|
||||
void dump_specs(Spec *spec);
|
||||
void dump_static_router_info(Router *router);
|
||||
void dump_hostname(Router *router);
|
||||
void dump_sysinfo(Router *router, Memory *memory);
|
||||
void dump_cpuinfo(Router *router, jiffy_counts_t *prev_jif, jiffy_counts_t *cur_jif);
|
||||
void get_port_name(Port *port);
|
||||
void get_port_stats(Port *port);
|
||||
void get_bridge_ports(char *network, char **ifname);
|
||||
void get_clients_onport(char *bridge, int portno, char **macaddr);
|
||||
void dump_usb_info(USB *usb, char *usbno);
|
||||
void clear_macaddr(void);
|
||||
char *get_macaddr(void);
|
||||
bool ndisc (const char *name, const char *ifname, unsigned flags, unsigned retry, unsigned wait_ms);
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "questd.h"
|
||||
|
||||
void
|
||||
remove_newline(char *buf)
|
||||
{
|
||||
int len;
|
||||
len = strlen(buf) - 1;
|
||||
if (buf[len] == '\n')
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
replace_char(char *buf, char a, char b)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while (buf[i]) {
|
||||
if (buf[i] == a)
|
||||
buf[i] = b;
|
||||
i++;
|
||||
}
|
||||
buf[i] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
runCmd(const char *pFmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char cmd[256] = {0};
|
||||
int len=0, maxLen;
|
||||
|
||||
maxLen = sizeof(cmd);
|
||||
|
||||
va_start(ap, pFmt);
|
||||
|
||||
if (len < maxLen)
|
||||
{
|
||||
maxLen -= len;
|
||||
vsnprintf(&cmd[len], maxLen, pFmt, ap);
|
||||
}
|
||||
|
||||
system(cmd);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
const char*
|
||||
chrCmd(const char *pFmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char cmd[256] = {0};
|
||||
int len=0, maxLen;
|
||||
|
||||
maxLen = sizeof(cmd);
|
||||
|
||||
va_start(ap, pFmt);
|
||||
|
||||
if (len < maxLen)
|
||||
{
|
||||
maxLen -= len;
|
||||
vsnprintf(&cmd[len], maxLen, pFmt, ap);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
FILE *pipe = 0;
|
||||
static char buffer[128] = {0};
|
||||
if ((pipe = popen(cmd, "r"))){
|
||||
fgets(buffer, sizeof(buffer), pipe);
|
||||
pclose(pipe);
|
||||
|
||||
remove_newline(buffer);
|
||||
if (strlen(buffer))
|
||||
return (const char*)buffer;
|
||||
else
|
||||
return "";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
131
questd/src/usb.c
131
questd/src/usb.c
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* usb -- collects usb info for questd
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: sukru.senli@inteno.se
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "questd.h"
|
||||
#include <string.h>
|
||||
|
||||
static void
|
||||
remove_space(char *buf)
|
||||
{
|
||||
char *newbuf = malloc(strlen(buf)+1);
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
while (buf[i]) {
|
||||
newbuf[j] = buf[i];
|
||||
if (buf[i] != ' ')
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
newbuf[j] = '\0';
|
||||
strcpy(buf, newbuf);
|
||||
free(newbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
get_usb_infos(char **val, char *usbno, char *info) {
|
||||
FILE *in;
|
||||
char cmnd[64];
|
||||
char result[32];
|
||||
|
||||
*val = "";
|
||||
|
||||
sprintf(cmnd, "/sys/bus/usb/devices/%s/%s", usbno, info);
|
||||
if ((in = fopen(cmnd, "r"))) {
|
||||
fgets(result, sizeof(result), in);
|
||||
remove_newline(result);
|
||||
fclose(in);
|
||||
*val = strdup(result);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_usb_device(char **val, char *mount) {
|
||||
FILE *mounts;
|
||||
char line[128];
|
||||
char dev[16];
|
||||
char mnt[64];
|
||||
|
||||
*val = NULL;
|
||||
|
||||
if ((mounts = fopen("/var/usbmounts", "r"))) {
|
||||
while(fgets(line, sizeof(line), mounts) != NULL)
|
||||
{
|
||||
remove_newline(line);
|
||||
if (sscanf(line, "/dev/%s /mnt/%s", dev, mnt) == 2) {
|
||||
if (!strcmp(mnt, mount) || strstr(mount, mnt)) {
|
||||
*val = strdup(dev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(mounts);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_usb_size(unsigned long *val, char *device) {
|
||||
FILE *in;
|
||||
char cmnd[64];
|
||||
char result[32];
|
||||
|
||||
*val = 0;
|
||||
|
||||
sprintf(cmnd, "/sys/class/block/%s/size", device);
|
||||
if ((in = fopen(cmnd, "r"))) {
|
||||
fgets(result, sizeof(result), in);
|
||||
remove_newline(result);
|
||||
fclose(in);
|
||||
*val = (long)(atoi(result) / 2048);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dump_usb_info(USB *usb, char *usbno)
|
||||
{
|
||||
FILE *in;
|
||||
char cmnd[64];
|
||||
char result[32];
|
||||
|
||||
sprintf(cmnd, "/sys/bus/usb/devices/%s/product", usbno);
|
||||
if ((in = fopen(cmnd, "r"))) {
|
||||
fgets(result, sizeof(result), in);
|
||||
remove_newline(result);
|
||||
fclose(in);
|
||||
|
||||
strcpy(usb->product, result);
|
||||
sprintf(usb->no, "%s", usbno);
|
||||
sprintf(usb->name, "USB%s", strndup(usbno+2, strlen(usbno)));
|
||||
get_usb_infos(&usb->vendor, usb->no, "manufacturer");
|
||||
get_usb_infos(&usb->serial, usb->no, "serial");
|
||||
//get_usb_infos(&usb->speed, usb->no, "speed");
|
||||
get_usb_infos(&usb->maxchild, usb->no, "maxchild");
|
||||
sprintf(usb->mount, "%s%s", usb->vendor, usb->serial);
|
||||
remove_space(usb->mount);
|
||||
if(!strcmp(usb->mount, usb->serial)) {
|
||||
sprintf(usb->mount, "%s%s", usb->product, usb->serial);
|
||||
remove_space(usb->mount);
|
||||
}
|
||||
get_usb_device(&usb->device, usb->mount);
|
||||
get_usb_size(&usb->size, usb->device);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.0.1
|
||||
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:teliasafety-misc.git
|
||||
else
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/teliasafety-misc.git
|
||||
endif
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=8feb071dc9c05b5580043718aaafe424ce557afe
|
||||
PKG_NAME:=teliasafety-misc
|
||||
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/teliasafety-misc
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Misc stuff for teliasafety
|
||||
URL:=
|
||||
DEPENDS:=
|
||||
endef
|
||||
|
||||
define Package/teliasafety-misc/description
|
||||
Broadcom endpoint test application
|
||||
endef
|
||||
|
||||
|
||||
define Package/teliasafety-misc/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
cp $(PKG_BUILD_DIR)/files/etc/init.d/* $(1)/etc/init.d/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,teliasafety-misc))
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME := wl-anyfi
|
||||
PKG_VERSION := 6.37.14.4803.cpe4.14L04.0-anyfi1.3
|
||||
PKG_RELEASE := 1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/wl-$(PKG_VERSION)
|
||||
|
||||
BCM_KERNEL = $(shell grep 'BCM_KERNEL_VERSION:=' $(TOPDIR)/package/bcmopen/Makefile | cut -d'=' -f2)
|
||||
|
||||
MODULES_DIR = "/lib/modules/$(BCM_KERNEL)/extra"
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/wl-anyfi
|
||||
SECTION := kernel
|
||||
SUBMENU := Proprietary BCM43xx Wi-Fi driver with Anyfi.net support
|
||||
CATEGORY := Kernel modules
|
||||
SUBMENU := Wireless Drivers
|
||||
TITLE := Proprietary BCM43xx Wi-Fi driver with Anyfi.net support
|
||||
DEPENDS := bcmkernel
|
||||
endef
|
||||
|
||||
define Package/wl-anyfi/description
|
||||
Proprietary BCM43xx WiFi driver with Anyfi.net
|
||||
support, built from precompiled kernel object files.
|
||||
|
||||
NOTE: This package is only needed until the Broadcom mainline
|
||||
driver can support Anyfi.net interfaces.
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
@echo "Nothing to do - wl-anyfi comes pre-built."
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
@echo "Nothing to do - wl-anyfi comes pre-built."
|
||||
tar xf files/wl-$(PKG_VERSION).tar.bz2 -C $(BUILD_DIR)
|
||||
cd $(PKG_BUILD_DIR) && ln -fs wl963268GW-anyfi.ko wl963268GWV-anyfi.ko
|
||||
endef
|
||||
|
||||
define Package/wl-anyfi/preinst
|
||||
#!/bin/sh
|
||||
cd $${IPKG_INSTROOT}/$(MODULES_DIR) && mv wl.ko wl-bcm.ko
|
||||
endef
|
||||
|
||||
define Package/wl-anyfi/postrm
|
||||
#!/bin/sh
|
||||
cd $${IPKG_INSTROOT}/$(MODULES_DIR) && mv wl-bcm.ko wl.ko
|
||||
endef
|
||||
|
||||
define Package/wl-anyfi/install
|
||||
$(INSTALL_DIR) $(1)/$(MODULES_DIR)
|
||||
cp $(PKG_BUILD_DIR)/wl$(CONFIG_BCM_KERNEL_PROFILE)-anyfi.ko $(1)/$(MODULES_DIR)/wl.ko
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,wl-anyfi))
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue