Sunday, September 26, 2010

Ubuntu: Configuring Webcam and Microphone in Lenovo Y530

I have a Lenovo Y530 laptop. I had Windows then being the devoted Linux girl, I installed Ubuntu 9.10 on it. The laptop has built-in webcam(1.3M pixels). It was working fine with windows but got screwed up in ubuntu. So I set out to find out how to fix it. At first glance it looked like there was no proper solution available online. But after hours of search, I found the easy steps buried under a bunch of useless/complex solutions. So I wanted to document the exact steps I followed to configure the webcam.

  • I tried installing cheese(webcam booth tool for linux) and used Ekiga softphone. You can use either of this tool to check if the webcam is listed in video devices list. In Cheese, the screen had this test screen and both the tools din't recognize the webcam.
  • Then in Terminal, try "lsusb". It would list all the USB devices connected to the computer. A sample lsusb would look like this (this has no webcam)

    Bus 005 Device 002: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 003: ID 046d:c016 Logitech, Inc. M-UV69a/HP M-UV96 Optical Wheel Mouse
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    The 8 digit number followed by ID is the unique ID of the hardware device. If at all you want to search for solutions for any device use this number in your searches and you will more likely land in the page you want. When I ran this cmd, the output din't have any device listed in it. Then in some thread in Ubuntu forums(an excellent place to start your search), someone asked to use hot keys to toggle the webcam. In Lenovo Y530, its Fn+Esc. After that, lsusb listed the device as in,
    Bus 002 Device 002: ID 04f2:b105 Chicony Electronics Co., Ltd
  • Now, I searched the ID with all related keywords, it landed here. I checked for my device and saw that it was complaint and all i have to do is download the v4l dvb drivers and viola.
  • Then follow the steps listed in this link. I downloaded the latest version of V4L/DVB via web browser and following cmds "make", "make install". [don't forget to do, "sudo make install" - I know its simple but trust me you don't want to miss it]
Then happened the weirdest thing. After rebooting the system and checking if webcam worked with cheese, the microphone got screwed. When open the sound preferences dialog(System->Preferences->Sound), in the Input tab, there was no device listed. Without proper knowledge about the thread flow, I removed pulseaudio from the system. Then it was a fresh start as with the webcam. The steps followed were the following:

  • In Terminal, use this cmd
    lspci -v | grep -i audio

    The result would print out the Audio device if configured right. In my case, it returned empty result.
  • So I downloaded the alsa drivers, util, lib files from here. Followed this steps
    • copy the tar.gz files to "/usr/src/alsa" - if you have the folder already or create one if you don't
    • Then unzip the files using "sudo tar xjf alsa-driver*". Similarly util and lib files(change tar options as you require)
    • Then we have to go each directory and do "./configure", "make", "make install".
    • During the "./configure" if any error pops, you have to clear that for the installation to complete. I am just listing the problems I faced.
      • Problem: During the "make" of Util files
         xmlto man alsactl_init.xml
        /bin/bash: xmlto: command not found

        Solution:
        sudo apt-get install xmlto
      • Problem: During the "./configure" of Util files
        checking for new_panel in -lpanelw... no
        configure: error: panelw library not found

        Solution: Create soft links to the library files. click here for source
         sudo ln -s libpanelw.so.5 /usr/lib/libpanelw.so
        sudo ln -s libformw.so.5 /usr/lib/libformw.so
        sudo ln -s libmenuw.so.5 /usr/lib/libmenuw.so
        sudo ln -s libncursesw.so.5 /lib/libncursesw.so

Then reboot the system. Now everything works perfectly fine.

Later added: As I mentioned in the post, I accidentally removed pulseaudio from my system. So when I tried to do skype call, both sides webcam worked fine. But audio had too much static noise. So I had to install pulseaudio. Then reinstalled skype. Skype call works fine. But still if I use the system's music player, then try skype calls again audio has static noise. I read from a forum that "sudo killall pulseaudio" and then restarting skype helps. But that is not efficient solution. If someone has permanent solution to this please drop a comment. Thanks in advance.

Sunday, September 12, 2010

Servlets

Servlets are replacing CGI script at most enterprise computing. They both perform similar operations of creating and displaying HTML pages dynamically. The basic differences between the two:

  • CGI - Platform dependent, hence they cannot utilize server's capabilities; spawns new process for every request, hence resource intensive;
  • Servlets - Since written in Java they can be executed in servers without any modifications as per "write once, run anywhere"; spawns new threads within the server process, hence lite weight.
Lifecycle of servlets:

  • init() - initializes the servlet
  • service(ServletRequest , ServletResponse) - all url's access this method and here we delegate to other service methods of form doXXX(HttpServletRequest , HttpServletResponse)
  • destroy() - destroys the servlet

Thursday, September 9, 2010

Reset root password for phpmyadmin/mysql

I recently faced an issue where I forgot the root password for mysql and ended up searching for simple procedure to unlock it by resetting the password. So I want to save here the steps to unlock the phpmyadmin if I should loose my root password again. Then I can skip the searching-for-an-hour part and go straight to the unlocking part. (Thanks to fredanthony and for source thread: click here)

The error message you get when you enter wrong password in the login page is :
"#1045 - Access denied for user 'root'@'localhost' (using password: NO) "

Steps:

  1. Stop mysql - $ /etc/init.d/mysql stop
  2. Kill all mysql related processes. The ps list can be pretty big and confusing so better use grep to filter mysql processes and use only those pids in kill command. - $ ps waux | grep mysql, $kill -9 pids
  3. Open a new session of mysql by skipping permissions - $ /usr/bin/mysqld_safe --skip-grant-tables
  4. While the above session is open, in a new tab open a new session of mysql - $ /usr/bin/mysql
  5. Inside the new session,change the database - (inside mysql)$use mysql;
  6. The critical part of our unlocking process is resetting the password for root user -(inside mysql) $UPDATE user SET Password=PASSWORD('YOUR_PASSWORD_HERE')
    WHERE Host='localhost' AND User='root'; - This step sets new password for the root user.
  7. Then quit the mysql sessions and restart the mysql - $quit, $/etc/init.d/mysql restart
  8. try logging into phpmyadmin with new password you set in update command and viola!

P.S: List of useful SQL command syntax - source

METHOD 2:
This step is to change the MYSQL root password. Source: Ubuntu help documentation. In a terminal enter the following command:

"sudo dpkg-reconfigure mysql-server-5.1"

However verify you have mysql-server-5.1 in your system. To find that, in terminal type "mysql -V". The result would print out details about the mysql server installed in your system.Sample result was
"mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1". Hence I use 5.1 in the above command. When you run the reconfigure command, it will prompt you to enter password and restarts the mysql daemon.