Saturday, September 14, 2013

How to make Crystal HD accelerated video decoding work in Ubuntu

I have a small "nettop" Foxconn NT510 system which I use as a "TV computer", mostly to play videos. It has an Atom D510 process (1.7GHz dual-core Pineview) which isn't powerful enough to decode and play 1080p video, and sometimes even stutters with 720p video in fast-moving scenes.

Fortunately, it also has a built-in Broadcom Crystal HD BCM970015 chip, which is a mini-PCI card that supports hardware-accelerated video decoding and has good Linux drivers.

Getting the CrystalHD to work under Ubuntu 12.04 took a few steps, but now I can play 1080p video with CPU usage of about 10% of one core, using either Totem (GStreamer-based) or VLC media players. Here's how:

  • Install both the crystalhd-dkms and firmware-crystalhd packages. The former is the kernel module for the driver, while the latter is the firmware for the device:

    $ sudo apt-get install crystalhd-dkms firmware-crystalhd

    If you don't install the firmware package, you'll get weird cryptic errors in your syslog and it just won't work. For some reason the need for the firmware package isn't mentioned clearly in most of the tutorials I've seen.
  • If you want to use a GStreamer-based video player like Totem, install gstreamer0.10-crystalhd. Now, accelerated playback with GStreamer should "just work."
  • To make VLC use the CrystalHD is somewhat less obvious. Ubuntu's version of VLC does include the CrystalHD plugin but it does not try to use it by default. Three ways to do it:
    • Use vlc --codec crystalhd from the command line. Works, but you'll have to run it this way every time.
    • Open the VLC GUI, and choose Tools | Preferences from the menu, then Show ALL Settings. Choose Input/Codecs from the lengthy tree menu, and then scroll down to the bottom of the pane where Preferred decoders list appears. Add "crystalhd" to that field, and save your preferences.
    • Edit your VLC configuration file (normally ~/.config/vlc/vlcrc) and find the comment string "Preferred decoders list". Edit the following line to look like this:

      # Preferred decoders list (string)

In any case, to verify that the CrystalHD is actually being used, start playing a video and watch your syslog (e.g. tail -f /var/log/syslog in a terminal window). You should see a line like this when you start playing video:

crystalhd 0000:04:00.0: Opening new user[0] handle

Tuesday, March 12, 2013

New Lenovo Yoga!

I just got a brand-spankin'-new Lenovo Yoga Ultrabook as a present from Intel. It's a clever new Ultrabook with a screen that folds all the way back to become a hybrid tablet. This is the top-of-the-line model with great hardware specs:
  • Intel Core i7-3537U (2GHz 1600MHz 4MB) (4-core Ivy Bridge!) with Intel HD graphics
  • 8gb RAM
  • 13.3" multitouch screen with 1600x900 resolution
  • Gigantic MacBook-esque touchpad and chiclet keyboard
  • 256gb Samsung SSD
  • Bluetooth 4.0 and Realtek 8723 b/g/n wifi
  • 1x USB 2 port, 1x USB 3 port, 1x HDMI out, and SD card reader
  • Weighs 3.3 lbs
  • Windows 8, MS Office Home & Student


My first impressions are that the hardware is beautiful and excellent, with a few caveats:
  • This is supposed to be a premium mobile product, but the Realtek wifi adapter is flaky under Windows and keeps dropping my home network connection. Why didn't Lenovo include an Intel wireless chipset? We make the best wireless hardware and write excellent drivers for both Windows and Linux. My old, cheap Acer AS1410 notebook with Intel wireless has never dropped a connection or failed to pick up a weak signal.
  • What, only one USB 3.0 port, and one USB 2.0 port? Ars Technica's review puts it well:
I must once again profess bafflement: why would any PC OEM include USB 2.0 ports in an Ivy Bridge-based notebook before exhausting the four USB 3.0 ports natively supported by Intel's chipset? (Sigh, moving on.)
  • The screen is huge and beautiful and very high-resolution, and the multi-touch works great, but the 16:9 aspect ratio isn't great in portrait mode.
  • The function keys default to Windows 8 "Fn" mode, rather than real function keys. This is annoying and many of them duplicate easily available functions anyway, but at least you can switch them back to normal in the BIOS.
There are also a couple of things I wish it had based on having gotten used to using a Lenovo ThinkPad T400 for work:
  • The keyboard is nice and has good tactile feedback, and the multi-touch touchpad is similarly excellent. I do wish that there was either a backlight for the keyboard, or a little overhead light that could shine on the keyboard (as on the ThinkPads).
  • No docking station. I've gotten really used to just slapping my ThinkPad down on the docking station to connect Ethernet, extra monitors, headset, and USB keyboard all in one fell swoop. I think USB 3 docking stations are dumb and needlessly expensive, because they tend to duplicate hardware that already exists onboard (like multi-monitor support, extra ports, and onboard ethernet) but simply lacks an external port.


