2010年10月13日 星期三

Ubuntu切換外接video的hotkey作法

首先evdev driver必須從kernel input event得到正確的keycode,在/usr/include/linux/input.h定義為:
#define KEY_SWITCHVIDEOMODE     227


然後在xkb-data套件中定義了kernel keycode到X keycode的mapping:在/usr/share/X11/xkb/keycodes/evdev裡:
<I235> = 235;   // #define KEY_SWITCHVIDEOMODE     227


在/usr/share/X11/xkb/symbols/inet裡:
key <I235>   {      [ XF86Display           ]       };


於是當切換外接video的hotkey按下後,也就是scancode產生時,kernel input event會產生出值為227的keycode,evdev讀到之後,Xserver再依據xkbdata的設定轉換為XF86Display。

接下來gnome-settings-daemon會filter這個X key,如gnome-settings-daemon-2.32.0/plugins/xrandr/gsd-xrandr-manager.c:

if (xev->xany.type == KeyPress) {
if (xev->xkey.keycode == manager->priv->switch_video_mode_keycode)
handle_fn_f7 (manager, xev->xkey.time);
else if (xev->xkey.keycode == manager->priv->rotate_windows_keycode)
handle_rotate_windows (manager, xev->xkey.time);


g-s-d每收到一個XF86Display key時,會呼叫gnome-rr-* 相關的函式(請見libgnomeui/gnome-rr.h),透過RandR API切換螢幕顯示的設定,便會切換到如外接投影機等顯示設備。

參考:http://live.gnome.org/RandR

2010年10月6日 星期三

Kernel: 不列入git log的changelog

對Linux kernel或LKML來說,git log是十分正式的紀錄。不過還是有些時候,我們只想寫一些對於這個patch的意見、或是給subsystem maintainer的一些參考說明,這些東西就不是那麼適合列入正式的git log中。

一個常見的情況是maintainer對於你的patch會有不同意見,此時可能會有patch v2, v3...的出現,而這些版本之間如果可以有簡單的說明的話,對於patch review會有很大的幫助。

像是這些「非正式性」的log,可以被紀錄在diffstat之後,如:

From 1709e3f1b68a12ce05039a52182288d0f4e21c7a Mon Sep 17 00:00:00 2001
From: Keng-Yu Lin <keng-yu.lin@canonical.com>
Date: Tue, 28 Sep 2010 11:11:57 +0800
Subject: [PATCH v5] dell-laptop: Add debugfs support

Export the status of RF killswitch through debugfs.

The killswitch status is obtained by the SMI to BIOS. Exporting this status
through debugfs can help identify the issue with the misbehaving firmware.

Signed-off-by: Keng-Yu Lin <keng-yu.lin@canonical.com>
---
drivers/platform/x86/dell-laptop.c | 77 ++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)

V5 fixed operator precedence mess-up of hwswitch_state, and prints the
bit number so that this debug info is complete for hardare manufacturers.


diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
index 4413975..cf8a89a 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
(下略)
Patchwork: https://patchwork.kernel.org/patch/213982/

而在Linux Documentation/SubmittingPatches Section 1.15中也有說明:
Other comments relevant only to the moment or the maintainer, not suitable for the permanent changelog, should also go here. A good example of such comments might be "patch changelogs" which describe what has changed between the v1 and v2 version of the patch.

在live-helper config中加入自訂的套件

將要預設安裝的套件放在config/chroot_local-packages目錄中即可。

參考:Debian Live Manual 6.3.1 Using chroot_local-packages to install custom packages

在live-helper config中加入private PPA

首先確定在config目錄中的bootstrap有這一行:

LH_BOOTSTRAP_INCLUDE="apt-transport-https"


因為private PPA是透過HTTPS。

然後在config/chroot_sources/把PPA的source list加入在myppa.chroot當中。

接下來要加入PPA的public key,將它存在同一個目錄的myppa.chroot.gpg檔案中:

apt-key adv --recv-key <KEYID>
apt-key export <KEYID> > myppa.chroot.gpg


這樣lh build時應該就能加入private PPA。