| # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Run the CH7036 HDMI monitor" |
| author "chromium-os-dev@chromium.org" |
| |
| start on starting boot-services |
| stop on stopping boot-services |
| |
| # sadly, these can't reference each other. |
| env DATA_DIR=/home/chronos |
| env LOGBASE=/var/log/ch7036_monitor |
| env RUNDIR=/var/run/chrontel |
| env RUNFILES="forced_mute" |
| env XAUTHORITY=/home/chronos/.Xauthority |
| env DISPLAY=:0.0 |
| # keep these consistent, make second empty for pure ch7036 detection |
| # this is hardware specific for tigerpoint gpio15 |
| # TODO(mdhayter) use board type or ebuild magic to select |
| env HPDGPIO=207 |
| env GPIOFLAG=-g/sys/class/gpio/gpio207/value |
| env I2C=/dev/i2c-chrontel |
| # might be overridden by --uid parameter in /sbin/session_manager_setup.sh |
| env USER_ID=1000 |
| |
| respawn |
| |
| script |
| |
| # Define some max. Don't need that many for debugging. |
| local max_logs=5 |
| |
| # All logs are tagged with the date. |
| local log_tag=`date +%Y%m%d-%H%M%S` |
| local log_count=`ls -t "$LOGBASE"* | wc -l` |
| |
| # Don't allow logs to grow past max log count. |
| if [ $log_count -ge $max_logs ] ; then |
| local oldest_log=`ls -rt "$LOGBASE"* | head -1` |
| rm "$oldest_log" |
| fi |
| exec /usr/bin/ch7036_monitor -v -d $I2C $GPIOFLAG >> "$LOGBASE.$log_tag" 2>&1 |
| |
| end script |
| |
| # Scripts terminate on command fail |
| # Should not actually start if anything in here fails |
| # Note you get an error if you try to re-export a gpio |
| pre-start script |
| echo "No HDMI support" > /var/log/hdmi_edid.log |
| if [ ! -d $RUNDIR ] ; then |
| mkdir $RUNDIR |
| else |
| for name in $RUNFILES ; do |
| if [ -e $RUNDIR/$name ] ; then |
| rm $RUNDIR/$name |
| fi |
| done |
| fi |
| test -d $RUNDIR |
| test -e /usr/bin/ch7036_monitor |
| /sbin/modprobe i2c-dev |
| /sbin/modprobe i2c-i801 |
| /sbin/modprobe nm10_gpio |
| if [ ! -e /sys/class/gpio/gpio$HPDGPIO ] ; then |
| echo $HPDGPIO > /sys/class/gpio/export |
| fi |
| dv="i2c-unknown" |
| # Find the I2C bus that may contain the CH7036 |
| # on Tigerpoint look for an adapter with a name of the form |
| # SMBus I801 adapter at XXXX |
| # Note: requires the explicit modprobe of i2c-i801 above to in /sys in time |
| for x in /sys/class/i2c-adapter/*/name |
| do |
| y=`cat $x` |
| if [ "${y% I801 adapter*}" = "SMBus" ] ; then dv=$x; fi |
| done |
| dv=/dev/${dv##/*er/} |
| # Don't see a way to export this info to the main script |
| # So create a symlink to the device that can be used |
| ln -sf ${dv%/name} $I2C |
| echo Made symlink ${dv%/name} $I2C >> /tmp/chprobe |
| /usr/bin/ch7036_monitor -p -d $I2C -v >> /tmp/chprobe 2>&1 |
| end script |
| |
| post-stop script |
| if [ -d $RUNDIR ] ; then |
| for name in $RUNFILES ; do |
| if [ -e $RUNDIR/$name ] ; then |
| rm $RUNDIR/$name |
| fi |
| done |
| fi |
| end script |