Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in
Parent Directory | Revision Log
Revision 2843 -
(hide annotations)
(download)
Fri Nov 16 13:47:13 2018 UTC (5 years, 6 months ago) by niro
File size: 6484 byte(s)
Fri Nov 16 13:47:13 2018 UTC (5 years, 6 months ago) by niro
File size: 6484 byte(s)
-revert last change
1 | niro | 1248 | # $Id$ |
2 | |||
3 | niro | 1258 | provide basic-video |
4 | niro | 1248 | |
5 | niro | 1258 | # todo monitor gfxcard |
6 | helper_graphic_add_configs() | ||
7 | { | ||
8 | local path="$1" | ||
9 | local conf | ||
10 | |||
11 | # exit ERR if path does not exist | ||
12 | [[ ! -d ${path} ]] && return 1 | ||
13 | |||
14 | for conf in $(find "${path}" -mindepth 1 -maxdepth 1 -type f -name \*.conf | sort) | ||
15 | do | ||
16 | cat "${conf}" >> "${CONFIG}" | ||
17 | done | ||
18 | } | ||
19 | |||
20 | # everything from xorg conf but inputdevices. they are handled properly trough udev! | ||
21 | helper_graphic_rebuild_xorg_conf_d() | ||
22 | { | ||
23 | local CONFIG | ||
24 | local conf | ||
25 | niro | 2828 | local boardvendor |
26 | niro | 2830 | local write_zotac_quirk |
27 | niro | 1258 | |
28 | # rebuild 25-gfxcard.conf | ||
29 | # always clear the config | ||
30 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf" |
31 | niro | 1258 | clearconfig |
32 | niro | 2019 | addconfig "# Autogenerated by mcored" |
33 | niro | 1258 | # but only add lines if some values are found in config.d dir |
34 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
35 | niro | 1258 | then |
36 | addconfig 'Section "Device"' | ||
37 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
38 | niro | 1258 | addconfig 'EndSection' |
39 | fi | ||
40 | |||
41 | # rebuild 25-module.conf | ||
42 | # always clear the config | ||
43 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf" |
44 | niro | 1258 | clearconfig |
45 | niro | 2019 | addconfig "# Autogenerated by mcored" |
46 | niro | 1258 | # but only add lines if some values are found in config.d dir |
47 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
48 | niro | 1258 | then |
49 | addconfig 'Section "Module"' | ||
50 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
51 | niro | 1258 | addconfig 'EndSection' |
52 | fi | ||
53 | |||
54 | # rebuild 25-screen.conf | ||
55 | # always clear the config | ||
56 | niro | 2194 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf" |
57 | niro | 1258 | clearconfig |
58 | niro | 2019 | addconfig "# Autogenerated by mcored" |
59 | niro | 1258 | # but only add lines if some values are found in config.d dir |
60 | niro | 2018 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
61 | niro | 1258 | then |
62 | addconfig 'Section "Screen"' | ||
63 | addconfig ' Identifier "Screen0"' | ||
64 | addconfig ' Monitor "Monitor0"' | ||
65 | niro | 2018 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
66 | niro | 1258 | addconfig 'EndSection' |
67 | fi | ||
68 | niro | 2828 | |
69 | # always disable hdmi port on zotac devices atm - fixme make it configurable like alx | ||
70 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/30-fix-zotac.conf" | ||
71 | clearconfig | ||
72 | niro | 2830 | write_zotac_quirk=0 |
73 | niro | 2828 | if [ -e /sys/devices/virtual/dmi/id/board_vendor ] |
74 | then | ||
75 | boardvendor="$(< /sys/devices/virtual/dmi/id/board_vendor)" | ||
76 | # decapitalize | ||
77 | boardvendor="${boardvendor,,}" | ||
78 | case ${boardvendor} in | ||
79 | niro | 2830 | *zotac*) write_zotac_quirk=1 ;; |
80 | niro | 2828 | esac |
81 | niro | 2830 | fi |
82 | # some zotacs has as the board_vendor "filled by o.e.m" | ||
83 | # so we search the whole devices subtree for zotac vendor matches | ||
84 | # 0x19da="ZOTAC International (MCO) Ltd." | ||
85 | if [[ -n $(cat /sys/devices/*/*/subsystem_vendor | grep 0x19da) ]] | ||
86 | then | ||
87 | write_zotac_quirk=1 | ||
88 | fi | ||
89 | if [[ ${write_zotac_quirk} = 1 ]] | ||
90 | then | ||
91 | addconfig "# Autogenerated by mcored" | ||
92 | addconfig "Section \"Monitor\"" | ||
93 | addconfig " Identifier \"LVDS1\"" | ||
94 | addconfig " Option \"Ignore\" \"True\"" | ||
95 | addconfig "EndSection" | ||
96 | fi | ||
97 | niro | 1258 | } |
98 | |||
99 | niro | 1248 | help_graphic_resolution() |
100 | { | ||
101 | mecho "set graphic.resolution [resolution]" | ||
102 | niro | 2813 | mecho " auto, 800x600, 1024x768, 1280x1024 etc" |
103 | niro | 1248 | } |
104 | |||
105 | help_graphic_refresh() | ||
106 | { | ||
107 | mecho "set graphic.refresh [refresh rate]" | ||
108 | niro | 2813 | mecho " auto, 60, 100 - all values are Hz" |
109 | niro | 1248 | } |
110 | |||
111 | niro | 1258 | help_graphic_depth() |
112 | { | ||
113 | mecho "set graphic.depth [color-depth]" | ||
114 | niro | 2813 | mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits" |
115 | niro | 1258 | } |
116 | |||
117 | help_graphic_driver() | ||
118 | { | ||
119 | mecho "get graphic.driver [action]" | ||
120 | mecho " Shows current selected or system available graphic drivers." | ||
121 | mecho " Available actions:" | ||
122 | mecho " system - show available drivers on the system" | ||
123 | mecho " current - shows the current selected driver used by Xorg" | ||
124 | mecho | ||
125 | mecho "set graphic.driver [driver]" | ||
126 | mecho " Selects the graphic card driver used by Xorg." | ||
127 | } | ||
128 | |||
129 | niro | 1248 | # set_graphic_resolution ${value} |
130 | set_graphic_resolution() | ||
131 | { | ||
132 | niro | 2269 | local resolution="${CLASS_ARGV[0]}" |
133 | niro | 1258 | local CONFIG |
134 | local depth | ||
135 | [[ -z ${resolution} ]] && help_graphic_resolution && return 1 | ||
136 | niro | 1248 | |
137 | niro | 2018 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
138 | niro | 1248 | |
139 | niro | 2823 | case ${resolution} in |
140 | niro | 2813 | *x*) |
141 | clearconfig | ||
142 | # do it for all supported color depth | ||
143 | for depth in 1 4 8 15 16 24 | ||
144 | do | ||
145 | addconfig ' SubSection "Display"' | ||
146 | addconfig " Depth ${depth}" | ||
147 | addconfig " Modes \"${resolution}\"" | ||
148 | addconfig ' ViewPort 0 0' | ||
149 | addconfig ' EndSubSection' | ||
150 | done | ||
151 | niro | 1258 | |
152 | niro | 2813 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
153 | then | ||
154 | x11runas "xrandr --size ${resolution}" | ||
155 | fi | ||
156 | ;; | ||
157 | auto) clearconfig ;; | ||
158 | esac | ||
159 | |||
160 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
161 | niro | 1248 | } |
162 | |||
163 | niro | 1258 | # set_graphic_depth ${value} |
164 | set_graphic_depth() | ||
165 | { | ||
166 | niro | 2269 | local depth="${CLASS_ARGV[0]}" |
167 | niro | 1258 | local CONFIG |
168 | [[ -z ${depth} ]] && help_graphic_depth && return 1 | ||
169 | |||
170 | niro | 2813 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
171 | |||
172 | niro | 1258 | # do it only for supported color depths |
173 | case "${depth}" in | ||
174 | 1|4|8|15|16|24) | ||
175 | clearconfig | ||
176 | addconfig " DefaultDepth ${depth}" | ||
177 | ;; | ||
178 | niro | 2813 | auto) clearconfig ;; |
179 | niro | 1258 | *) help_graphic_depth && return 1 ;; |
180 | esac | ||
181 | |||
182 | helper_graphic_rebuild_xorg_conf_d | ||
183 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
184 | then | ||
185 | mecho "X11 restart required!" | ||
186 | fi | ||
187 | niro | 1258 | } |
188 | |||
189 | niro | 1248 | # set_graphic_refresh ${value} |
190 | set_graphic_refresh() | ||
191 | { | ||
192 | niro | 2269 | local value="${CLASS_ARGV[0]}" |
193 | niro | 1258 | [[ -z ${value} ]] && help_graphic_refresh && return 1 |
194 | niro | 1248 | |
195 | niro | 2018 | #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh |
196 | niro | 1248 | |
197 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
198 | then | ||
199 | x11runas "xrandr --refresh ${value}" | ||
200 | fi | ||
201 | niro | 1248 | |
202 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
203 | niro | 1248 | } |
204 | |||
205 | niro | 1258 | set_graphic_driver() |
206 | niro | 1248 | { |
207 | niro | 2269 | local driver="${CLASS_ARGV[0]}" |
208 | niro | 2194 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
209 | niro | 1258 | local CONFIG |
210 | [[ -z ${driver} ]] && help_graphic_driver && return 1 | ||
211 | niro | 1248 | |
212 | niro | 2665 | if [[ ${driver} = auto ]] |
213 | niro | 1258 | then |
214 | niro | 2665 | decho "Using driver autodetection, doing nothing" |
215 | elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] | ||
216 | then | ||
217 | niro | 2018 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
218 | niro | 1258 | clearconfig |
219 | addconfig " Identifier \"Card0\"" | ||
220 | addconfig " Driver \"${driver}\"" | ||
221 | niro | 1248 | |
222 | niro | 1258 | helper_graphic_rebuild_xorg_conf_d |
223 | niro | 2018 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
224 | then | ||
225 | mecho "X11 restart required!" | ||
226 | fi | ||
227 | niro | 1258 | else |
228 | eecho "Driver '${driver}' does not exist on this system. Aborted!" | ||
229 | niro | 1248 | fi |
230 | } | ||
231 | |||
232 | niro | 1258 | get_graphic_driver() |
233 | niro | 1248 | { |
234 | niro | 2269 | local action="${CLASS_ARGV[0]}" |
235 | niro | 2194 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
236 | niro | 1258 | local driver |
237 | local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" | ||
238 | local i | ||
239 | niro | 1248 | |
240 | niro | 1258 | case "${action}" in |
241 | current) | ||
242 | niro | 2018 | if [[ -f ${MROOT}/${config} ]] |
243 | niro | 1258 | then |
244 | niro | 2018 | driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
245 | niro | 1643 | rvecho "${driver}" |
246 | niro | 1258 | else |
247 | niro | 1643 | rvecho "none" |
248 | niro | 1258 | fi |
249 | ;; | ||
250 | system) | ||
251 | niro | 2039 | driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') |
252 | niro | 1643 | rvecho "${driver}" |
253 | niro | 1258 | ;; |
254 | *) | ||
255 | help_graphic_driver | ||
256 | return 1 | ||
257 | ;; | ||
258 | esac | ||
259 | niro | 1248 | } |