Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/basic-video/graphic.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2845 - (hide annotations) (download)
Fri Nov 16 14:24:20 2018 UTC (5 years, 5 months ago) by niro
File size: 7318 byte(s)
-honor MROOT and fix typos en|disabled -> en|disable
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 niro 2844
90 niro 2845 if [ -f ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/hdmi ]
91 niro 2844 then
92 niro 2845 source ${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/hdmi
93 niro 2844 case "${graphic_hdmi}" in
94 niro 2845 enable) write_zotac_quirk=0 ;;
95     disable) write_zotac_quirk=1 ;;
96 niro 2844 esac
97     fi
98    
99 niro 2830 if [[ ${write_zotac_quirk} = 1 ]]
100     then
101     addconfig "# Autogenerated by mcored"
102     addconfig "Section \"Monitor\""
103     addconfig " Identifier \"LVDS1\""
104     addconfig " Option \"Ignore\" \"True\""
105     addconfig "EndSection"
106     fi
107 niro 1258 }
108    
109 niro 1248 help_graphic_resolution()
110     {
111     mecho "set graphic.resolution [resolution]"
112 niro 2813 mecho " auto, 800x600, 1024x768, 1280x1024 etc"
113 niro 1248 }
114    
115     help_graphic_refresh()
116     {
117     mecho "set graphic.refresh [refresh rate]"
118 niro 2813 mecho " auto, 60, 100 - all values are Hz"
119 niro 1248 }
120    
121 niro 1258 help_graphic_depth()
122     {
123     mecho "set graphic.depth [color-depth]"
124 niro 2813 mecho " auto, 1, 4, 8, 15, 16, 24 - all values are bits"
125 niro 1258 }
126    
127     help_graphic_driver()
128     {
129     mecho "get graphic.driver [action]"
130     mecho " Shows current selected or system available graphic drivers."
131     mecho " Available actions:"
132     mecho " system - show available drivers on the system"
133     mecho " current - shows the current selected driver used by Xorg"
134     mecho
135     mecho "set graphic.driver [driver]"
136     mecho " Selects the graphic card driver used by Xorg."
137     }
138    
139 niro 2844 help_graphic_hdmi()
140     {
141     mecho "set graphic.hdmi [action]"
142     mecho " Available actions:"
143     mecho " enable - enables the hdmi port"
144     mecho " disable - disables the hdmi port"
145     }
146    
147 niro 1248 # set_graphic_resolution ${value}
148     set_graphic_resolution()
149     {
150 niro 2269 local resolution="${CLASS_ARGV[0]}"
151 niro 1258 local CONFIG
152     local depth
153     [[ -z ${resolution} ]] && help_graphic_resolution && return 1
154 niro 1248
155 niro 2018 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/20-resolution.conf"
156 niro 1248
157 niro 2823 case ${resolution} in
158 niro 2813 *x*)
159     clearconfig
160     # do it for all supported color depth
161     for depth in 1 4 8 15 16 24
162     do
163     addconfig ' SubSection "Display"'
164     addconfig " Depth ${depth}"
165     addconfig " Modes \"${resolution}\""
166     addconfig ' ViewPort 0 0'
167     addconfig ' EndSubSection'
168     done
169 niro 1258
170 niro 2813 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
171     then
172     x11runas "xrandr --size ${resolution}"
173     fi
174     ;;
175     auto) clearconfig ;;
176     esac
177    
178 niro 1258 helper_graphic_rebuild_xorg_conf_d
179 niro 1248 }
180    
181 niro 1258 # set_graphic_depth ${value}
182     set_graphic_depth()
183     {
184 niro 2269 local depth="${CLASS_ARGV[0]}"
185 niro 1258 local CONFIG
186     [[ -z ${depth} ]] && help_graphic_depth && return 1
187    
188 niro 2813 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/10-depth.conf"
189    
190 niro 1258 # do it only for supported color depths
191     case "${depth}" in
192     1|4|8|15|16|24)
193     clearconfig
194     addconfig " DefaultDepth ${depth}"
195     ;;
196 niro 2813 auto) clearconfig ;;
197 niro 1258 *) help_graphic_depth && return 1 ;;
198     esac
199    
200     helper_graphic_rebuild_xorg_conf_d
201 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
202     then
203     mecho "X11 restart required!"
204     fi
205 niro 1258 }
206    
207 niro 1248 # set_graphic_refresh ${value}
208     set_graphic_refresh()
209     {
210 niro 2269 local value="${CLASS_ARGV[0]}"
211 niro 1258 [[ -z ${value} ]] && help_graphic_refresh && return 1
212 niro 1248
213 niro 2018 #echo "${value}" > ${MROOT}/${MCORE_CONFIG_PATH}/xorg/refresh
214 niro 1248
215 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
216     then
217     x11runas "xrandr --refresh ${value}"
218     fi
219 niro 1248
220 niro 1258 helper_graphic_rebuild_xorg_conf_d
221 niro 1248 }
222    
223 niro 1258 set_graphic_driver()
224 niro 1248 {
225 niro 2269 local driver="${CLASS_ARGV[0]}"
226 niro 2194 local driverdir="@@LIBDIR@@/xorg/modules/drivers"
227 niro 1258 local CONFIG
228     [[ -z ${driver} ]] && help_graphic_driver && return 1
229 niro 1248
230 niro 2665 if [[ ${driver} = auto ]]
231 niro 1258 then
232 niro 2665 decho "Using driver autodetection, doing nothing"
233     elif [[ -f ${MROOT}/${driverdir}/${driver}_drv.so ]]
234     then
235 niro 2018 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
236 niro 1258 clearconfig
237     addconfig " Identifier \"Card0\""
238     addconfig " Driver \"${driver}\""
239 niro 1248
240 niro 1258 helper_graphic_rebuild_xorg_conf_d
241 niro 2018 if [[ -z ${MROOT} ]] || [[ ${MROOT} = / ]]
242     then
243     mecho "X11 restart required!"
244     fi
245 niro 1258 else
246     eecho "Driver '${driver}' does not exist on this system. Aborted!"
247 niro 1248 fi
248     }
249    
250 niro 2844 set_graphic_hdmi()
251     {
252     local action="${CLASS_ARGV[0]}"
253     local CONFIG
254    
255     case "${action}" in
256     enable|disable)
257 niro 2845 CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/hdmi"
258 niro 2844 clearconfig
259     addconfig "graphic_hdmi=\"${action}\""
260     ;;
261     *)
262     help_graphic_driver
263     return 1
264     ;;
265     esac
266     }
267    
268 niro 1258 get_graphic_driver()
269 niro 1248 {
270 niro 2269 local action="${CLASS_ARGV[0]}"
271 niro 2194 local driverdir="@@LIBDIR@@/xorg/modules/drivers"
272 niro 1258 local driver
273     local config="${MCORE_CONFIG_PATH}/xorg/device/25-device.conf"
274     local i
275 niro 1248
276 niro 1258 case "${action}" in
277     current)
278 niro 2018 if [[ -f ${MROOT}/${config} ]]
279 niro 1258 then
280 niro 2018 driver=$(grep Driver "${MROOT}/${config}" | sed 's:.*Driver.*\"\(.*\)\":\1:')
281 niro 1643 rvecho "${driver}"
282 niro 1258 else
283 niro 1643 rvecho "none"
284 niro 1258 fi
285     ;;
286     system)
287 niro 2039 driver=$(list_files_in_directory ${MROOT}/${driverdir} -mindepth 1 -maxdepth 1 | sed s':_drv.so::g')
288 niro 1643 rvecho "${driver}"
289 niro 1258 ;;
290     *)
291     help_graphic_driver
292     return 1
293     ;;
294     esac
295 niro 1248 }
296 niro 2844
297     get_graphic_hdmi()
298     {
299 niro 2845 local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/device/hdmi"
300 niro 2844 if [ -f ${CONFIG} ]
301     then
302     rvecho "$(< ${CONFIG})"
303     fi
304     }