Tagged: audio

Getting Sound (ALSA) Working on Gentoo

I don't think this is limited to only Gentoo setup, but the sound isn't working after the installation. These are the steps I took to get my sound cards recognized by ALSA and got it working.

I use ALSA instead of PulseAudio with no particular reasonings. Some say ALSA is better or vice-versa, but I'm using it since I'm just used to.

I had a suspicion that the sound might not work after the installation. I ran alsamixer to test if my suspicion was right. Well, there was no alsamixer, so I installed media-sound/alsa-utils.# emerge --ask media-sound/alsa-utils

When alsamixer was executed, it returned the following error message as I suspected.$ alsamixer cannot open mixer: No such file or directory

The system recognizes its hardware and the driver seems to be installed but ALSA didn't see them.# lspci -k | grep -iA2 audio 00:14.2 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 Azalia (Intel HDA) Subsystem: Hewlett-Packard Company SBx00 Azalia (Intel HDA) Kernel driver in use: snd_hda_intel -- 01:00.1 Audio device: NVIDIA Corporation GF106 High Definition Audio Controller (rev a1) Subsystem: eVga.com. Corp. GeForce GTS 450 Kernel driver in use: snd_hda_intel

But, ALSA didn't seem to recognize those sound cards.# cat /proc/asound/cards --- no soundcards ---

I google'd around and found that the HD-audio component consists of two parts, the driver (which I seem to have installed) and codec from the Linux Kernel site as well as some Gentoo forum posts.# dmsg | grep -i codec [ 1.626139] snd_hda_intel 0000:01:00.1: no codecs found!

Yup, I don't have codecs installed. I google'd again and found that conexant for my audio device. So, I searched that codec name in the kernel config file.# grep -i conexant /usr/src/linux/.config CONFIG_SND_HDA_CODEC_CONEXANT=n

I enabled the kernel options following by ALSA in Gentto Wiki, including SND_HDA_CODEC_CONEXANT, and rebuilt the kernel.# cd /usr/src/linux # make menuconfig # make && make modules_install # make install # shudown -r now

After the reboot, kernel version should be incremented/updated.# uname -v #3 SMP Thu Feb 13 14:46:50 EST

Codecs are now installed.# dmesg | grep -i codec [ 1.254990] snd_hda_codec_realtek hdaudioC0D0: ALC888: SKU not ready 0x411111f0 [ 1.255697] snd_hda_codec_realtek hdaudioC0D0: autoconfig for ALC888: line_outs=4 (0x14/0x15/0x16/0x17/0x0) type:line [ 1.255879] snd_hda_codec_realtek hdaudioC0D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.256057] snd_hda_codec_realtek hdaudioC0D0: hp_outs=1 (0x1b/0x0/0x0/0x0/0x0) [ 1.256231] snd_hda_codec_realtek hdaudioC0D0: mono: mono_out=0x0 [ 1.256361] snd_hda_codec_realtek hdaudioC0D0: dig-out=0x11/0x1e [ 1.256491] snd_hda_codec_realtek hdaudioC0D0: inputs: [ 1.256623] snd_hda_codec_realtek hdaudioC0D0: Front Mic=0x19 [ 1.256768] snd_hda_codec_realtek hdaudioC0D0: Rear Mic=0x18 [ 1.256863] snd_hda_codec_realtek hdaudioC0D0: Line=0x1c [ 1.514180] snd_hda_codec_generic hdaudioC1D0: autoconfig for Generic: line_outs=0 (0x0/0x0/0x0/0x0/0x0) type:line [ 1.514376] snd_hda_codec_generic hdaudioC1D0: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.514544] snd_hda_codec_generic hdaudioC1D0: hp_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.514727] snd_hda_codec_generic hdaudioC1D0: mono: mono_out=0x0 [ 1.514829] snd_hda_codec_generic hdaudioC1D0: dig-out=0x5/0x0 [ 1.514967] snd_hda_codec_generic hdaudioC1D0: inputs: [ 1.561175] snd_hda_codec_generic hdaudioC1D1: autoconfig for Generic: line_outs=0 (0x0/0x0/0x0/0x0/0x0) type:line [ 1.561370] snd_hda_codec_generic hdaudioC1D1: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.561554] snd_hda_codec_generic hdaudioC1D1: hp_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.561738] snd_hda_codec_generic hdaudioC1D1: mono: mono_out=0x0 [ 1.561833] snd_hda_codec_generic hdaudioC1D1: dig-out=0x5/0x0 [ 1.561962] snd_hda_codec_generic hdaudioC1D1: inputs: [ 1.600184] snd_hda_codec_generic hdaudioC1D2: autoconfig for Generic: line_outs=0 (0x0/0x0/0x0/0x0/0x0) type:line [ 1.600378] snd_hda_codec_generic hdaudioC1D2: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.600563] snd_hda_codec_generic hdaudioC1D2: hp_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.600745] snd_hda_codec_generic hdaudioC1D2: mono: mono_out=0x0 [ 1.600882] snd_hda_codec_generic hdaudioC1D2: dig-out=0x5/0x0 [ 1.601018] snd_hda_codec_generic hdaudioC1D2: inputs: [ 1.638124] snd_hda_codec_generic hdaudioC1D3: autoconfig for Generic: line_outs=0 (0x0/0x0/0x0/0x0/0x0) type:line [ 1.638271] snd_hda_codec_generic hdaudioC1D3: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.638411] snd_hda_codec_generic hdaudioC1D3: hp_outs=0 (0x0/0x0/0x0/0x0/0x0) [ 1.638551] snd_hda_codec_generic hdaudioC1D3: mono: mono_out=0x0 [ 1.638690] snd_hda_codec_generic hdaudioC1D3: dig-out=0x5/0x0 [ 1.638822] snd_hda_codec_generic hdaudioC1D3: inputs:

