~system76-dev/system76-driver/2.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/usr/bin/env python
#
## System76, Inc.
## Copyright System76, Inc.
## Released under the GNU General Public License (See LICENSE)
## Common sound driver installation
import os
import urllib
import model
import fileinput

WORKDIR = os.path.join(os.path.dirname(__file__), '.')
USRSRCDIR = os.path.join(os.path.dirname(__file__), '/usr/src/')
SOUNDDIR1 = os.path.join(os.path.dirname(__file__), 'sys76-alsa-1.0.14rc2')
SOUNDDIR2 = os.path.join(os.path.dirname(__file__), 'sys76-alsa-1.0.14rc3')
SOUNDDIR3 = os.path.join(os.path.dirname(__file__), 'sys76-alsa-1.0.14')

def alsa1():
    """Installs alsa 1.0.14rc2"""
    if os.path.exists(SOUNDDIR1) == True:
        # Install kernel headers
        os.system("sudo apt-get --assume-yes install linux-headers-`uname -r` build-essential")
        # Configure and Install Driver
        os.chdir(SOUNDDIR1)
        os.system("sudo sh configure --with-oss=yes --with-cards=hda-intel,usb-audio --with-kernel=/usr/src/linux-headers-`uname -r`/")
        os.system("sudo make && sudo make install")
        os.system("sudo make clean")
    elif os.path.exists(SOUNDDIR1) == False:
        # Get the driver
        os.chdir(WORKDIR)
        os.system("sudo wget http://planet76.com/sound/sys76-alsa-1.0.14rc2.tgz")
        os.system("tar -xzvf sys76-alsa-1.0.14rc2.tgz")
        # Install kernel headers
        os.system("sudo apt-get --assume-yes install linux-headers-`uname -r` build-essential")
        # Configure and Install Driver
        os.chdir(SOUNDDIR1)
        os.system("sudo sh configure --with-oss=yes --with-cards=hda-intel,usb-audio --with-kernel=/usr/src/linux-headers-`uname -r`/")
        os.system("sudo make && sudo make install")
        os.system("sudo make clean")
    else:
        raise OSError("A problem has occured.")
    
def alsa2():
    """Installs alsa 1.0.14rc3"""
    if os.path.exists(SOUNDDIR2) == True:
        # Install kernel headers
        os.system("sudo apt-get --assume-yes install linux-headers-`uname -r` build-essential")
        # Configure and Install Driver
        os.chdir(SOUNDDIR2)
        os.system("sudo sh configure --with-oss=yes --with-cards=hda-intel,usb-audio --with-kernel=/usr/src/linux-headers-`uname -r`/")
        os.system("sudo make && sudo make install")
        os.system("sudo make clean")
    elif os.path.exists(SOUNDDIR2) == False:
        # Get the Driver
        os.chdir(WORKDIR)
        os.system("sudo wget http://planet76.com/sound/sys76-alsa-1.0.14rc3.tar.gz")
        os.system("tar -xzvf sys76-alsa-1.0.14rc3.tar.gz")
        # Install kernel headers
        os.system("sudo apt-get --assume-yes install linux-headers-`uname -r` build-essential")
        # Configure and Install Driver
        os.chdir(SOUNDDIR2)
        os.system("sudo sh configure --with-oss=yes --with-cards=hda-intel,usb-audio --with-kernel=/usr/src/linux-headers-`uname -r`/")
        os.system("sudo make && sudo make install")
        os.system("sudo make clean")
    else:
        raise OSError("A problem has occured.")
    
def alsa3():
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    alsa_base = open("/etc/modprobe.d/alsa-base", "w")
    
    for line in fileinput.input("alsa_base",inplace =1):
        line = line.strip()
        if not 'toshiba' in line:
            print line
            
    for line in fileinput.input("alsa_base",inplace =1):
        line = line.strip()
        if not 'targa-dig' in line:
            print line
    
    """Installs alsa 1.0.14 final with realtek patches"""
    if os.path.exists(SOUNDDIR3) == True:
        # Install kernel headers
        os.system("sudo apt-get --assume-yes install linux-headers-`uname -r` build-essential")
        # Configure and Install Driver
        os.chdir(SOUNDDIR3)
        os.system("sudo sh configure --with-oss=yes --with-cards=hda-intel,usb-audio --with-kernel=/usr/src/linux-headers-`uname -r`/")
        os.system("sudo make && sudo make install")
        os.system("sudo make clean")
        os.system("echo options snd-hda-intel model=toshiba | sudo tee -a /etc/modprobe.d/alsa-base")
    elif os.path.exists(SOUNDDIR3) == False:
        # Get the Driver
        os.chdir(WORKDIR)
        os.system("sudo wget http://planet76.com/sound/sys76-alsa-1.0.14.tar.gz")
        os.system("tar -xzvf sys76-alsa-1.0.14.tar.gz")
        # Install kernel headers
        os.system("sudo apt-get --assume-yes install linux-headers-`uname -r` build-essential")
        # Configure and Install Driver
        os.chdir(SOUNDDIR3)
        os.system("sudo sh configure --with-oss=yes --with-cards=hda-intel,usb-audio --with-kernel=/usr/src/linux-headers-`uname -r`/")
        os.system("sudo make && sudo make install")
        os.system("sudo make clean")
        os.system("echo options snd-hda-intel model=toshiba | sudo tee -a /etc/modprobe.d/alsa-base")
    
