Contents of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in
Parent Directory | Revision Log
Revision 2830 -
(show annotations)
(download)
Tue Aug 15 11:22:47 2017 UTC (6 years, 9 months ago) by niro
File size: 6484 byte(s)
Tue Aug 15 11:22:47 2017 UTC (6 years, 9 months ago) by niro
File size: 6484 byte(s)
-some zotac devices have not the right bios infos, so we search the whole devices subtree for zotac vendor matches
1 | # $Id$ |
2 | |
3 | provide basic-video |
4 | |
5 | # 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 | local boardvendor |
26 | local write_zotac_quirk |
27 | |
28 | # rebuild 25-gfxcard.conf |
29 | # always clear the config |
30 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-device.conf" |
31 | clearconfig |
32 | addconfig "# Autogenerated by mcored" |
33 | # but only add lines if some values are found in config.d dir |
34 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
35 | then |
36 | addconfig 'Section "Device"' |
37 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device |
38 | addconfig 'EndSection' |
39 | fi |
40 | |
41 | # rebuild 25-module.conf |
42 | # always clear the config |
43 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-module.conf" |
44 | clearconfig |
45 | addconfig "# Autogenerated by mcored" |
46 | # but only add lines if some values are found in config.d dir |
47 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
48 | then |
49 | addconfig 'Section "Module"' |
50 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/module |
51 | addconfig 'EndSection' |
52 | fi |
53 | |
54 | # rebuild 25-screen.conf |
55 | # always clear the config |
56 | CONFIG="${MROOT}@@SYSCONFDIR@@/X11/xorg.conf.d/25-screen.conf" |
57 | clearconfig |
58 | addconfig "# Autogenerated by mcored" |
59 | # but only add lines if some values are found in config.d dir |
60 | if path_not_empty ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
61 | then |
62 | addconfig 'Section "Screen"' |
63 | addconfig ' Identifier "Screen0"' |
64 | addconfig ' Monitor "Monitor0"' |
65 | helper_graphic_add_configs ${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen |
66 | addconfig 'EndSection' |
67 | fi |
68 | |
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 | write_zotac_quirk=0 |
73 | 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 | *zotac*) write_zotac_quirk=1 ;; |
80 | esac |
81 | 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 | } |
98 | |
99 | help_graphic_resolution() |
100 | { |
101 | mecho "set graphic.resolution [resolution]" |
102 | mecho " auto, 800x600, 1024x768, 1280x1024 etc" |
103 | } |
104 | |
105 | help_graphic_refresh() |
106 | { |
107 | mecho "set graphic.refresh [refresh rate]" |
108 | mecho " auto, 60, 100 - all values are Hz" |
109 | } |
110 | |
111 | help_graphic_depth() |
112 | { |
113 | mecho "set graphic.depth [color-depth]" |
114 | mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits" |
115 | } |
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 | # set_graphic_resolution ${value} |
130 | set_graphic_resolution() |
131 | { |
132 | local resolution="${CLASS_ARGV[0]}" |
133 | local CONFIG |
134 | local depth |
135 | [[ -z ${resolution} ]] && help_graphic_resolution && return 1 |
136 | |
137 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf" |
138 | |
139 | case ${resolution} in |
140 | *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 | |
152 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
153 | then |
154 | x11runas "xrandr --size ${resolution}" |
155 | fi |
156 | ;; |
157 | auto) clearconfig ;; |
158 | esac |
159 | |
160 | helper_graphic_rebuild_xorg_conf_d |
161 | } |
162 | |
163 | # set_graphic_depth ${value} |
164 | set_graphic_depth() |
165 | { |
166 | local depth="${CLASS_ARGV[0]}" |
167 | local CONFIG |
168 | [[ -z ${depth} ]] && help_graphic_depth && return 1 |
169 | |
170 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf" |
171 | |
172 | # 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 | auto) clearconfig ;; |
179 | *) help_graphic_depth && return 1 ;; |
180 | esac |
181 | |
182 | helper_graphic_rebuild_xorg_conf_d |
183 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
184 | then |
185 | mecho "X11 restart required!" |
186 | fi |
187 | } |
188 | |
189 | # set_graphic_refresh ${value} |
190 | set_graphic_refresh() |
191 | { |
192 | local value="${CLASS_ARGV[0]}" |
193 | [[ -z ${value} ]] && help_graphic_refresh && return 1 |
194 | |
195 | #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh |
196 | |
197 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
198 | then |
199 | x11runas "xrandr --refresh ${value}" |
200 | fi |
201 | |
202 | helper_graphic_rebuild_xorg_conf_d |
203 | } |
204 | |
205 | set_graphic_driver() |
206 | { |
207 | local driver="${CLASS_ARGV[0]}" |
208 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
209 | local CONFIG |
210 | [[ -z ${driver} ]] && help_graphic_driver && return 1 |
211 | |
212 | if [[ ${driver} = auto ]] |
213 | then |
214 | decho "Using driver autodetection, doing nothing" |
215 | elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]] |
216 | then |
217 | CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
218 | clearconfig |
219 | addconfig " Identifier \"Card0\"" |
220 | addconfig " Driver \"${driver}\"" |
221 | |
222 | helper_graphic_rebuild_xorg_conf_d |
223 | if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]] |
224 | then |
225 | mecho "X11 restart required!" |
226 | fi |
227 | else |
228 | eecho "Driver '${driver}' does not exist on this system. Aborted!" |
229 | fi |
230 | } |
231 | |
232 | get_graphic_driver() |
233 | { |
234 | local action="${CLASS_ARGV[0]}" |
235 | local driverdir="@@LIBDIR@@/xorg/modules/drivers" |
236 | local driver |
237 | local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf" |
238 | local i |
239 | |
240 | case "${action}" in |
241 | current) |
242 | if [[ -f ${MROOT}/${config} ]] |
243 | then |
244 | driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:') |
245 | rvecho "${driver}" |
246 | else |
247 | rvecho "none" |
248 | fi |
249 | ;; |
250 | system) |
251 | driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g') |
252 | rvecho "${driver}" |
253 | ;; |
254 | *) |
255 | help_graphic_driver |
256 | return 1 |
257 | ;; |
258 | esac |
259 | } |