/proc/asound/cards which showed "--- no soundcards ---" now shows found sound cards.# cat /proc/asound/cards 0 [SB ]: HDA-Intel - HDA ATI SB HDA ATI SB at 0xfbff4000 irq 16 1 [NVidia ]: HDA-Intel - HDA NVidia HDA NVidia at 0xfe97c000 irq 19

Yes, ALSA now sees the sound cards. I checked with alsamixer and it seems to be working fine. alsamixer

When I tested with aplay, I heard a noise from my speaker! I now confirmed that the sound is working on my Gentoo.# aplay < /dev/urandom

New: Article about Pulseaudio

Follow the above link to get the sound working from VirtualBox clients.

That's all!
-gibb

Exploring with Gentoo Linux (Part 1)

Part 1 - Base System

In my previous post, I mentioned that my 10-year-old PC went haywire and upgraded some components to fix them. One of them was the main hard disk that had Slackware installed. I replaced it with a new SSD disk, hoping to get some speed in processing (my PC was so old that I'm not expecting much of speed boost). Since my primary drive needed a replacement, I had to install new OS on it. I was thinking of putting Slackware as usual but it got me thinking a bit. Its last release was 4 years ago. I love its simplicity and stable build but didn't feel like installing a 4-year-old OS.

Gentoo Linux

I've tried Debian, Arch, and Manjaro Linux before, but I always came back to Slackware before I knew it. While debating whether to put Slackware 14.2 again, I came across with Gentoo Linux. I knew the existance of Gentoo Linux and you'd need to compile every package, like Ports in FreeBSD. Well, I wanted to start a new so I decided to give it a try to see how I'd like it.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Installation:

I wanted the set up of my work environment be the same as what I had before (See Building My Work Environment (Part 1)), so most of applications that'll be installed will be the same. At any rate, the installation of Gentoo was a bit of trial and error, and it took quite a while to get it installed. I'll leave the steps to its Handbook, but its installation procedure is not a menu driven, like other distos. It involes a lot of typings. It reminded me of the Arch Linux installation.

Even Slackware installation is a console menu based, so that makes a big difference between these two distros. I would think the installation procedure for Gentoo or Arch is more flexible.

Partition/filesystem Schemes:

I have this 256GB SSD as a primary disk and 1TB SATA disk for /home. The SSD disk was brand new so I partitioned it as follows with parted;

PartitionSizeFSDescription
/dev/sda12MiB-BIOS boot partition
/dev/sda2128MiBext2Boot partition
/dev/sda34295MiBSWAPSwap Partition
/dev/sda4239970MiBext4/ Partition
Updated: Updated article about Partition Schemes

For the secondary disk, I converted its partition table to gpt and created one partition for /home.

PartitionSizeFSDescription
/dev/sdb1953868MiBext4/home partition

This below is my /etc/fstab. I have /var/tmp and /var/tmp/portage as tmpfs. I took an advice from Portage TMPDIR on tmpfs in Gentoo wiki.

/dev/sda2/bootext2defaults,noatime0 2
/dev/sda3noneswapsw0 0
/dev/sda4/ext4noatime,errors=remount-ro0 1
/dev/sdb1/homeext4defaults1 2
tmpfs/tmptmpfsnoatime,nodev,nosuid,size=10G0 0
tmpfs/var/tmptmpfsrw,nosuid,noatime,nodev, size=15G,mode=17770 0
tmpfs/var/tmp/portage tmpfsrw,nosuid,noatime,nodev,size=15G, mode=775,uid=portage,gid=portage, x-mount.mkdir=7750 0
Updated: Updated article about /etc/fstab

SSD Optimization:

Some of websites mention the use of discard mount option in fstab, but as SSD from Gentoo wiki and Solid State Drive from Archwiki stated, using the discard mount option is called continuous TRIM and it's not recommended. Instead, it suggests to run fstrim periodically. So, that's what I did using cron.# crontab -e =================================== # Global variables SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # For details see man 5 crontab # Example of job definition: # .---------------- minute (0 - 59) # |  .------------- hour (0 - 23) # |  |  .---------- day of month (1 - 31) # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # |  |  |  |  | # * * * * * user-name command to be executed 15 04 * * 6 /sbin/fstrim /

XDG cache on tmpfs:

Many X Window System programs, such as Chromium, Firefox, etc..., make frequent disk I/O every few seconds to cache. To reduce strains to SSD, the default cache location can be changed to tmpfs. The default cache location is ~/.cache and this is HDD for my case but I sent it to tmpfs anyway.# nvim /etc/profile.d/xdg_cache_home.sh ============================================ if [ $USER ]; then export XDG_CACHE_HOME="/tmp/${USER}/.cache" fi

make.conf:

/etc/portage/make.conf is used to customize the Portage environment for the entire system (not per package or user). The settings defined in this file will be applied to all packages that are being installed (or emerged). So far, these are my custom settings: # cat /etc/portage/make.conf ================== CFLAGS="-march=native -O2 -pipe" ... # The number of parallel make jobs that can be used MAKEOPTS="-j7" # USE flags USE="-emacs -kde -gnome -bluetooth alsa" # Language codes for US English and Japanese L10N="en en-US ja"

X11:

If startx can't be found, it most likely X11 didn't get installed. # emerge --ask x11-base/xorg-server

System Logger:

During the installation, I chose to install system logger (app-admin/sysklogd) and this may display the following messages in console:

sysklogd: /dev/xconsole: No such file or directory

When the message starts to appear, updating its configuration file should solve it. # nvim /etc/syslog.conf ============ ... #daemon.*;mail.*;\ # news.err;\ # *.=debug;*.=info;\ # *.=notice;*.=warn |/dev/xconsole

ALSA Issues:

I have another post with more details about issues with ALSA sound, but to sum it up,I need to enable SND_HDA_CODEC_CONEXANT in the kernel options. The HD-audio component apparently consists of two parts, the driver and codec, and correct options need to be enabled.

eix:

eix is a set of utilities for searching and diffing local ebuild repositories using a binary cache. This is used to audit installed packages for maintenance. Use eix Gentoo wiki for how to set it up. # emerge --ask app-portage/eix

New: Some system utilities are added below.

smartmontools:

smartmontools is a utility to read and monitor the S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) information of ATA/SATA and SCSI/SAS drives. Use Gentoo wiki: smartmontools for how to set it up. # emerge --ask sys-apps/smartmontools