def alsa4():
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not 'toshiba' in line:
            print line
            
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not 'targa-dig' in line:
            print line
            
    os.system("echo options snd-hda-intel model=targa-dig | sudo tee -a /etc/modprobe.d/alsa-base")

def alsa5():
    
    """Installs alsa 1.0.15rc3 source package.  Creates alsa-modules package.
    Installs alsa-modules package.  Replaces above alsa3 def.
    Adds "toshiba" line to alsa-base."""
    
    #Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not 'toshiba' in line:
            print line
            
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not 'targa-dig' in line:
            print line
    
    # Determine running kernel version
    b = os.popen('uname -r')
    try:
        uname = b.readline().strip()
    finally:
        b.close()
    kernel = uname
    
    # Check if alsa-modules-'uname -r' is installed
    b = os.popen('dpkg --get-selections | grep alsa-modules')
    try:
        installstatus = b.readline().strip()
        installed = installstatus.rstrip('install')
        version = installed.strip()
    finally:
        b.close()
        
    if version == "alsa-modules-%s" % kernel:
        alsa_installed = True
    else:
        alsa_installed = False
    
    # Change to the working directory
    os.chdir(WORKDIR)
    
    if alsa_installed == True:
        os.system("echo options snd-hda-intel model=toshiba | sudo tee -a /etc/modprobe.d/alsa-base")
        return
    elif os.path.isfile("alsa-source_1.0.15rc3-ldd1_all.deb") == True:
        os.system("sudo apt-get --assume-yes install build-essential debhelper intltool-debian po-debconf html2text debconf-utils module-assistant")
        os.system("sudo dpkg -i alsa-source_1.0.15rc3-ldd1_all.deb")
        os.chdir(USRSRCDIR)
        os.system("sudo module-assistant -t -i a-i alsa-source")
        os.system("echo options snd-hda-intel model=toshiba | sudo tee -a /etc/modprobe.d/alsa-base")
        return
    elif os.path.isfile("alsa-source_1.0.15rc3-ldd1_all.deb") == False:
        os.system("sudo wget http://planet76.com/sound/alsa-source_1.0.15rc3-ldd1_all.deb")
        os.system("sudo apt-get --assume-yes install build-essential debhelper intltool-debian po-debconf html2text debconf-utils module-assistant")
        os.system("sudo dpkg -i alsa-source_1.0.15rc3-ldd1_all.deb")
        os.chdir(USRSRCDIR)
        os.system("sudo module-assistant -t -i a-i alsa-source")
        os.system("echo options snd-hda-intel model=toshiba | sudo tee -a /etc/modprobe.d/alsa-base")
        return

def alsa6():
    
    """Installs alsa 1.0.15rc3 source package.  Creates alsa-modules package.
    Installs alsa-modules package.  Replaces above alsa1 and alsa2 defs."""
    
    # Determine running kernel version
    b = os.popen('uname -r')
    try:
        uname = b.readline().strip()
    finally:
        b.close()
    kernel = uname
    
    # Check if alsa-modules-'uname -r' is installed
    b = os.popen('dpkg --get-selections | grep alsa-modules')
    try:
        installstatus = b.readline().strip()
        installed = installstatus.rstrip('install')
        version = installed.strip()
    finally:
        b.close()
        
    if version == "alsa-modules-%s" % kernel:
        alsa_installed = True
    else:
        alsa_installed = False
    
    # Change to the working directory
    os.chdir(WORKDIR)
    
    if alsa_installed == True:
        return
    elif os.path.isfile("alsa-source_1.0.15rc3-ldd1_all.deb") == True:
        os.system("sudo apt-get --assume-yes install build-essential debhelper intltool-debian po-debconf html2text debconf-utils module-assistant")
        os.system("sudo dpkg -i alsa-source_1.0.15rc3-ldd1_all.deb")
        os.chdir(USRSRCDIR)
        os.system("sudo module-assistant -t -i a-i alsa-source")
        return
    elif os.path.isfile("alsa-source_1.0.15rc3-ldd1_all.deb") == False:
        os.system("sudo wget http://planet76.com/sound/alsa-source_1.0.15rc3-ldd1_all.deb")
        os.system("sudo apt-get --assume-yes install build-essential debhelper intltool-debian po-debconf html2text debconf-utils module-assistant")
        os.system("sudo dpkg -i alsa-source_1.0.15rc3-ldd1_all.deb")
        os.chdir(USRSRCDIR)
        os.system("sudo module-assistant -t -i a-i alsa-source")
        return
    
