Minor adjustments
[ikiwiki.git] / docs / handbook / 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 If you have trouble with the laptop recognizing the touchpad, try moving the ig4, cyapa, and atmel module loads into /etc/rc.local (kldload'ing the modules from /etc/rc.local).  It is unclear to me why there are sometimes issues initializing the drivers in early boot.
17
18 ### WIFI setup
19
20 For WIFI support you will want this in your "/etc/rc.conf"
21
22     wlans_ath0="wlan0"
23     ifconfig_wlan0="DHCP WPA"
24
25 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:
26
27     network={
28         ssid="blahblah"
29         psk="passwordhere"
30     }
31
32 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.
33
34 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.
35
36 ### Disabling the power button
37
38 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:
39
40     sysctl hw.acpi.power_button_state=NONE
41
42 You can put 'hw.acpi.power_button_state=NONE' in /etc/sysctl.conf to make this automatic on startup.
43
44 ### dbus setup
45
46 Newer versions of firefox do not start dbus automatically, so we recommend starting it up from /etc/rc.conf with this entry:
47
48     dbus_enable="YES"
49
50 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.
51
52 ### Sound Setup
53
54 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.
55
56 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.
57
58 ### X11 Setup
59
60 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:
61
62     pkg install xorg-apps
63     pkg install xorg-docs
64     pkg install xorg-fonts
65     pkg install xorg-libraries
66     pkg install xorg-macros
67     pkg install xorg-drivers
68     pkg install xorg-server
69     pkg install xdm
70     pkg install firefox
71     (also install your favorite apps, GUIs, window managers, whatever)
72
73 The base intel driver in xorg-drivers needs to be replaced with the intel29 driver from dports.  As the X11 work has progressed this has become easier so now you just need to install the package:
74
75     pkg install xf86-video-intel29
76
77 The "/etc/X11/xorg.conf" configuration file should consist of the following.  If you have trouble getting the keyboard to work you may have to mess around with the keyboard settings.  But this should work.
78
79     Section "ServerLayout"
80             Identifier     "X.org Configured"
81             Screen      1  "Screen0" 0 0
82             InputDevice    "Mouse0" "CorePointer"
83             InputDevice    "Mouse1" "SendCoreEvents"
84             InputDevice    "TouchScreen0" "SendCoreEvents"
85             InputDevice    "Keyboard0" "CoreKeyboard"
86     EndSection
87
88     # This may be needed to prevent X from ignoring keyboard
89     # and mouse devices in xorg.conf.
90     #
91     Section "ServerFlags"
92             Option "AutoAddDevices" "False"
93     EndSection
94
95     Section "Files"
96             ModulePath   "/usr/local/lib/xorg/modules"
97             FontPath     "/usr/local/lib/X11/fonts/misc/"
98             FontPath     "/usr/local/lib/X11/fonts/TTF/"
99             FontPath     "/usr/local/lib/X11/fonts/OTF/"
100             FontPath     "/usr/local/lib/X11/fonts/Type1/"
101             FontPath     "/usr/local/lib/X11/fonts/100dpi/"
102             FontPath     "/usr/local/lib/X11/fonts/75dpi/"
103     EndSection
104
105     Section "Module"
106             Load  "dbe"
107             Load  "dri"
108             Load  "dri2"
109             Load  "extmod"
110             Load  "record"
111             Load  "glx"
112     EndSection
113
114     # Depending on how your keyboard probes, you may have to change this.
115     #
116     Section "InputDevice"
117             Identifier  "Keyboard0"
118             Driver      "kbd"
119     EndSection
120
121     Section "InputDevice"
122             Identifier  "Mouse0"
123             Driver      "mouse"
124             Option          "Protocol" "imps/2"
125             Option          "Device" "/dev/cyapa0-67"
126     EndSection
127
128     Section "InputDevice"
129             Identifier  "Mouse1"
130             Driver      "mouse"
131             Option          "Protocol" "auto"
132             Option          "Device" "/dev/sysmouse"
133             Option          "ZAxisMapping" "4 5"
134     EndSection
135
136     Section "InputDevice"
137             Identifier  "TouchScreen0"
138             Driver      "elographics"
139             Option          "Device" "/dev/atmel1-4a"
140     #   Option      "ZAxisMapping" "4 5 6 7"
141     EndSection
142
143     Section "Monitor"
144             Identifier   "Monitor0"
145             VendorName   "Monitor Vendor"
146             ModelName    "Monitor Model"
147     EndSection
148
149     Section "Device"
150             #Option     "NoAccel" "true"                # [<bool>]
151             #Option     "AccelMethod"           # <str>
152             #Option     "Backlight"             # <str>
153             #Option     "DRI"                   # <str>
154             Identifier  "Card0"
155             Driver      "intel"
156             #Option     "ReprobeOutputs" "true"
157             #BusID      "PCI:0:2:0"
158     EndSection
159
160     Section "Screen"
161             Identifier "Screen0"
162             Device     "Card0"
163             Monitor    "Monitor0"
164             SubSection "Display"
165                     Depth     1
166             EndSubSection
167             SubSection "Display"
168                     Depth     4
169             EndSubSection
170             SubSection "Display"
171                     Depth     8
172             EndSubSection
173             SubSection "Display"
174                     Depth     15
175             EndSubSection
176             SubSection "Display"
177                     Depth     16
178             EndSubSection
179             SubSection "Display"
180                     Depth     24
181             EndSubSection
182     EndSection
183
184 For the touchscreen to work, you need to install the "xf86-input-elographics" driver:
185
186     pkg install xf86-input-elographics
187
188 See 
189 [these](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198982.html) 
190 [commits](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198985.html) 
191 [for](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198994.html) 
192 [details](http://lists.dragonflybsd.org/pipermail/commits/2014-January/198995.html) 
193 on how to simulate left, right, and middle clicks with the touchpad, and also support simulated mousewheel scrolling.
194
195 We suggest [starting X via xdm](http://www.dragonflybsd.org/docs/newhandbook/X/#index4h3) which needs a package in addition to xorg:
196
197     pkg install xdm
198
199 ### Further Mouse Setup
200
201 We recommend using moused and /dev/sysmouse to handle external USB mouse attachments.  By using moused, mice can be plugged and unplugged without imploding X11.  Try putting this in your /etc/rc.conf:
202
203     moused_enable="YES"
204
205 If that doesn't work then set moused_enable="NO" in /etc/rc.conf and start moused manually in /etc/rc.local:
206
207     moused -p /dev/ums0
208     moused -p /dev/ums1
209
210 ### Touchpad and Touchscreen problems
211
212 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.
213
214 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.
215
216 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.
217
218 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. 
219
220 ### Volume and backlight adjustment keys
221 In order to use these keys make two scripts:
222
223     #!/bin/csh
224     #
225     # mute script
226     
227     set curvol = "`mixer -f /dev/mixer1 -s vol`"
228     
229     if ( -f ~/.savemute ) then
230             set lastvol = "`cat ~/.savemute`"
231     else
232             set lastvol = ""
233     endif
234     
235     if ( "$curvol" == "vol 0:0" ) then
236             if ( "$lastvol" != "" ) then
237                     eval mixer -f /dev/mixer1 $lastvol
238             endif
239     else
240             if ( "$lastvol" != "$curvol" ) then
241                     echo "$curvol" > ~/.savemute
242             endif
243             mixer -f /dev/mixer1 vol 0
244     endif
245
246     #!/bin/csh
247     #
248     # backlight script
249     
250     set level = `sysctl -n hw.backlight_level`
251     @ level = $level + $argv
252     sysctl hw.backlight_level=${level}
253
254 add next lines to `~/.xbindkeysrc`:
255
256     # Volume
257     #
258     "/path/to/scripts/mute"
259       F8
260     
261     "mixer -f /dev/mixer1 vol -5"
262       F9
263     
264     "mixer -f /dev/mixer1 vol +5"
265       F10
266     
267     # Screen
268     #
269     "/path/to/scripts/backlight -20"
270       F6
271     
272     "/path/to/scripts/backlight 20"
273       F7
274
275 You must call xbindkeys somewhere in your `.xinitrc`.
276
277 *Hint:* You can set default blacklight level by placing next line in `.xinitrc`:
278
279     sysctl hw.backlight_level=370
280
281 ### Home, End, Delete, ...
282
283 With Alt as modifier you can get:
284
285 Insert    = Alt + \
286
287 Delete    = Alt + BackSpace
288
289 Home      = Alt + Left
290
291 End       = Alt + Right
292
293 PageUp    = Alt + Up
294
295 PageDown  = Alt + Down
296
297 Create dirs for keyboard configuration
298
299     mkdir -p ${HOME}/.config/xkb/types ${HOME}/.config/xkb/symbols
300
301 Create modifiers' config file `${HOME}/.config/xkb/types/c720` which contains
302
303     xkb_types "c720" {
304         virtual_modifiers Alt;
305         type "ARROW" {
306             modifiers    = Shift+Alt;
307             map[Shift]  = Level2;
308             map[Alt]    = Level3;
309             map[Alt+Shift]    = Level3;
310             level_name[Level1] = "Base";
311             level_name[Level2] = "Caps";
312             level_name[Level3] = "Alt";
313         };
314     };
315
316 Create symbols' config file `${HOME}/.config/xkb/symbols/c720` which contains
317
318     xkb_symbols "c720" {
319         key <BKSL> {
320             type="ARROW",
321             repeat=yes,
322             symbol[Group1] = [backslash, bar, Insert],
323             symbol[Group2] = [backslash, slash, Insert],
324             actions[Group1] = [
325                 NoAction(),
326                 NoAction(),
327                 RedirectKey(key=<INS>, clearmods=Alt)
328             ],
329             actions[Group2] = [
330                 NoAction(),
331                 NoAction(),
332                 RedirectKey(key=<INS>, clearmods=Alt)
333             ]
334         };
335         key <BKSP> {
336             type="ARROW",
337             repeat=yes,
338             [BackSpace, BackSpace, Delete],
339             actions[Group1] = [
340                 NoAction(),
341                 NoAction(),
342                 RedirectKey(key=<DELE>, clearmods=Alt)
343             ]
344         };
345         key <LEFT> {
346             type="ARROW",
347             [Left, Left, Home],
348             actions[Group1] = [
349                 NoAction(),
350                 NoAction(),
351                 RedirectKey(key=<HOME>, clearmods=Alt)
352             ]
353         };
354         key <RGHT> {
355             type="ARROW",
356             repeat=yes,
357             [Right, Right, End],
358             actions[Group1] = [
359                 NoAction(),
360                 NoAction(),
361                 RedirectKey(key=<END>, clearmods=Alt)
362             ]
363         };
364         key <UP> {
365             type="ARROW",
366             repeat=yes,
367             [Up, Up, Prior],
368             actions[Group1] = [
369                 NoAction(),
370                 NoAction(),
371                 RedirectKey(key=<PGUP>, clearmods=Alt)
372             ]
373         };
374         key <DOWN> {
375             type="ARROW",
376             [Down, Down, Next],
377             actions[Group1] = [
378                 NoAction(),
379                 NoAction(),
380                 RedirectKey(key=<PGDN>, clearmods=Alt)
381             ]
382         };
383     };
384
385 Add next line to `.xinitrc` (or in some autoload/autostart)
386
387     setxkbmap -layout "us+c720" -types "complete+c720" -print|xkbcomp -I"$HOME/.config/xkb" - "${DISPLAY%%.*}"
388  
389 ### Power savings
390
391 This sysctl setting tells the Chromebook to automatically go to the best power state it can:
392
393     sysctl machdep.mwait.CX.idle=AUTODEEP
394
395 WARNING!  We have recently come to believe that this mode may cause chromebooks lockup on disk I/O (AHCI), so if you get lockups please try without setting this mode.
396