Gentoo Archives: gentoo-commits

From: "Doug Goldstein (cardoe)" <cardoe@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-admin/eselect-xvmc/files: eselect-xvmc-0.2.eselect
Date: Wed, 29 Oct 2008 14:37:32
Message-Id: E1KvCAr-0000T2-Oa@stork.gentoo.org
1 cardoe 08/10/29 14:37:29
2
3 Added: eselect-xvmc-0.2.eselect
4 Log:
5 add support for ATI's XvMC implementation
6 (Portage version: 2.2_rc12/cvs/Linux 2.6.26-gentoo-r1 x86_64)
7
8 Revision Changes Path
9 1.1 app-admin/eselect-xvmc/files/eselect-xvmc-0.2.eselect
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-xvmc/files/eselect-xvmc-0.2.eselect?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-xvmc/files/eselect-xvmc-0.2.eselect?rev=1.1&content-type=text/plain
13
14 Index: eselect-xvmc-0.2.eselect
15 ===================================================================
16 # Copyright 1999-2008 Gentoo Foundation
17 # Distributed under the terms of the GNU General Public License v2
18 # $Id: eselect-xvmc-0.2.eselect,v 1.1 2008/10/29 14:37:29 cardoe Exp $
19
20 DESCRIPTION="Manage the XvMC implementation used by your system"
21 MAINTAINER="cardoe@g.o"
22 SVN_DATE='$Date: 2008/10/29 14:37:29 $'
23 VERSION=$(svn_date_to_version "${SVN_DATE}" )
24
25 XVMCLIBS=(
26 "libXvMCNVIDIA_dynamic.so.1"
27 "libXvMC.so.1"
28 "libviaXvMC.so.1"
29 "libchromeXvMC.so.1"
30 "libviaXvMCPro.so.1"
31 "libchromeXvMCPro.so.1"
32 "libI810XvMC.so.1"
33 "libAMDXvBA.so.1" )
34 XVMCPRETTY=(
35 "nvidia"
36 "xorg-x11"
37 "via"
38 "openchrome"
39 "via-pro"
40 "openchrome-pro"
41 "intel"
42 "ati" )
43
44 get_implementation_indices() {
45 local ret n
46 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
47 [[ -e "${ROOT}/usr/lib/${XVMCLIBS[n]}" ]] && ret+=($n)
48 done
49
50 echo ${ret[@]}
51 }
52
53 get_current_implementation_index() {
54 local n
55 if [[ -f "${ROOT}/etc/X11/XvMCConfig" ]]; then
56 local current=$(< "${ROOT}/etc/X11/XvMCConfig")
57 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
58 if [[ "${XVMCLIBS[n]}" = "${current}" ]]; then
59 echo "${n}"
60 return
61 fi
62 done
63 fi
64
65 echo "-1"
66 }
67
68 set_new_implementation() {
69 echo -n "Switching to ${XVMCPRETTY[$1]} XvMC implementation..."
70 touch "${ROOT}/etc/X11/XvMCConfig" 2&>1 > /dev/null
71 if [[ $? -eq 0 ]]; then
72 echo "${XVMCLIBS[$1]}" > "${ROOT}/etc/X11/XvMCConfig"
73 chmod 644 "${ROOT}/etc/X11/XvMCConfig"
74 chown 0:0 "${ROOT}/etc/X11/XvMCConfig"
75 echo " done"
76 else
77 echo " failed!"
78 echo "Insufficient privileges"
79 fi
80 }
81
82 ### list action
83
84 ## {{{ list stuff
85 describe_list() {
86 echo "List Available XvMC implementations"
87 }
88
89 do_list() {
90 local output n
91 local avail=( $(get_implementation_indices) )
92 local current=$(get_current_implementation_index)
93 write_list_start "Available XvMC implementations ( $(highlight '*') is current ):"
94
95 if (( ${#avail[@]} )) ; then
96 for n in "${avail[@]}" ; do
97 output[n]="${XVMCPRETTY[n]}"
98 [[ ${current} -eq ${n} ]] && \
99 output[n]+=" $(highlight '*')"
100 done
101 write_numbered_list "${output[@]}"
102 else
103 write_kv_list_entry "(none found)" ""
104 fi
105
106 return 0
107 }
108 ## }}}
109
110 ### show action
111
112 ## {{{ show stuff
113 describe_show() {
114 echo "Print the current XvMC implementation."
115 }
116
117 do_show() {
118 local current=$(get_current_implementation_index)
119 write_list_start "Current XvMC implementation:"
120
121 if [[ ${current} -ne -1 ]]; then
122 echo "${XVMCPRETTY[current]}"
123 return 0
124 else
125 echo "(none)"
126 return 2
127 fi
128 }
129 ## }}}
130
131 ### set action
132
133 ## {{{ set stuff
134 describe_set() {
135 echo "Select the XvMC implementation"
136 }
137
138 describe_set_parameters() {
139 echo "<target>"
140 }
141
142 describe_set_options() {
143 echo "<target> : XvMC implementation to activate"
144 echo "--use-old : If an implementation is already set, use that one instead"
145 }
146
147 do_set() {
148 local current=$(get_current_implementation_index)
149 local avail=( $(get_implementation_indices) )
150 local n new action
151
152 while [[ ${#@} -gt 0 ]]; do
153 local opt=${1}
154 shift
155 case ${opt} in
156 --use-old)
157 if [[ ${current} -gt -1 ]]; then
158 (( ${current} < ${#XVMCPRETTY[@]} )) && action="old-implementation"
159 fi
160 ;;
161 *)
162 [[ -z ${action} ]] && action="set-implementation"
163
164 if is_number ${opt} ; then
165 new=${avail[opt - 1]}
166 if [[ -z ${new} ]]; then
167 die -q "Unrecognized option: ${opt}"
168 fi
169 elif has ${opt} ${XVMCPRETTY[@]}; then
170 for (( n = 0; n < ${#XVMCPRETTY[@]}; ++n )); do
171 [[ "${XVMCPRETTY[n]}" = "${opt}" ]] && new=${n}
172 done
173 else
174 die -q "Unrecognized option: ${opt}"
175 fi
176 ;;
177 esac
178 done
179
180 case ${action} in
181 old-implementation)
182 set_new_implementation ${current}
183 return $?
184 ;;
185 set-implementation)
186 if [[ -n ${new} ]]; then
187 set_new_implementation ${new}
188 return $?
189 else
190 die -q "Please specify an implementation to set"
191 fi
192 ;;
193 *)
194 die -q "Invalid usage of set action."
195 esac
196 }
197
198 # vim: ts=4 sw=4 noet fdm=marker