Ubuntu11.10で録画用サーバ
Ubuntuを11.10にアップグレードしたのでその作業ログ。
必要なパッケージのインストール
sudo aptitude -y install ntp sudo aptitude -y install mercurial sudo aptitude -y install build-essential linux-headers-`uname -r` sudo aptitude -y install autoconf pkg-config sudo aptitude -y install php5 php5-mysql sudo aptitude -y install ffmpeg
後述するが、以下の操作はまだしなくて良い。
sudo aptitude -y install libccid pcsc-tools pcscd
時刻合わせ
/etc/ntp.conf の server をコメントアウトして、
server ntp.nict.jp server ntp.nict.jp server ntp.nict.jp
とかに。
sudo service ntp stop sudo ntpdate ntp.nict.jp sudo service ntp start
で即時調整。
ドライバのインストール
http://baalzephon.dyndns.org/tech/index.php?Linux%2Fテレビ関連%2FPT2
を参考に。
hg clone http://hg.honeyplanet.jp/pt1.oyama/ pt1_driver_oyama cd pt1_driver_oyama hg revert -r c44e16dbb0e2 --all hg revert -r tip --all
patchを適用。
cd driver patch < pt1_pci.c.patch make sudo make install
pt1_pci.c.patch
長い空白はTABだったりします。
--- a/driver/pt1_pci.c Sun Oct 24 21:50:50 2010 +0900 +++ b/driver/pt1_pci.c Tue Nov 01 21:47:13 2011 +0900 @@ -18,6 +18,13 @@ #include <linux/mutex.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) #include <linux/freezer.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +#include <linux/spinlock.h> +#else +#include <linux/smp_lock.h> +#endif +#endif #else #define set_freezable() #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) @@ -76,6 +83,7 @@ #define DMA_SIZE 4096 // DMAバッファサイズ #define DMA_RING_SIZE 128 // RINGサイズ #define DMA_RING_MAX 511 // 1RINGにいくつ詰めるか(1023はNGで511まで) +#define MAX_READ_SIZE (1024 * 4) #define CHANEL_DMA_SIZE (2*1024*1024) // 地デジ用(16Mbps) #define BS_CHANEL_DMA_SIZE (4*1024*1024) // BS用(32Mbps) @@ -144,6 +152,10 @@ #define PT1MAJOR 251 #define DRIVERNAME "pt1video" +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static spinlock_t pt1_ioctl_spin_lock; +#endif + static void reset_dma(PT1_DEVICE *dev_conf) { @@ -309,12 +321,12 @@ // 頻度を落す(4Kで起動させる) for(lp = 0 ; lp < MAX_CHANNEL ; lp++){ channel = dev_conf->channel[real_channel[lp]] ; - if((channel->size >= DMA_SIZE) && (channel->valid == TRUE)){ + if((channel->size >= MAX_READ_SIZE) && (channel->valid == TRUE)){ wake_up(&channel->wait_q); } } } - schedule_timeout_interruptible(msecs_to_jiffies(1)); + schedule_timeout_interruptible(msecs_to_jiffies(10)); } return 0 ; } @@ -403,9 +415,9 @@ __u32 size ; unsigned long dummy; - // 4K単位で起こされるのを待つ(CPU負荷対策) - if(channel->size < DMA_SIZE){ - wait_event_timeout(channel->wait_q, (channel->size >= DMA_SIZE), + // 128K単位で起こされるのを待つ(CPU負荷対策) + if(channel->size < MAX_READ_SIZE){ + wait_event_timeout(channel->wait_q, (channel->size >= MAX_READ_SIZE), msecs_to_jiffies(500)); } mutex_lock(&channel->lock); @@ -568,6 +580,25 @@ return -EINVAL; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) +static long pt1_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + long rc; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + spin_lock(&pt1_ioctl_spin_lock); +#else + lock_kernel(); +#endif + rc = pt1_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + spin_unlock(&pt1_ioctl_spin_lock); +#else + unlock_kernel(); +#endif + return rc; +} +#endif /* */ static const struct file_operations pt1_fops = { @@ -575,7 +606,11 @@ .open = pt1_open, .release = pt1_release, .read = pt1_read, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + .unlocked_ioctl = pt1_unlocked_ioctl, +#else .ioctl = pt1_ioctl, +#endif .llseek = no_llseek, }; @@ -964,14 +999,17 @@ pt1video_class = class_create(THIS_MODULE, DRIVERNAME); if (IS_ERR(pt1video_class)) return PTR_ERR(pt1video_class); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + spin_lock_init(&pt1_ioctl_spin_lock); +#endif return pci_register_driver(&pt1_driver); } static void __exit pt1_pci_cleanup(void) { + pci_unregister_driver(&pt1_driver); class_destroy(pt1video_class); - pci_unregister_driver(&pt1_driver); } module_init(pt1_pci_init);
録画用プログラムのインストール
これは必要ありません。
cd pt1_driver_oyama/arib25 make sudo make install cd ../recpt1 make sudo make install
modprobe
/etc/modprobe.d/blacklist.conf
の末尾に
blacklist earth-pt1
と追記。その後
sudo modprobe pt1_drv
録画テスト
recpt1 --b25 --strip 27 5 test.ts
これで
bcas->init failed Cannot start b25 decoder Fall back to encrypted recording
と表示されることがある。
http://postcard.blog.ocn.ne.jp/itazura/2011/05/ubuntu_1104natt.html とか Ubuntu 11.04 AMD64にPT2をインストールする。:覚え書きその他:So-netブログ を参考に、
/etc/apt/sources.list
の末尾に
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu maverick main universe deb-src http://ftp.jaist.ac.jp/pub/Linux/ubuntu maverick main universe deb http://security.ubuntu.com/ubuntu maverick-security main universe deb-src http://security.ubuntu.com/ubuntu maverick-security main universe
とか追記。
sudo aptitude update sudo aptitude remove pcscd libpcsclite-dev libpcsclite1 libccid libpcsc-perl pcsc-tools sudo aptitude install pcscd=1.5.5-3ubuntu2.1 libpcsclite1=1.5.5-3ubuntu2.1 libccid=1.3.11-1 libpcsc-perl=1.4.8-1 pcsc-tools=1.4.16-1 sudo cp /etc/libccid_Info.plist{.dpkg-dist,} sudo aptitude hold pcscd libpcsclite-dev libpcsclite1 libccid libpcsc-perl pcsc-tools
epgrec新BSチャンネル対応版
パッケージ 2011年10月1日からのBS新チャンネル対応ファイル群 - epgrec - OSDNからダウンロード。
recpt1
cd pt1-7662d0ecd74b/recpt1 sudo make -B install
epgdump
cd epgdumpr2 make -B sudo install -m 0755 epgdump /usr/local/bin