add panel self refresh and explain the sysctl cpu idle states a little bettere.
[ikiwiki.git] / docs / handbook / docs / handbook / DellXPS9360 / index.mdwn
1 ## Dell XPS 9360 (and similar) Configuration
2
3 DragonFlyBSD will run on the newer Dell XPS's such as the 9360, with a little work.  There are two major issues with this laptop.  The first is that the BIOS ACPI appears to implode when the USB driver is loaded via the normal boot sequence.  The second is that we do not yet support the Atheros 10k Wifi built into the laptop.  There are two solutions to these problems.  A third problem appears to be that the I2C chipset fails to probe, but it doesn't look like anything needs it.
4
5 ### General bootstrapping and initial configuration files
6
7 (0) BIOS Setup issues
8
9     Set the SSD controlled to AHCI.
10
11     You may have to mess with the function key mode to make the F1...F12 keys all work as expected.
12
13     Disable secure boot.  Recommend EFI boot.  No need to enable legacy booting.  Make sure you can boot from USB for the initial bootstrap.
14
15     Bootstrap DragonFlyBSD via a usb boot.  Just install normally.  Note that on the Dell XPS series, Dell apparently only supports M.2 SSDs (AHCI), and does not support NVMe SSDs.  We support NVMe, but Dell apparently does not.
16
17 (1) Your /boot/loader.conf should disable xhci loading and should NOT load the ig4 driver.  You can preload the sound drivers, and you will also need to set a kenv variable to enable the urtwn driver's firmware loading.  You can also turn on panel self refresh mode for i915, which will slightly reduce dram and cpu power consumption:
18
19     #ig4_load="YES" (commented out)
20     unset xhci_load
21     sound_load="YES"
22     snd_hda_load="YES"
23     legal.realtek.license_ack=1
24     drm.i915.enable_psr=1
25
26 (2) You will have to buy a USB wifi module.  I use a Realtek RTL8188CUS based USB dongle.  For example, the Plugable USB 2.0 Wireless Nano.  Make sure it uses the correct chipset.
27
28     I suggest the RTL8188CUS based wifi usb dongle (appears to work well on the 2.4 GHz band, but doesn't seem to see 5.0 GHz).
29
30     Plug the dongle into the left port for maximum bandwidth
31
32 (3) You will want to run a few things in /etc/rc.local:
33
34     moused -p /dev/psm0
35     kldload xhci
36     cd /etc/rc.d
37     sleep 8
38     echo "starting network"
39     sh netif start
40
41 (4) Your /etc/rc.conf should nominally contain your network setup:
42
43     wlans_urtwn0="wlan0"
44     ifconfig_wlan0="DHCP WPA"
45
46     # Also recommend 
47
48     sshd_enable="YES"
49     dbus_enable="YES"
50     dntpd_enable="YES"
51
52 (5) Create an /etc/wpa_supplicant.conf file for your wifi connection.
53
54     network={
55         ssid="ssidhere"
56         psk="wpapasswordhere"
57     }
58
59 ### X Setup
60
61 X should just run and see the touchpad and mouse.  No touchscreen support at the moment.  You will need to set up appropriate accounts and files.  The following packages are useful:
62
63     pkg install xorg-apps
64     pkg install xorg-docs
65     pkg install xorg-fonts
66     pkg install xorg-libraries
67     pkg install xorg-macros
68     pkg install xorg-drivers
69     pkg install xorg-server
70     pkg install xdm
71     pkg install dbus
72     pkg install xbindkeys
73     pkg install firefox
74     (also install your favorite apps, GUIs, window managers, whatever)
75
76 We suggest [starting X via xdm](http://www.dragonflybsd.org/docs/newhandbook/X/#index4h3) which needs a package in addition to xorg:
77
78     pkg install xdm
79
80 ### Further Mouse Setup
81
82 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.  I usually throw in two additional moused commands in /etc/rc.local:
83
84     moused -p /dev/ums0
85     moused -p /dev/ums1
86
87
88 ### Volume and backlight adjustment keys
89 In order to use these keys make two scripts:
90
91     #!/bin/csh
92     #
93     # mute script  "mute"
94     
95     set curvol = "`mixer -f /dev/mixer1 -s vol`"
96     
97     if ( -f ~/.savemute ) then
98             set lastvol = "`cat ~/.savemute`"
99     else
100             set lastvol = ""
101     endif
102     
103     if ( "$curvol" == "vol 0:0" ) then
104             if ( "$lastvol" != "" ) then
105                     eval mixer -f /dev/mixer1 $lastvol
106             endif
107     else
108             if ( "$lastvol" != "$curvol" ) then
109                     echo "$curvol" > ~/.savemute
110             endif
111             mixer -f /dev/mixer1 vol 0
112     endif
113
114     #!/bin/csh
115     #
116     # backlight script "backlight"
117     
118     set level = `sysctl -n hw.backlight_level`
119     @ level = $level + $argv
120     sysctl hw.backlight_level=${level}
121
122 add next lines to `~/.xbindkeysrc`:
123
124     # Volume
125     #
126     "/path/to/scripts/mute"
127       F8
128     
129     "mixer -f /dev/mixer1 vol -5"
130       F9
131     
132     "mixer -f /dev/mixer1 vol +5"
133       F10
134     
135     # Screen
136     #
137     "/path/to/scripts/backlight -100"
138       F6
139     
140     "/path/to/scripts/backlight 100"
141       F7
142
143 You must call xbindkeys somewhere in your `.xinitrc`.
144
145 *Hint:* You can set default blacklight level by placing next line in `.xinitrc`:
146
147     sysctl hw.backlight_level=7500
148
149 ### Home, End, Delete, ...
150
151 With Alt as modifier you can get:
152
153 Insert    = Alt + \
154
155 Delete    = Alt + BackSpace
156
157 Home      = Alt + Left
158
159 End       = Alt + Right
160
161 PageUp    = Alt + Up
162
163 PageDown  = Alt + Down
164
165 Create dirs for keyboard configuration
166
167     mkdir -p ${HOME}/.config/xkb/types ${HOME}/.config/xkb/symbols
168
169 Create modifiers' config file `${HOME}/.config/xkb/types/dell` which contains
170
171     xkb_types "dell" {
172         virtual_modifiers Alt;
173         type "ARROW" {
174             modifiers    = Shift+Alt;
175             map[Shift]  = Level2;
176             map[Alt]    = Level3;
177             map[Alt+Shift]    = Level3;
178             level_name[Level1] = "Base";
179             level_name[Level2] = "Caps";
180             level_name[Level3] = "Alt";
181         };
182     };
183
184 Create symbols' config file `${HOME}/.config/xkb/symbols/dell` which contains
185
186     xkb_symbols "dell" {
187         key <BKSL> {
188             type="ARROW",
189             repeat=yes,
190             symbol[Group1] = [backslash, bar, Insert],
191             symbol[Group2] = [backslash, slash, Insert],
192             actions[Group1] = [
193                 NoAction(),
194                 NoAction(),
195                 RedirectKey(key=<INS>, clearmods=Alt)
196             ],
197             actions[Group2] = [
198                 NoAction(),
199                 NoAction(),
200                 RedirectKey(key=<INS>, clearmods=Alt)
201             ]
202         };
203         key <BKSP> {
204             type="ARROW",
205             repeat=yes,
206             [BackSpace, BackSpace, Delete],
207             actions[Group1] = [
208                 NoAction(),
209                 NoAction(),
210                 RedirectKey(key=<DELE>, clearmods=Alt)
211             ]
212         };
213         key <LEFT> {
214             type="ARROW",
215             [Left, Left, Home],
216             actions[Group1] = [
217                 NoAction(),
218                 NoAction(),
219                 RedirectKey(key=<HOME>, clearmods=Alt)
220             ]
221         };
222         key <RGHT> {
223             type="ARROW",
224             repeat=yes,
225             [Right, Right, End],
226             actions[Group1] = [
227                 NoAction(),
228                 NoAction(),
229                 RedirectKey(key=<END>, clearmods=Alt)
230             ]
231         };
232         key <UP> {
233             type="ARROW",
234             repeat=yes,
235             [Up, Up, Prior],
236             actions[Group1] = [
237                 NoAction(),
238                 NoAction(),
239                 RedirectKey(key=<PGUP>, clearmods=Alt)
240             ]
241         };
242         key <DOWN> {
243             type="ARROW",
244             [Down, Down, Next],
245             actions[Group1] = [
246                 NoAction(),
247                 NoAction(),
248                 RedirectKey(key=<PGDN>, clearmods=Alt)
249             ]
250         };
251     };
252
253 Add next line to `.xinitrc` (or in some autoload/autostart)
254
255     setxkbmap -layout "us+dell" -types "complete+dell" -print|xkbcomp -I"$HOME/.config/xkb" - "${DISPLAY%%.*}"
256  
257 ### Power savings
258
259 This sysctl setting tells the Dell to automatically go to the best power state it can:
260
261     sysctl machdep.mwait.CX.idle=AUTODEEP
262
263 You can try these settings as well, put the one you want in your /etc/sysctl.conf so you don't have to run the sysctl on boot:
264
265 # in /etc/sysctl.conf
266 #
267 # enable one.  If you have lockup problems with AUTODEEP or C4/3, use C3/1.
268 # This adds a little wakeup latency but significant reduces cpu power consumption.
269 # YMMV.  Use C1/0 for max responsiveness and you don't care about power consumption.
270 #
271 machdep.mwait.CX.idle=AUTODEEP
272 #machdep.mwait.CX.idle=C4/3
273 #machdep.mwait.CX.idle=C3/1
274
275
276 WARNING!  We have recently come to believe that this mode may cause lockups on disk I/O (AHCI), so if you get lockups please try without setting this mode.
277