The Ultrabooks do away with legacy BIOS in favor of UEFI firmware, which allow them to boot very, very quickly even from a cold start. Woohoo!

As for the preinstalled Windows 8 operating system... woof. I've heard a lot of bad reviews, but it's even worse than I expected. It's lacking in functionality, confusingly split between Metro mode and Desktop mode (which removes my favorite features of the Windows 7 start menu, for good measure), and Microsoft seems to be aiming to outdo Apple in terms of vendor lock-in, developer restrictions, and flogging their own web services (Hotmail, Skydrive, etc.).

While trying to use Windows 8, I've regularly found myself wishing I could just reach for any of the following:
  1. My Acer AS1410 mini-notebook, running Ubuntu with Gnome Shell 3
  2. My workhorse Lenovo Thinkpad T400 laptop, running Windows 7
  3. My Samsung Epic smartphone running CyanogenMod 10 (Android Jellybean)
Yes, even my phone with its 4.3" touchscreen is far more versatile and easy-to-use than the Windows 8 monstrosity.


I'm planning to install Ubuntu. Looks like lack of device drivers for the wireless chipset were an issue a couple of months ago, but that these have been resolved in more recent kernels.

Details to follow...

Sunday, January 30, 2011

Best mouse ever!

I'm not usually one to sing the praises of particular electronics products, but I will make an exception for the Logitech V550 mouse.

At work, I'm constantly taking my laptop in and out of its docking station and traveling around the building to various conference rooms and other offices. It's a pain to use the touchpad when away from my desk, and it's also a pain to carry a wired mouse and have it dangling all over the place and accidentally activating buttons when I'm carrying it around. One of my coworkers showed me this model and I immediately decided to get one myself.

The killer feature (for me) of the Logitech V550 is that it comes with three little adhesive clips. You attach one to the lid of your laptop, and then you can snap the mouse onto and off of the laptop in a flash. The buttons cannot be accidentally activated when it's clipped in. The mouse itself is fairly small but feels solid and comfortable in my large-ish hands. It also has Logitech's "Hyper-Fast Scrolling" wheel which I thought was kind of a gimmick, but turns out to be quite nice: you can use the scrolling wheel click-by-click as with most other mice, or press it to switch to a smooth-scrolling mode which is good for scrolling down long pages. You can also wiggle the scroll wheel side-to-side, and I have configured this to go forward and backward on web pages.

I haven't had it long enough to find out how good the battery life is, but it's supposed to be many, many months, which is far better than other optical mice I have used.

So, if you need a mouse to use with a laptop that you're carrying around all the time, I highly recommend this one.  I paid about $30 and I think it's well worth it.

Monday, July 19, 2010

Humbling is...

humbling /ˈhəm-b(ə-)liŋ/
  1. adjective
    1. The realization that my $20 MP3 player can beat me at Chess.

Saturday, July 3, 2010

If, for some reason, you want to install Windows 7... here's how to make an installation USB drive, from Linux

Hey, do you remember CD-ROMs or DVDs?  They were these round things that you put in your computer... made a lot of noise.  Stored files, but not very many.  Not very fast.  A pain to deal with.  Nobody uses them anymore, now that we just download music and movies off the Internet and exchange files online or via flash drives.  Nobody, that is, except for my mom, who was upset when her DVD drive broke a few months ago...

Anyway, I digress: my mom is evidently not the only one who still uses DVDs.  Microsoft still distributes DVDs for installing and upgrading Windows 7.

My Acer 1410 notebook is awesome, but one of the least-awesome things about it is that it came with Windows Vista.  Not just Vista, but Vista loaded up with a whole lot of crapware courtesy of Acer, including about 500 flash games that have to be uninstalled individually.  Basically the first thing I did with the computer was to install Ubuntu instead of Vista.

But then Acer sent me free DVDs to upgrade to Windows 7... which I heard sucked less than Vista.  So I decided to give it a shot.  But here's the thing: the Acer 1410 doesn't have a DVD drive, since no one except my mom and Microsoft uses them anymore.  So how to install Windows 7?

Windows 7 can be installed from USB drives

Although Windows 7 is still distributed on DVD, it's smarter than Windows XP or Vista (but still only as smart as, say, Linux circa 2000).  Windows 7 can install itself from a USB drive, or pretty much anything... I actually used a 4 GB SD card since I have a bunch of those lying around.

