summaryrefslogtreecommitdiffstats
path: root/scripts/rc.setup
blob: 1cbeabc89f090dca99819354b88e757cc85253a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/zsh

# this files initializes ivtv devices found
# used inside ivysync.dyne module for initialisation
# part of dyne:bolic GNU/Linux
# GNU GPL v3 2006-2009 - Denis Jaromil Roio

source /lib/dyne/utils.sh

PATH=$PATH:/opt/$1/bin
HOME=/root

MOVIE=/opt/$1/firmware/v4l-cx2341x-init.mpg


notice "Initializing IVTV devices"

act "installing firmware"
cp -ra /opt/$1/firmware/* /usr/lib/hotplug/firmware

act "loading kernel module"
loadmod videodev
loadmod tveeprom
loadmod v4l1_compat
loadmod i2c_algo_bit
loadmod cx2341x
insmod /opt/$1/kernel/ivtv.ko

act "detecting devices"


#for i in 1 2 3 4; do
#  DEV="/dev/video`bc<<<$i+15`"
#  if [ -w "$DEV" ]; then
#    # kick the output devices
#    cat $MOVIE > "$DEV" & \
#        > /dev/null 2>&1
#  fi
#done

sync
sleep 1
sync

#for pids in `ps ax|grep "$MOVIE"|awk '{print $1}'`; do
#  kill $pids > /dev/null 2>&1
#  sync
#done

# blank the screens
ivtvfbctl /dev/fb0 --globalalpha=on --localalpha=off --alpha 0
	
sync
sleep 1
sync

# play test mpeg2
for i in 1 2 3 4; do
  DEV="/dev/video`bc<<<$i+15`"
  if [ -w "$DEV" ]; then
    echo "    Video syncstarter device $i initialized"
    chmod 666 "$DEV"
#    cat $MOVIE > "$DEV" &
  fi
done

sync

# setup input encoding
### echo "Setting up video in devices 0, 1 & 2..."
# -u 0: PAL
# -f width=720,height=576(PAL)480(NTSC)
# -p 0: tv-tuner input
# -l 0: s-video and composite output
# -c bitrate=8000000,bitrate_peak=16000000
# -c stream_type=<#>
# see ivtv.h IVTV_STREAM_* types (try 10 for DVD, or 0 for PS)

act "setting up devices for PAL output"
for i in 0 1 2 3; do
  DEV="/dev/video${i}"
  if [ -w "$DEV" ]; then

    ivtvctl -d "$DEV" -p 0 -u 0 -l 0 -f width=720,height=576 \
     -c bitrate=8000000,bitrate_peak=9000000,stream_type=10

    sync

  fi
done

action=`get_config ivysync`

##################################
############## run in single mode

if [ "$action" = "run" ]; then
  # setup $HOME to where we have saved the .ivysync playlists
  HOME=/root
  # loop indefinitely
  while true; do

    sync

    ivysync-nox -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19 &

    sleep 5

    killall ivysync-nox

    sleep 10

    ivysync-nox -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19

  done
  # if loop ends then reboot
  reboot
fi

##################################
############## run in network mode
if [ "`expr substr $action 1 3`" = "net" ]; then

   while true; do

	net="`echo $action | cut -d: -f2`"
	if [ "`echo $action|cut -d: -f3`" = "master" ]; then
		master=true
	fi

	# launches master 
	if [ "$master" = "true" ]; then
		/root/offer-handshake.sh $net
	else
		/root/listen-handshake.sh $net
	fi

	sync

	ivysync-udp -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19 &

	sleep 3

	if [ "$master" = "true" ]; then udpbroadcast 255.255.255.255 15500 a; fi

	sleep 5

	killall ivysync-udp

	sleep 5

	if [ "$master" = "true" ]; then
		(sleep 5; udpbroadcast 255.255.255.255 15500 a )&
	fi

	ivysync-udp -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19

   done
   # if loop ends then reboot
   reboot

fi