2019-12-16

X61/X61s + Linux Mint 19.2 (Ubuntu 18.04) 安裝 Crystal HD (BCM70015) 硬體解壓縮卡

最近淘了台ThinkPad X61s來懷舊,想說這2007年的硬體播放1080p影片可能不太行,於是花了NT.200買了個Broadcom Crystal HD (BCM70015)硬體解壓縮卡來玩玩,不過要注意的是,影片格式、解析度、比特率不能超過以下限制,否則影片透過硬解後可能會撥不出來:

H.264/AVC HP at L 5.1 1080p/1080i, 40 Mbps
SMPTE VC-1 AP at L 3 1080p/1080i, 40 Mbps
WMV9 (VC-1 SP and MP)
MPEG-2 MP @ ML and HL, 80 Mbps
DivX 3.11, 4.1, 5.X, 6.X, XviD

安裝環境:Linux Mint 19.2 (Ubuntu 18.04), kernel 4.18.0-25

0.因為X61/X61s是用GM965/GL960內顯,
因此先更新為最新i915 driver (xserver-xorg-video-intel)
(此步驟可不做,若opengl呼叫有問題,可試著更新內顯驅動):
sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo apt-get update
sudo apt dist-upgrade

1.先安裝crystalhd driver,可選擇用modprobe或dkms的方式:

先安裝必要工具:
sudo apt-get install checkinstall git-core autoconf build-essential subversion dpkg-dev fakeroot pbuilder build-essential dh-make debhelper devscripts patchutils quilt git-buildpackage pristine-tar git yasm zlib1g-dev zlib-bin libzip-dev libx11-dev libx11-dev libxv-dev vstream-client-dev libgtk2.0-dev libpulse-dev libxxf86dga-dev x11proto-xf86dga-dev git libgstreamermm-0.10-dev libgstreamer0.10-dev automake libtool python-appindicator 

modprobe方式:
git clone https://github.com/dbason/crystalhd.git
cd crystalhd/driver/linux
autoconf
./configure
make
sudo make install
cd ../../linux_lib/libcrystalhd/
make
sudo make install
sudo make -C firmware install
sudo modprobe crystalhd

dkms方式:
git clone https://github.com/dbason/crystalhd.git /usr/src/
mv /usr/src/crystalhd /usr/src/crystalhd-0.1
cd /usr/src/crystalhd-0.1/linux_lib/libcrystalhd/
make
sudo make install
dkms add -m crystalhd -v 0.1
dkms build -m crystalhd -v 0.1
dkms install -m crystalhd -v 0.1

cp -f /usr/src/crystalhd-0.1/driver/linux/20-crystalhd.rules /lib/udev/rules.d/ <--勿省略,以免非root使用者無法開啟設備

2.檢查crystal hd是否有正確載入driver:
lsmod | grep crystalhd
-> crystalhd 110592 0

dmesg | grep crystalhd
->...
->[810.638520] crystalhd 0000:02:00.0 Starting Device:0x1615

3.安裝smplayer, mpv, gstreamer1.0-crystalhd, libcrystalhd3
apt-get install smplayer mpv gstreamer1.0-crystalhd libcrystalhd3
(VLC測試撥放會說 buffer deadlock prevented 而失敗,因此改用smplayer+mpv)

4 .重開機,抓個測試影片來測試:
http://jell.yfish.us/media/jellyfish-40-mbps-hd-h264.mkv
直接先用mpv來撥放(其中--vo=可改gl, sdl, xv試試):
mpv --hwdec=crystalhd --vo=gl jellyfish-40-mbps-hd-h264.mkv
-> DtsDeviceOpen: Opeining HW in mode 0
-> Enable single threaded mode

使用smplayer透過mpv播放:
exit(離開root bash)
smplayer(開啟smplayer)
Options/Preferences/General
General/Multimedia engine: mpv

Options/Preferences/Performance
Allow frame drop 勾選
Allow hard frame drop 勾選
Performance/Decoding/Hardware decoding: crystalhd

再用smplayer播放 jellyfish-40-mbps-hd-h264.mkv
檢視選單 View/Mplayer/mpv log
看看是否有跟mpv播放一樣的log

或者改直接播youtube試試:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
mpv --hwdec=crystalhd https://www.youtube.com/watch?v=i0p1bmr0EmE

5.若要移除cyrstalhd driver, 可照以下步驟:
modprobe:
modprobe -r crystalhd

dkms:
dkms remove crystalhd/0.1 --all

不過最後發現i915內顯驅動似乎仍有問題,造成opengl輸出的buffer無法建立,因此1080p用硬解後mpv播放反而更卡...後來發現改用smplayer+mplayer播放超順!算了就這樣吧 囧

ref:
https://wiki.archlinux.org/index.php/Intel_graphics
https://gist.github.com/Brainiarc7/aa43570f512906e882ad6cdd835efe57
http://rocksaying.tw/archives/2015/Linux_DKMS_%E6%A9%9F%E5%88%B6%E5%B0%8E%E5%85%A5%E7%AD%86%E8%A8%98.html
https://kodi.wiki/view/Broadcom_Crystal_HD
https://www.pcdvd.com.tw//showthread.php?t=906270&page=1&pp=10
https://github.com/dbason/crystalhd
https://github.com/agx/libcrystalhd/blob/master/src/libcrystalhd_if.c
http://jell.yfish.us/
https://askubuntu.com/questions/1082499/how-to-get-and-install-intel-i915-drivers-on-ubuntu-18-04
https://wiki.archlinux.org/index.php/Mpv_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
https://mpv.io/manual/stable/#video-output-drivers

沒有留言:

張貼留言