def alsa7():
    
    """Installs alsa 1.0.15rc3 source package.  Creates alsa-modules package.
    Installs alsa-modules package.  Adds "options snd-hda-intel model=6stack-dig" 
    line to alsa-base."""
    
    #Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not '6stack-dig' in line:
            print line
    
    # Determine running kernel version
    b = os.popen('uname -r')
    try:
        uname = b.readline().strip()
    finally:
        b.close()
    kernel = uname
    
    # Check if alsa-modules-'uname -r' is installed
    b = os.popen('dpkg --get-selections | grep alsa-modules')
    try:
        installstatus = b.readline().strip()
        installed = installstatus.rstrip('install')
        version = installed.strip()
    finally:
        b.close()
        
    if version == "alsa-modules-%s" % kernel:
        alsa_installed = True
    else:
        alsa_installed = False
    
    # Change to the working directory
    os.chdir(WORKDIR)
    
    if alsa_installed == True:
        os.system("echo options snd-hda-intel model=6stack-dig | sudo tee -a /etc/modprobe.d/alsa-base")
        return
    elif os.path.isfile("alsa-source_1.0.15rc3-ldd1_all.deb") == True:
        os.system("sudo apt-get --assume-yes install build-essential debhelper intltool-debian po-debconf html2text debconf-utils module-assistant")
        os.system("sudo dpkg -i alsa-source_1.0.15rc3-ldd1_all.deb")
        os.chdir(USRSRCDIR)
        os.system("sudo module-assistant -t -i a-i alsa-source")
        os.system("echo options snd-hda-intel model=6stack-dig | sudo tee -a /etc/modprobe.d/alsa-base")
        return
    elif os.path.isfile("alsa-source_1.0.15rc3-ldd1_all.deb") == False:
        os.system("sudo wget http://planet76.com/sound/alsa-source_1.0.15rc3-ldd1_all.deb")
        os.system("sudo apt-get --assume-yes install build-essential debhelper intltool-debian po-debconf html2text debconf-utils module-assistant")
        os.system("sudo dpkg -i alsa-source_1.0.15rc3-ldd1_all.deb")
        os.chdir(USRSRCDIR)
        os.system("sudo module-assistant -t -i a-i alsa-source")
        os.system("echo options snd-hda-intel model=6stack-dig | sudo tee -a /etc/modprobe.d/alsa-base")
        return

def alsa8():
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not '6stack-dig' in line:
            print line
            
    os.system("echo options snd-hda-intel model=6stack-dig | sudo tee -a /etc/modprobe.d/alsa-base")
    
def alsa9():
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not 'toshiba' in line:
            print line
            
    os.system("echo options snd-hda-intel model=toshiba | sudo tee -a /etc/modprobe.d/alsa-base")
    
def alsa10():
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not '3stack-6ch-dig' in line:
            print line
            
    os.system("echo options snd-hda-intel model=3stack-6ch-dig | sudo tee -a /etc/modprobe.d/alsa-base")
    
def alsa11():
    
    # Install Alsa Driver 1.0.17 for mic and sound after resume support
    os.chdir(WORKDIR)
    os.system("sudo sh ./alsa-1.0.17.sh")
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base",inplace =1):
        line = line.strip()
        if not '3stack-6ch-dig' in line:
            print line
            
    os.system("echo options snd-hda-intel model=3stack-6ch-dig | sudo tee -a /etc/modprobe.d/alsa-base")
    
def alsa12():
    
    # Clean up /etc/modprobe.d/alsa-base file
    
    for line in fileinput.input("/etc/modprobe.d/alsa-base.conf",inplace =1):
        line = line.strip()
        if not 'acer-aspire' in line:
            print line
            
    os.system("echo options snd-hda-intel model=acer-aspire | sudo tee -a /etc/modprobe.d/alsa-base.conf")
    os.system("gconftool-2 --config-source xml:readwrite:/etc/gconf/gconf.xml.mandatory --type string --set /system/gstreamer/0.10/default/audiosrc 'pulsesrc'")