Add udev rule to control weston upon HDMI hotplug/unplug

Restart weston service when HDMI is connected and stop weston
service when HDMI is disconnected from the device

Change-Id: I9af7c48e887f282da0d492b69200c9250818268c
diff --git a/debian/etc/udev/scripts/hdmi_hotplug.sh b/debian/etc/udev/scripts/hdmi_hotplug.sh
new file mode 100755
index 0000000..5604d84
--- /dev/null
+++ b/debian/etc/udev/scripts/hdmi_hotplug.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+HDMIStatus=$(cat /sys/class/drm/card0-HDMI-A-1/status)
+
+if [ $HDMIStatus == 'connected' ]; then
+	systemctl restart weston
+else
+	systemctl stop weston
+fi
diff --git a/debian/rules b/debian/rules
index da2effd..323c248 100755
--- a/debian/rules
+++ b/debian/rules
@@ -9,3 +9,6 @@
 
 override_dh_auto_test:
 	true
+
+override_dh_installudev:
+	dh_installudev --name=hdmi_hotplug --priority 99
diff --git a/debian/weston-mtk.hdmi_hotplug.udev b/debian/weston-mtk.hdmi_hotplug.udev
new file mode 100644
index 0000000..d1e7e6e
--- /dev/null
+++ b/debian/weston-mtk.hdmi_hotplug.udev
@@ -0,0 +1 @@
+ACTION=="change", KERNEL=="card0", SUBSYSTEM=="drm", RUN+="/etc/udev/scripts/hdmi_hotplug.sh"
\ No newline at end of file