eventlircd: seperate udev rules and scripts and move to package 'lirc'

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2014-03-08 02:40:54 +01:00
parent 3a0b0544d8
commit 07a6125d1e
6 changed files with 157 additions and 20 deletions

View File

@ -38,6 +38,7 @@ post_makeinstall_target() {
# install our own evmap files and udev rules
rm -rf $INSTALL/etc/eventlircd.d
rm -rf $INSTALL/usr/lib/udev/rules.d
rm -rf $INSTALL/usr/lib/udev/lircd_helper
mkdir -p $INSTALL/etc/eventlircd.d
cp $PKG_DIR/evmap/*.evmap $INSTALL/etc/eventlircd.d

View File

@ -1,19 +0,0 @@
diff --git a/udev/lircd_helper.in b/udev/lircd_helper.in
index f580cc6..d4d7f3f 100644
--- a/udev/lircd_helper.in
+++ b/udev/lircd_helper.in
@@ -41,7 +41,13 @@
daemon="${daemon} --uinput"
daemon="${daemon} --output=@localstatedir@/run/lirc/lircd-${devname_instance}"
daemon="${daemon} --pidfile=@localstatedir@/run/lirc/lircd-${devname_instance}.pid"
- daemon="${daemon} ${lircd_conf}"
+ if test -e "/storage/.config/lircd.conf" ; then
+ daemon="${daemon} /storage/.config/lircd.conf"
+ elif test -e "${lircd_conf}" ; then
+ daemon="${daemon} ${lircd_conf}"
+ else
+ exit 1
+ fi
${daemon}
for devlink in ${DEVLINKS} ; do
devlink_instance=`echo ${devlink} | /bin/sed -e 's/\/\+/~/g' -e 's/^~dev~//'`

View File

@ -44,7 +44,7 @@ PKG_CONFIGURE_OPTS_TARGET="ac_cv_path_LIBUSB_CONFIG= /
if [ "$DEBUG" = yes ]; then
PKG_CONFIGURE_OPTS_TARGET="$PKG_CONFIGURE_OPTS_TARGET --enable-debug"
else
PKG_CONFIGURE_OPTS_TARGET="$PKG_CONFIGURE_OPTS_TARGET --disable-debug"
PKG_CONFIGURE_OPTS_TARGET="$PKG_CONFIGURE_OPTS_TARGET --enable-debug"
fi
pre_make_target() {
@ -57,4 +57,8 @@ post_makeinstall_target() {
mkdir -p $INSTALL/etc/lirc
cp $PKG_DIR/config/lircd.conf.xbox $INSTALL/etc/lirc
cp $PKG_DIR/config/lircd.conf.rpi $INSTALL/etc/lirc
mkdir -p $INSTALL/usr/lib/udev
cp $PKG_DIR/scripts/lircd_helper $INSTALL/usr/lib/udev
cp $PKG_DIR/scripts/lircd_wakeup_enable $INSTALL/usr/lib/udev
}

View File

@ -0,0 +1,74 @@
#!/bin/sh
################################################################################
# lircd_helper
#
# This script can be used by udev to start or stop lircd when a remote control
# device is added or removed.
#
# lircd_helper configures lircd to output using a uinput event device so that
# eventlircd can aggregate the outputs into a single lircd socket.
#
# lircd_helper configures lircd to use an lircd socket name that is derived
# from the device name. In addition, lircd_helper creates symbolic links to this
# lircd socket that are derived from the device symbolic links. You can use this
# socket and the symbolic link to this socket when using commands such as
# irsend.
#
# lircd_helper understands two lircd_helper specific device properites set
# using ENV{} and passed as environment variables:
# lircd_driver:
# Used to tell lircd_helper the name of the lircd driver.
# lircd_conf:
# Used to tell lircd_helper the path to the lircd.conf file to use.
################################################################################
case "${ACTION}" in
add)
if test "x${lircd_driver}" = "x" ; then
exit 1;
fi
if test "x${lircd_conf}" = "x" ; then
exit 1;
fi
if test ! -e '/run/lirc' ; then
mkdir -p '/run/lirc'
fi
devname_instance=`echo ${DEVNAME} | sed -e 's/\/\+/~/g' -e 's/^~dev~//'`
if test ! -e "/run/lirc/lircd-${devname_instance}.pid" ; then
daemon='/usr/sbin/lircd'
daemon="${daemon} --driver=${lircd_driver}"
daemon="${daemon} --device=${DEVNAME}"
daemon="${daemon} --uinput"
daemon="${daemon} --output=/run/lirc/lircd-${devname_instance}"
daemon="${daemon} --pidfile=/run/lirc/lircd-${devname_instance}.pid"
if test -e "/storage/.config/lircd.conf" ; then
daemon="${daemon} /storage/.config/lircd.conf"
elif test -e "${lircd_conf}" ; then
daemon="${daemon} ${lircd_conf}"
else
exit 1
fi
${daemon}
for devlink in ${DEVLINKS} ; do
devlink_instance=`echo ${devlink} | /bin/sed -e 's/\/\+/~/g' -e 's/^~dev~//'`
rm -f "/run/lirc/lircd-${devlink_instance}"
ln -s "lircd-${devname_instance}" "/run/lirc/lircd-${devlink_instance}"
done
fi
;;
remove)
instance=`echo $DEVNAME | sed -e 's/\/\+/~/g' -e 's/^~dev~//'`
if test -e "/run/lirc/lircd-${instance}.pid" ; then
pid=`cat /run/lirc/lircd-${instance}.pid`
if test ! "x${pid}" = "x" ; then
kill ${pid}
fi
for devlink in ${DEVLINKS} ; do
devlink_instance=`echo ${devlink} | sed -e 's/\/\+/~/g' -e 's/^~dev~//'`
rm -f "/run/lirc/lircd-${devlink_instance}"
done
fi
;;
esac
exit 0

View File

@ -0,0 +1,17 @@
#!/bin/sh
################################################################################
# wakeup_enable
################################################################################
devpath=`readlink -f "/sys/${DEVPATH}"`
while echo "${devpath}" | grep -q '^/sys/devices/' > /dev/null 2>&1 ; do
if test -e "${devpath}/power/wakeup" ; then
state=`cat "${devpath}/power/wakeup"`
if test "x${state}" = "xdisabled" ; then
echo "enabled" > "${devpath}/power/wakeup"
fi
fi
devpath=`dirname "${devpath}"`
done
exit 0

View File

@ -0,0 +1,60 @@
################################################################################
# An example udev rules file for lircd.
################################################################################
# lircd_helper only does something for "add" and "remove" actions.
ACTION!="add|remove", GOTO="end"
KERNEL=="hiddev[0-9]*", SUBSYSTEM=="usb", SUBSYSTEMS=="usb", GOTO="begin"
KERNEL=="ttyACM[0-9]*", SUBSYSTEM=="tty", SUBSYSTEMS=="usb", GOTO="begin"
KERNEL=="lirc[0-9]*", SUBSYSTEM=="lirc", SUBSYSTEMS=="i2c", GOTO="begin"
KERNEL=="lirc[0-9]*", SUBSYSTEM=="lirc", SUBSYSTEMS=="usb", GOTO="begin"
KERNEL=="lirc[0-9]*", SUBSYSTEM=="lirc", SUBSYSTEMS=="platform", GOTO="begin"
KERNEL=="lirc[0-9]*", SUBSYSTEM=="lirc", SUBSYSTEMS=="pnp", GOTO="begin"
GOTO="end"
LABEL="begin"
#-------------------------------------------------------------------------------
# Ask lircd_helper to lirc devices.
#-------------------------------------------------------------------------------
SUBSYSTEM=="lirc", \
ENV{lircd_driver}="default", \
ENV{lircd_conf}="/etc/lirc/lircd.conf"
### Microsoft Xbox DVD dongle
SUBSYSTEM=="lirc", DRIVERS=="lirc_xbox", \
ENV{lircd_driver}="default", \
ENV{lircd_conf}="/etc/lirc/lircd.conf.xbox"
### RPi GPIO IR Receiver
SUBSYSTEM=="lirc", DRIVERS=="lirc_rpi", \
ENV{lircd_driver}="default", \
ENV{lircd_conf}="/etc/lirc/lircd.conf.rpi"
#-------------------------------------------------------------------------------
# Ask lircd_helper to handle USB devices that do not show up as lirc devices
# and are supported by lircd. Remote controls that are USB HID devices that show
# up as event devices are not included as as they are handled by eventlircd.
#-------------------------------------------------------------------------------
SUBSYSTEMS=="usb", GOTO="begin-usb"
GOTO="end-usb"
LABEL="begin-usb"
ENV{ID_USB_INTERFACES}=="", IMPORT{builtin}="usb_id"
ENV{ID_VENDOR_ID}=="04d8", ENV{ID_MODEL_ID}=="fd08", \
ENV{lircd_driver}="usb_irtoy", \
ENV{lircd_conf}="/storage/.config/lircd.conf"
ENV{ID_VENDOR_ID}=="0fe9", ENV{ID_MODEL_ID}=="9010", \
ENV{lircd_driver}="dvico", \
ENV{lircd_conf}="/etc/lirc/lircd.conf"
# Enable wake-on-usb for the USB remotes.
ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", RUN+="lircd_wakeup_enable"
LABEL="end-usb"
ENV{lircd_driver}=="?*", ENV{lircd_conf}=="?*", RUN+="lircd_helper"
LABEL="end"