lshw:

lshw is a hardware detection utility to report various hardware components. # emerge --ask sys-apps/lshw

To display connected storage devices, run below command: # lshw -class disk -class storage ========================= ... *-scsi:0 physical id: 1 logical name: scsi0 capabilities: emulated *-disk description: ATA Disk product: Samsung SSD 860 physical id: 0.0.0 bus info: scsi@0:0.0.0 logical name: /dev/sda version: 1B6Q serial: S5GANE0MB00832Y size: 238GiB (256GB) capabilities: gpt-1.00 partitioned partitioned:gpt configuration: ansiversion=5 guid=2d257117-5180-48d2-be63-3222d90a37e9 logicalsectorsize=512 sectorsize=512 ... *-scsi:2 physical id: 3 logical name: scsi2 capabilities: emulated *-disk description: ATA Disk product: WDC WD10EZEX-75W vendor: Western Digital physical id: 0.0.0 bus info: scsi@2:0.0.0 logical name: /dev/sdb version: 7113 serial: WD-WCC6Y4PE55J2 size: 931GiB (1TB) capabilities: gpt-1.00 partitioned partitioned:gpt configuration: ansiversion=5 guid=189d3b93-af3e-47e2-8ed2-975eb9ed4ec0 logicalsectorsize=512 sectorsize=4096

Things To Be Installed:

Fonts:
  • font-awesome
  • Kochi (Japanese)
  • Inconsolata

Icons:
  • Faenza

File Manager:
  • pcmanfm
  • ranger

Music:
  • cmus - Console based music player

Terminal:
  • rxvt-unicode

Text Editor:
  • Neovim

Themes:
  • lxappearance - Change GTK based themes
  • nitrogen - Set wallpapers
  • My customized Morning Glory theme

Version Control:
  • git

Virtualization:
  • virtualbox

Web Browser:
  • chromium

Window Manager:
  • i3
  • i3pystatus - Replacement for i3status
  • rofi - Replacement for dmenu

Others:
  • scrot - Command line screen capture
  • neofetch - ASCII art to show logo and system info

That's all!
-gibb