Make the mode configurable at build time for the waltham transmitter
[AGL/meta-agl.git] / meta-agl-core / recipes-graphics / wayland / weston-ini-conf.bb
1 SUMMARY = "Configuration file for the Weston and AGL Wayland compositors"
2 LICENSE = "MIT"
3 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
4
5 SRC_URI = " \
6         file://core.cfg \
7         file://shell.cfg \
8         file://hdmi-a-1-0.cfg \
9         file://hdmi-a-1-90.cfg \
10         file://hdmi-a-1-180.cfg \
11         file://hdmi-a-1-270.cfg \
12         file://remote-output.cfg \
13         file://transmitter-output.cfg.in \
14         file://virtual-0.cfg \
15         file://virtual-180.cfg \
16         file://virtual-270.cfg \
17 "
18
19 S = "${WORKDIR}"
20
21 inherit update-alternatives
22
23 # Default primary display/orientation fragment
24 WESTON_DISPLAYS ?= "hdmi-a-1-270"
25
26 # Configuration fragments to use in weston.ini.*
27 # Note that some may be replaced/removed when building the landscape
28 # configuration.
29 WESTON_FRAGMENTS = "core shell ${WESTON_DISPLAYS}"
30
31 # On-target weston.ini directory
32 weston_ini_dir = "${sysconfdir}/xdg/weston"
33
34 # Options for the user to change in local.conf
35 # e.g. TRANSMITTER_OUTPUT_MODE = "1080x1488"
36 TRANSMITTER_OUTPUT_MODE ??= "640x720@30"
37 TRANSMITTER_OUTPUT_HOST ??= "192.168.20.99"
38 TRANSMITTER_OUTPUT_PORT ??= "5005"
39
40 do_configure() {
41     sed -e "s#mode=.*#mode=${TRANSMITTER_OUTPUT_MODE}#" \
42         -e "s#host=.*#host=${TRANSMITTER_OUTPUT_HOST}#" \
43         -e "s#port=.*#port=${TRANSMITTER_OUTPUT_PORT}#" \
44         ${WORKDIR}/transmitter-output.cfg.in  > ${WORKDIR}/transmitter-output.cfg
45 }
46
47 do_compile() {
48     # Put all of our cfg files together for a default portrait
49     # orientation configuration
50     rm -f ${WORKDIR}/weston.ini.default
51     for F in ${WESTON_FRAGMENTS}; do
52         cat ${WORKDIR}/${F}.cfg >> ${WORKDIR}/weston.ini.default
53         echo >> ${WORKDIR}/weston.ini.default
54     done
55     sed -i -e '$ d' ${WORKDIR}/weston.ini.default
56
57     # Do it again, but filter fragments to configure for landscape
58     # and a corresponding landscape-inverted that is 180 degrees
59     # rotated.
60     rm -f ${WORKDIR}/weston.ini.landscape
61     for F in ${WESTON_FRAGMENTS}; do
62         INVF=$F
63         if echo $F | grep '^hdmi-a-1-\(90\|270\)$'; then
64             F="hdmi-a-1-0"
65             INVF="hdmi-a-1-180"
66         elif echo $F | grep '^virtual-270$'; then
67             F="virtual-0"
68             INVF="virtual-180"
69         fi
70         cat ${WORKDIR}/${F}.cfg >> ${WORKDIR}/weston.ini.landscape
71         cat ${WORKDIR}/${INVF}.cfg >> ${WORKDIR}/weston.ini.landscape-inverted
72         echo >> ${WORKDIR}/weston.ini.landscape
73         echo >> ${WORKDIR}/weston.ini.landscape-inverted
74     done
75     sed -i -e '$ d' ${WORKDIR}/weston.ini.landscape
76     sed -i -e '$ d' ${WORKDIR}/weston.ini.landscape-inverted
77 }
78
79 do_install:append() {
80     install -d ${D}${weston_ini_dir}
81     install -m 0644 ${WORKDIR}/weston.ini.default ${D}${weston_ini_dir}/
82     install -m 0644 ${WORKDIR}/weston.ini.landscape ${D}${weston_ini_dir}/
83     install -m 0644 ${WORKDIR}/weston.ini.landscape-inverted ${D}${weston_ini_dir}/
84 }
85
86 PACKAGE_ARCH = "${MACHINE_ARCH}"
87
88 # Use the alternative mechanism to handle multiple packages providing
89 # weston.ini.  This seems simpler than other possible approaches.
90 # Note that for now the generated packages are being marked as
91 # incompatible with each other for simplicity, that can be changed if
92 # a usecase where switching between alternatives at runtime is desirable
93 # appears.
94
95 ALTERNATIVE_LINK_NAME[weston.ini] = "${weston_ini_dir}/weston.ini"
96
97 RDEPENDS:${PN} = "weston-init"
98 RPROVIDES:${PN} = "weston-ini"
99 RCONFLICTS:${PN} = "${PN}-landscape"
100 ALTERNATIVE:${PN} = "weston.ini"
101 ALTERNATIVE_TARGET_${PN} = "${weston_ini_dir}/weston.ini.default"
102
103 PACKAGE_BEFORE_PN += "${PN}-landscape"
104
105 FILES:${PN}-landscape = "${weston_ini_dir}/weston.ini.landscape"
106
107 RDEPENDS:${PN}-landscape = "weston-init"
108 RPROVIDES:${PN}-landscape = "weston-ini"
109 RCONFLICTS:${PN}-landscape = "${PN}"
110 ALTERNATIVE:${PN}-landscape = "weston.ini"
111 ALTERNATIVE_TARGET_${PN}-landscape = "${weston_ini_dir}/weston.ini.landscape"
112
113 PACKAGE_BEFORE_PN += "${PN}-landscape-inverted"
114
115 FILES:${PN}-landscape-inverted = "${weston_ini_dir}/weston.ini.landscape-inverted"
116
117 RDEPENDS:${PN}-landscape-inverted = "weston-init"
118 RPROVIDES:${PN}-landscape-inverted = "weston-ini"
119 RCONFLICTS:${PN}-landscape-inverted = "${PN}"
120 ALTERNATIVE:${PN}-landscape-inverted = "weston.ini"
121 ALTERNATIVE_TARGET_${PN}-landscape-inverted = "${weston_ini_dir}/weston.ini.landscape-inverted"