There are a bunch of guides on the Internet that explain how to copy your Windows 7 DVD onto a USB drive and make it bootable.  There's even an official tool from Microsoft to do it.  Unfortunately, these tools and procedures require that
  1. You have a computer with Windows running on it and a DVD drive
  2. You actually have to use Windows to prepare the USB drive... and, frankly, the idea of actually using Windows to prepare bootable media sounds excruciating to me
Are you getting the feeling that I don't really know why I wanted to install Windows 7 in the first place?  Basically, I just wanted to find out if it sucks less than I imagined it would...

Anyway, if you are okay with the above requirements, you can use Windows to transfer your Windows 7 installation DVDs to USB, and be on your merry way.  But, for me...

Making a Windows 7 USB stick from within Linux

You need a flash drive or memory card with at least 4 GB capacity to hold the entire contents of the Windows 7 installation DVD.  Be aware that everything on the USB drive will be erased!!!  Oh, and you need a DVD drive on your Linux computer too.

Plug in the USB drive on your Linux computer, and figure out the device node assigned to it (perhaps /dev/sdb or /dev/sdc).  If you don't know how to do this... ask.  If the flash drive is automatically mounted, then unmount it after you've checked to make sure that you've copied any important data off of it.

Now we need to blank the USB drive and format it with NTFS.  This detail is extremely importantIf you format the USB drive with FAT32, then the Windows 7 installation will start to work, but fail cryptically with messages about unavailable CD-ROM drivers... the Internets are littered with confused forum postings by others who have stumbled on this weird bug.

So, let's use GNU Parted (which should be installed on most modern Linux systems).  First, blank the partition table (replace /dev/sdX with the appropriate device node for your USB drive):

$ sudo parted /dev/sdX
(parted) mklabel msdos
Warning: The existing disk label on /dev/sdb will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? yes

Next, create a new partition filling the USB drive, make it bootable, and then check that it worked by displaying the partition table:

(parted) mkpart primary ntfs 1c 100%
(parted) set 1 boot on
(parted) print
Model: Multiple Card Reader (scsi)
Disk /dev/sdX: 4094MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  4094MB  4093MB  primary  ntfs
(parted) quit

Sweet.  Now you have to format the newly-created NTFS partition:

$ sudo mkntfs --fast /dev/sdX1 
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

Here's a slightly tricky part: you have to give the USB drive an appropriate Windows 7 boot sector.  There's a great program called ms-sys for this sort of thing, and I have made pre-built ms-sys packages for Ubuntu.  So install it.  Use ms-sys to make an appropriate boot sector for the USB drive:

$ sudo ms-sys --mbr7 /dev/sdX
Windows 7 master boot record successfully written to /dev/sdX

Finally you have to copy the installation files onto the USB drive.  Mount the newly-created NTFS partition, however you usually mount removable media.  Also, take the Windows 7 installation DVD and mount it.  You may wish to pause for a moment to think about how quaint the DVD is, and to remind yourself which way is "up" on the DVD drive.

Copy allllll the files and directories from the DVD to the USB drive.  You can use a graphical file manager like Nautilus, or do it from the command line with rsync, using something like this:

$ rsync -av /mnt/dvd /mnt/usbdrive 

And finally, you're done!  Unmount the USB drive and boot off of it on the computer you're trying to install Windows 7 onto.  Windows 7 actually installs fairly quickly, but I must warn you that it will overwrite other operating systems' bootloaders without asking.  So if you plan to dual-boot Windows and Linux/*BSD/etc., be sure that you have something like SystemRescueCD or a bootable Linux flash drive so that you can recover the bootloader.

Epilogue: Windows is still lame

So after all this rigamarole, I have Windows 7 installed on my Acer 1410 notebook alongside Ubuntu.  Whoopty-do.  Windows 7 seems to run a little faster than Vista, and without the crazy screen flickering problems when you suspend and restart.

If you like Ubuntu and are sick of XP and Vista, you still won't like Windows 7.  It's the same old same-old as far as I can tell.

Back to Ubuntu for me. :-)

Wednesday, June 30, 2010

Wow, Pandora on the Motorola Q

The Motorola Q smartphone is getting pretty old and crufty these days, and can't do a lot of the cool stuff that newer Android and iPhones can do but... apparently it still has a few tricks up its sleeve, including the ability to play streaming Internet radio using the free Pandora service.

Friday, June 18, 2010

High-capacity hard drives

I've been shopping for a big, reliable, fast, cheap hard drive and have been frustrated by the lack of useful reviews and comparisons between different 2TB models.  Finally I found this useful 2TB HD Roundup from HotHardware which compares Seagate, WD, and Samsung models.

Unfortunately, Hitachi's surprisingly cheap 7200 rpm drive was not reviewed there, but here's a review of it from Tom's Hardware.

Based on this, I think I'm gonna spring for the cheap, low-power, and pretty well-performing Seagate LP 2tb drive.