For my system, I got kanyo's method to work automatically on every boot by reverse engineering the ioctl calls that come from HDA Analyzer when you click on the widgets to adjust the settings. Here is my pyhon script:
#!/usr/bin/python
# Matt Damiano's script based on hda-analyzer
# to automatically enable onboard mic on Lenovo G560
#
def __ioctl_val(val):
# copied directly from hda_codec.py
# workaround for OverFlow bug in python 2.4
if val & 0x80000000:
return -((val^0xffffffff)+1)
return val
## just to prove his is the right file descriptor...
info = struct.pack('Ii64s80si64s', 0, 0, '', '', 0, '')
result = ioctl(fd, IOCTL_INFO, info)
name = struct.unpack('Ii64s80si64s', result)[3]
print name
For my system, I got kanyo's method to work automatically on every boot by reverse engineering the ioctl calls that come from HDA Analyzer when you click on the widgets to adjust the settings. Here is my pyhon script:
#!/usr/bin/python
# Matt Damiano's script based on hda-analyzer
# to automatically enable onboard mic on Lenovo G560
#
import os
import struct
from fcntl import ioctl
def main(): for_device( 0, 1) settings( fd)
fd = get_fd_
modify_
def __ioctl_val(val): 0xffffffff) +1)
# copied directly from hda_codec.py
# workaround for OverFlow bug in python 2.4
if val & 0x80000000:
return -((val^
return val
IOCTL_INFO = __ioctl_ val(0x80dc4801) val(0xc0084811)
IOCTL_VERB_WRITE = __ioctl_
def modify_ settings( fd): active_ connection_ verb = 336003329 val2_verb = 335765760 val3_verb = 335761664 val2_volume_ verb = 335765840 val3_volume_ verb = 335761744
# set active connection for Node [0x14] AUD_IN to Audio Selector [0x18]
set_
unmute_
unmute_
boost_
boost_
ioctl(fd, IOCTL_VERB_WRITE, struct.pack('II', set_active_ connection_ verb, 0)) volume_ verb, 0)) volume_ verb, 0))
ioctl(fd, IOCTL_VERB_WRITE, struct.pack('II', unmute_val2_verb, 0))
ioctl(fd, IOCTL_VERB_WRITE, struct.pack('II', unmute_val3_verb, 0))
ioctl(fd, IOCTL_VERB_WRITE, struct.pack('II', boost_val2_
ioctl(fd, IOCTL_VERB_WRITE, struct.pack('II', boost_val3_
return
def get_fd_ for_device( card, device): "/dev/snd/ hwC%sD% s" % (card, device), os.O_RDWR)
fd = os.open(
## just to prove his is the right file descriptor... pack('Ii64s80si 64s', 0, 0, '', '', 0, '') unpack( 'Ii64s80si64s' , result)[3]
info = struct.
result = ioctl(fd, IOCTL_INFO, info)
name = struct.
print name
return fd
if __name__ == "__main__":
main()