Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, August 23, 2011

microphone doesn't do stereo on asus 1001p

The mic on my asus eee 1001p doesn't work correctly under Linux (apparently also on a number of models of the eee). In pulseaudio, it shows up as a stereo mic but the two channels cancel each other out so if you want it to work, you have to adjust one of the channels down to 0 (I use the pulseaudio volume control for this, pavucontrol). However, it's annoying that this doesn't just work. I've looked for solutions since I bought the device and I finally found one this week.

The correct solution is a kernel patch which appears to be on its way to kernel land. But while I'm waiting, I found a suitable workaround using the hda-verb utility. Here's the magic incantation below. Update the /dev/snd/* path to whatever is right for your system and then take the "value" output of the 2nd command and do a bit-wise or of 0x80 (in my case, 0x1800 became 0x1880) and use that as the last argument to the last command below.


# ./hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x07
nid = 0x20, verb = 0x500, param = 0x7
value = 0x0
# ./hda-verb /dev/snd/hwC0D0 0x20 GET_PROC_COEF 0
nid = 0x20, verb = 0xc00, param = 0x0
value = 0x1800
# ./hda-verb /dev/snd/hwC0D0 0x20 SET_COEF_INDEX 0x07
nid = 0x20, verb = 0x500, param = 0x7
value = 0x0
# ./hda-verb /dev/snd/hwC0D0 0x20 SET_PROC_COEF 0x1880

Saturday, December 4, 2010

openwrt crashes due to OOM killer

I have an openvpn tunnel running between two OpenWRT-powered routers. One of them is running Kamikaze 7.09 and crashes all the time when transferring lots of data at once. It was getting really annoying (for me and them) having to call the site and have it manually rebooted. I finally discovered that it appears to be dying because it runs out of memory and the OOM killer terminates all the important processes. It'd be nice if the OOM killer would just reboot the thing, but the kernel in Kamikaze 7.09 for this router doesn't support that (I think newer ones do). So I wrote the following watchdog script and installed it in root's crontab to run every 4 minutes. So far, the router hasn't crashed permanently. When memory gets low, it just reboots! Hopefully no more calls to this site...


#!/bin/sh

F="`free | grep Mem | cut -c 37-45`"
if [[ $F -lt 500 ]]; then
logger "Memory Low ($F) - rebooting..."
sleep 5
/sbin/reboot
fi

Thursday, December 2, 2010

I'm a victim of this NetworkManager bug where if it can't reach the dhcp server after some longer amount of time, it gives up. I have a server that is difficult for me to reboot that has gone down because NetworkManager just gives up if something happens to the DHCP server. So, I wrote this watchdog script and put it in my crontab to run every 5 minutes.


#!/bin/bash

if pidof dhclient > /dev/null; then
logger "dhclient is alive"
else
logger "dhclient is dead, restart NetworkManager"
/etc/init.d/NetworkManager restart
fi

Wednesday, September 22, 2010

Palm not syncing

My Palm wasn't connecting correctly to my Linux netbook. I was getting some weird errors in the logs:

usb 2-1: new full speed USB device using uhci_hcd and address 2
usb 2-1: device descriptor read/64, error -71
usb 2-1: device descriptor read/64, error -71
usb 2-1: new full speed USB device using uhci_hcd and address 3
usb 2-1: device descriptor read/64, error -71
usb 2-1: device descriptor read/64, error -71
usb 2-1: new full speed USB device using uhci_hcd and address 4
usb 2-1: device not accepting address 4, error -71
usb 2-1: new full speed USB device using uhci_hcd and address 5
usb 2-1: device not accepting address 5, error -71
hub 2-0:1.0: unable to enumerate USB device on port 1


After hunting and hunting (and not saving the page that gave me the answer), I discovered this is related to a bug on the Palm. The page I found suggested a reset. So I did, and it synced up right after that.

Tuesday, September 7, 2010

Suspend on Lid Close with LXDE

LXDE has been great on my Asus EEE 1001P. It's fast and usable. I've had some issues with it, but the most frustrating problem is that Fedora 12 with LXDE doesn't suspend by default when you close the lid. I did some googling and discovered this is known and the easy to fix it is to install the gnome-power-manager. But that kind of defeats the point of LXDE, right? I'm trying to avoid installing and using gnome heaviness to stay lean and mean and fast.

So, after lots of googling around, I finally came up with the optimum configuration which uses what I hope are lighter-weight services.

First, I had to install acpid to respond to lid close/open events (my code is based on this post):
yum install acpid


I hunted through the LXDE source code and discovered that lxde-logout uses a dbus call to HAL to trigger the suspend. I found a great blog post describing how to do this from a script. I implemented that by doing creating the following files:

/etc/acpi/events/lid (update: don't put a dot in the filename for Fedora 14+, it seems a new version of acpid ignores all files with dots in their names)

event=button/lid
action=/etc/acpi/actions/lid.sh


/etc/acpi/actions/lid.sh

#!/bin/bash

# maybe this sleep isn't needed, but just to make sure the lid close event doesn't trigger immediate wake-up
sleep 2

# make sure the lid is closed
grep -q open /proc/acpi/button/lid/LID/state && exit 0

# suspend
dbus-send --system --dest=org.freedesktop.Hal --type=method_call --print-reply /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0

Monday, May 18, 2009

Reducing an LVM Volume Group that's missing disks

I put in a new hard drive and used "pvmove" to move all the physical extents (all the data) from the old drives to the new one. But then, I removed the drives without running vgreduce! Oops... Fortunately, vgreduce has a "--removemissing" flag that can remove all the missing physical volumes from a volume group and restore consistency. This is exactly what I needed since I was sure that there was no data left on those other volumes.