#!/bin/sh

export LD_LIBRARY_PATH=/tmp/lib:$LD_LIBRARY_PATH:

cd /tmp/

chmod 777 web/images/*
chmod 777 web/css/*
chmod 777 web/js/*
chmod 777 web/*
chmod 777 ko/extdrv/*
chmod 777 ko/*
chmod 777 lib/*
chmod 777 *
chmod 777 nginx/sbin/*
chmod 777 samba/bin/*

edid_config=$(cat /box/box.ini | grep 'edid_index:')
edid=${edid_config:11:1}
edid_size=`echo "$edid" | wc -c`
if [ "$edid_size" = "2" ]
then
	cp /tmp/edid/$edid.* /tmp/edid.bin
	echo edid is index $edid
fi

cd /tmp/ko
./load3559av100_multicore -i

#I2S

himm 0x1F0000FC 0x1E02
himm 0x1F000100 0x1E02
himm 0x1F000104 0x1D02
himm 0x1F000108 0x1402
himm 0x1F00010C 0x1D02

#VI0

himm 0x1F001084 0x14f3 #vi0_clk

himm 0x1F001088 0x14f3 #vi0_dat7
himm 0x1F00108C 0x14f3 #vi0_dat6
himm 0x1F001090 0x14f3 #vi0_dat5
himm 0x1F001094 0x14f3 #vi0_dat4
himm 0x1F001098 0x14f3 #vi0_dat3
himm 0x1F00109c 0x14f3 #vi0_dat2
himm 0x1F0010a0 0x14f3 #vi0_dat1
himm 0x1F0010a4 0x14f3 #vi0_dat0

himm 0x1F0010a8 0x14f3 #vi0_dat15
himm 0x1F0010ac 0x14f3 #vi0_dat14
himm 0x1F0010b0 0x14f3 #vi0_dat13
himm 0x1F0010b4 0x14f3 #vi0_dat12
himm 0x1F0010b8 0x14f3 #vi0_dat11
himm 0x1F0010bc 0x14f3 #vi0_dat10
himm 0x1F0010c0 0x14f3 #vi0_dat9
himm 0x1F0010c4 0x14f3 #vi0_dat8

#GPIO

himm 0x1F00106C 0x1800 #GPIO12_2 RECORD BUTTON
himm 0x1F001070 0x0040 #GPIO12_3 RECORD LED
himm 0x1F001074 0x0040 #GPIO12_4
himm 0x1F001078 0x0040 #GPIO12_5
himm 0x1F00107C 0x0040 #GPIO12_6
himm 0x1F001080 0x0040 #GPIO12_7

himm 0x1214C400 0xFB #GPIO12 DIR

himm 0x1214C020 0x8;  #GPIO12_3 LOW RECORD
himm 0x1214C040 0; #GPIO12_4 LOW POWER
himm 0x1214C080 0x20; #GPIO12_5 LOW LAN
himm 0x1214C100 0x40; #GPIO12_6 LOW HDMI
himm 0x1214C200 0x80; #GPIO12_7 LOW WIFI

himm 0x1F0010E8 0x1C00 #GPIO0_2 RESET

#himm 0x12140010
#himm 0x1214C010

himm 0x1F000020 0x0040 #GPIO0_5 FPGA RESET
himm 0x12145400 0x1 #GPIO5 DIR
himm 0x12145004 0x1 #HIGH

telnetd&

#echo 20480000 > /proc/sys/net/core/wmem_default
#echo 40960000 > /proc/sys/net/core/wmem_max

ifconfig lo up
/tmp/nginx/sbin/nginx -p /tmp/nginx/
/tmp/samba/bin/smbd -D

#RJ45
himm 0x101c03c4 0xd04
himm 0x101c03c0 0x11011f
himm 0x101c03c4 0x17b
himm 0x101c03c0 0x110110

cd /tmp/
./reset &
./box.4k60
