(no commit message)
[ikiwiki.git] / docs / newhandbook / ConfigChromebook / index.mdwn
1 ## Chromebook Config
2
3 DragonFly currently supports the Acer C720 and C720p Intel-haswell chromebook.  You must follow the linux directions on how to unlock the chromebook so non-chrome OSs can be installed.  Generally speaking, the linux directions get you to a point where you can boot any kernel via the built-in SeaBIOS.  Note that you can always restore your chromebook back to using chrome by following Google's directions on recovering a chromebook.
4
5 On the Acer C720 you need to load specific drivers to gain support for the touchpad and touchscreen.  You also need to load the sound drivers.  In "/boot/loader.conf" add:
6
7     ig4_load="YES"
8     cyapa_load="YES"
9     atmel_mxt_load="YES"
10     if_ath_load="YES"
11     sound_load="YES"
12     snd_hda_load="YES"
13
14 The atmel module is only needed for the touchscreen model.
15
16 ### WIFI setup
17
18 For WIFI support you will want this in your "/etc/rc.conf"
19
20     wlans_ath0="wlan0"
21     ifconfig_wlan0="DHCP WPA"
22
23 And your "/etc/wpa_supplicant.conf" file should contain entries for all the wifi basestations you can connect to.  Most typically an entry looks like this:
24
25     network={
26         ssid="blahblah"
27         psk="passwordhere"
28     }
29
30 Its easiest to just reboot after setting up the files rather than trying to start wpa_supplicant manually.  You can have multiple network={} elements in the config file.
31
32 Both 2.4 GHz and 5 GHz base stations will work.  5 GHz base stations may have a range issue though.  ifconfig wlan0 for more information.  Also make sure that your /etc/rc.conf does not have any setup for ath0, if you used the installer it might have done something.
33
34 ### Disabling the power button
35
36 The power button is a function key on the right and is very easy to hit accidently.  You can disable the power button with a sysctl:
37
38     sysctl hw.acpi.power_button_state=NONE
39
40 You can put 'hw.acpi.power_button_state=NONE' in /etc/sysctl.conf to make this automatic on startup.
41
42 ### dbus setup
43
44 Newer versions of firefox do not start dbus automatically, so we recommend starting it up from /etc/rc.conf with this entry:
45
46     dbus_enable="YES"
47
48 I think you can start it manually with 'dbus-daemon --system' if you do not want to reboot to pick it up from rc.conf.
49
50 ### Sound Setup
51
52 The sound and snd_hda drivers can be loaded from /boot/loader.conf, which we have already described above.  The C720[P] has two sound chips, one built into the Haswell cpu which drives the HDMI digital sound, and a Realtek AC0283 which drives the built-in speakers and headphones.
53
54 You should see /dev/dsp0 and /dev/dsp1 and the hw.snd.default_unit sysctl should already default to unit 1.  I suggest testing sound with mpg123 and your favorite MP3.  It should just work.  However, we've noticed that some C720Ps use the wrong chipid in the pciconf output (probably a BIOS issue) so if your machine only sees one sound device the driver might need a tweak.
55
56 ### X11 Setup
57
58 DragonFly supports accelerated X on Haswell cpus via the "intel" driver.  You no longer have to recompile the X server.  We recommend the following package sets:
59
60     pkg install xorg-apps
61     pkg install xorg-docs
62     pkg install xorg-fonts
63     pkg install xorg-libraries
64     pkg install xorg-macros
65     pkg install xorg-server
66     pkg install xdm
67     pkg install firefox
68     (also install your favorite apps, GUIs, whatever)
69
70 The base intel driver in xorg-drivers needs to be replaced with the intel29 driver from dports.  If you do not have dports setup, run 'make' from /usr and follow the instructions.  Do this after installing the base X packages to avoid pulling in unnecessary sources.
71
72     cd /usr/dports/x11-drivers/xf86-video-intel29
73     make
74     make reinstall
75
76 The "/etc/X11/xorg.conf" configuration file should consist of the following:
77
78     Section "ServerLayout"
79             Identifier     "X.org Configured"
80             Screen      1  "Screen0" 0 0
81             InputDevice    "Mouse0" "CorePointer"
82             InputDevice    "Mouse1" "SendCoreEvents"
83             InputDevice    "TouchScreen0" "SendCoreEvents"
84             InputDevice    "Keyboard0" "CoreKeyboard"
85     EndSection
86
87     # This may be needed to prevent X from ignoring keyboard
88     # and mouse devices in xorg.conf.
89     #
90     Section "ServerFlags"
91             Option "AutoAddDevices" "False"
92     EndSection
93
94     Section "Files"
95             ModulePath   "/usr/local/lib/xorg/modules"
96             FontPath     "/usr/local/lib/X11/fonts/misc/"
97             FontPath     "/usr/local/lib/X11/fonts/TTF/"
98             FontPath     "/usr/local/lib/X11/fonts/OTF/"
99             FontPath     "/usr/local/lib/X11/fonts/Type1/"
100             FontPath     "/usr/local/lib/X11/fonts/100dpi/"
101             FontPath     "/usr/local/lib/X11/fonts/75dpi/"
102     EndSection
103
104     Section "Module"
105             Load  "dbe"
106             Load  "dri"
107             Load  "dri2"
108             Load  "extmod"
109             Load  "record"
110             Load  "glx"
111     EndSection
112
113     Section "InputDevice"
114             Identifier  "Keyboard0"
115             Driver      "kbd"
116     EndSection
117
118     Section "InputDevice"
119             Identifier  "Mouse0"
120             Driver      "mouse"
121             Option          "Protocol" "imps/2"
122             Option          "Device" "/dev/cyapa0-67"
123     EndSection
124
125     Section "InputDevice"
126             Identifier  "Mouse1"
127             Driver      "mouse"
128             Option          "Protocol" "auto"
129             Option          "Device" "/dev/sysmouse"
130             Option          "ZAxisMapping" "4 5"
131     EndSection
132
133     Section "InputDevice"
134             Identifier  "TouchScreen0"
135             Driver      "elographics"
136             Option          "Device" "/dev/atmel1-4a"
137     #   Option      "ZAxisMapping" "4 5 6 7"
138     EndSection
139
140     Section "Monitor"
141             Identifier   "Monitor0"
142             VendorName   "Monitor Vendor"
143             ModelName    "Monitor Model"
144     EndSection
145
146     Section "Device"
147             #Option     "NoAccel" "true"                # [<bool>]
148             #Option     "AccelMethod"           # <str>
149             #Option     "Backlight"             # <str>
150             #Option     "DRI"                   # <str>
151             Identifier  "Card0"
152             Driver      "intel"
153             #Option     "ReprobeOutputs" "true"
154             #BusID      "PCI:0:2:0"
155     EndSection
156
157     Section "Screen"
158             Identifier "Screen0"
159             Device     "Card0"
160             Monitor    "Monitor0"
161             SubSection "Display"
162                     Depth     1
163             EndSubSection
164             SubSection "Display"
165                     Depth     4
166             EndSubSection
167             SubSection "Display"
168                     Depth     8
169             EndSubSection
170             SubSection "Display"
171                     Depth     15
172             EndSubSection
173             SubSection "Display"
174                     Depth     16
175             EndSubSection
176             SubSection "Display"
177                     Depth     24
178             EndSubSection
179     EndSection
180
181 For the touchscreen to work, you need to install the "xf86-input-elographics" driver:
182
183     pkg install xf86-input-elographics
184
185 See 
186 [these](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198982.html) 
187 [commits](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198985.html) 
188 [for](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198994.html) 
189 [details](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198995.html) 
190 on how to simulate left, right, and middle clicks with the touchpad, and also support simulated mousewheel scrolling.
191
192 We suggest [starting X via xdm](http://www.dragonflybsd.org/docs/newhandbook/X/#index4h3) which needs a package in addition to xorg:
193
194     pkg install xdm
195
196 ### Further Mouse Setup
197
198 We recommend using moused and /dev/sysmouse.  Try putting this in your /etc/rc.conf:
199
200     moused_enable="YES"
201
202 If that doesn't work then set moused_enable="NO" in /etc/rc.conf and start moused manually in /etc/rc.local:
203
204     moused -p /dev/ums0
205     moused -p /dev/ums1
206
207 ### Touchpad and Touchscreen problems
208
209 Some people seem to have jitter problems with either or both the touchpad and the touchscreen, even on linux-based systems and the original chomebook chrome install.  It depends on a number of factors and we aren't sure why it happens, but the problems seem to be at their worst when the laptop is sitting on a non-conductive (e.g. plastic) table with power connected.  The problems can sometimes be mitigated by doing a few touches, or placing the laptop on your lap, or on some other surface, or disconnecting the power.
210
211 The issue does not crop up on all C720[P]'s.  If the problem gets too annoying you may have to disable either or both the touchpad and touchscreen.
212
213 A secondary issue is that when the touchscreen is going bonkers it can cause X to get sludgy. If you have a refresh problem with X, it might be the touchscreen driver that is causing it.
214
215 I've seen jitter issues on my particular C720 and C720P occasionally but they go away completely if the laptop is sitting on a wood table or my lap. 
216
217 ### Volume and backlight adjustment keys
218 In order to use these keys make two scripts:
219
220     #!/bin/csh
221     #
222     # mute script
223     
224     set curvol = "`mixer -f /dev/mixer1 -s vol`"
225     
226     if ( -f ~/.savemute ) then
227             set lastvol = "`cat ~/.savemute`"
228     else
229             set lastvol = ""
230     endif
231     
232     if ( "$curvol" == "vol 0:0" ) then
233             if ( "$lastvol" != "" ) then
234                     eval mixer -f /dev/mixer1 $lastvol
235             endif
236     else
237             if ( "$lastvol" != "$curvol" ) then
238                     echo "$curvol" > ~/.savemute
239             endif
240             mixer -f /dev/mixer1 vol 0
241     endif
242
243     #!/bin/csh
244     #
245     # backlight script
246     
247     set level = `sysctl -n hw.backlight_level`
248     @ level = $level + $argv
249     sysctl hw.backlight_level=${level}
250
251 add next lines to `~/.xbindkeysrc`:
252
253     # Volume
254     #
255     "/path/to/scripts/mute"
256       F8
257     
258     "mixer -f /dev/mixer1 vol -5"
259       F9
260     
261     "mixer -f /dev/mixer1 vol +5"
262       F10
263     
264     # Screen
265     #
266     "/path/to/scripts/backlight -20"
267       F6
268     
269     "/path/to/scripts/backlight 20"
270       F7
271
272 You must call xbindkeys somewhere in your `.xinitrc`.
273
274 *Hint:* You can set default blacklight level by placing next line in `.xinitrc`:
275
276     sysctl hw.backlight_level=370
277
278 ### Home, End, Delete, ...
279
280 With Alt as modifier you can get:
281
282 Insert    = Alt + \
283
284 Delete    = Alt + BackSpace
285
286 Home      = Alt + Left
287
288 End       = Alt + Right
289
290 PageUp    = Alt + Up
291
292 PageDown  = Alt + Down
293
294 Create dirs for keyboard configuration
295
296     mkdir -p ${HOME}/.config/xkb/types ${HOME}/.config/xkb/symbols
297
298 Create modifiers' config file `${HOME}/.config/xkb/types/c720` which contains
299
300     xkb_types "c720" {
301         virtual_modifiers Alt;
302         type "ARROW" {
303             modifiers    = Shift+Alt;
304             map[Shift]  = Level2;
305             map[Alt]    = Level3;
306             map[Alt+Shift]    = Level3;
307             level_name[Level1] = "Base";
308             level_name[Level2] = "Caps";
309             level_name[Level3] = "Alt";
310         };
311     };
312
313 Create symbols' config file `${HOME}/.config/xkb/symbols/c720` which contains
314
315     xkb_symbols "c720" {
316         key <BKSL> {
317             type="ARROW",
318             repeat=yes,
319             symbol[Group1] = [backslash, bar, Insert],
320             symbol[Group2] = [backslash, slash, Insert],
321             actions[Group1] = [
322                 NoAction(),
323                 NoAction(),
324                 RedirectKey(key=<INS>, clearmods=Alt)
325             ],
326             actions[Group2] = [
327                 NoAction(),
328                 NoAction(),
329                 RedirectKey(key=<INS>, clearmods=Alt)
330             ]
331         };
332         key <BKSP> {
333             type="ARROW",
334             repeat=yes,
335             [BackSpace, BackSpace, Delete],
336             actions[Group1] = [
337                 NoAction(),
338                 NoAction(),
339                 RedirectKey(key=<DELE>, clearmods=Alt)
340             ]
341         };
342         key <LEFT> {
343             type="ARROW",
344             [Left, Left, Home],
345             actions[Group1] = [
346                 NoAction(),
347                 NoAction(),
348                 RedirectKey(key=<HOME>, clearmods=Alt)
349             ]
350         };
351         key <RGHT> {
352             type="ARROW",
353             repeat=yes,
354             [Right, Right, End],
355             actions[Group1] = [
356                 NoAction(),
357                 NoAction(),
358                 RedirectKey(key=<END>, clearmods=Alt)
359             ]
360         };
361         key <UP> {
362             type="ARROW",
363             repeat=yes,
364             [Up, Up, Prior],
365             actions[Group1] = [
366                 NoAction(),
367                 NoAction(),
368                 RedirectKey(key=<PGUP>, clearmods=Alt)
369             ]
370         };
371         key <DOWN> {
372             type="ARROW",
373             [Down, Down, Next],
374             actions[Group1] = [
375                 NoAction(),
376                 NoAction(),
377                 RedirectKey(key=<PGDN>, clearmods=Alt)
378             ]
379         };
380     };
381
382 Add next line to `.xinitrc` (or in some autoload/autostart)
383
384     setxkbmap -layout "us+c720" -types "complete+c720" -print|xkbcomp -I"$HOME/.config/xkb" - "${DISPLAY%%.*}"
385  
386 ### Power savings
387
388 This sysctl setting tells the Chromebook to automatically go to the best power state it can:
389
390     sysctl machdep.mwait.CX.idle=AUTODEEP