1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright © 2023 Intel Corporation
4 */
5
6 #include "intel_display_params.h"
7 #include "i915_drv.h"
8
9 #define intel_display_param_named(name, T, perm, desc) \
10 module_param_named(name, intel_display_modparams.name, T, perm); \
11 MODULE_PARM_DESC(name, desc)
12 #define intel_display_param_named_unsafe(name, T, perm, desc) \
13 module_param_named_unsafe(name, intel_display_modparams.name, T, perm); \
14 MODULE_PARM_DESC(name, desc)
15
16 static struct intel_display_params intel_display_modparams __read_mostly = {
17 #define MEMBER(T, member, value, ...) .member = (value),
18 INTEL_DISPLAY_PARAMS_FOR_EACH(MEMBER)
19 #undef MEMBER
20 };
21 /*
22 * Note: As a rule, keep module parameter sysfs permissions read-only
23 * 0400. Runtime changes are only supported through i915 debugfs.
24 *
25 * For any exceptions requiring write access and runtime changes through module
26 * parameter sysfs, prevent debugfs file creation by setting the parameter's
27 * debugfs mode to 0.
28 */
29
30 intel_display_param_named_unsafe(dmc_firmware_path, charp, 0400,
31 "DMC firmware path to use instead of the default one. "
32 "Use /dev/null to disable DMC and runtime PM.");
33
34 intel_display_param_named_unsafe(vbt_firmware, charp, 0400,
35 "Load VBT from specified file under /lib/firmware");
36
37 intel_display_param_named_unsafe(lvds_channel_mode, int, 0400,
38 "Specify LVDS channel mode "
39 "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
40
41 intel_display_param_named_unsafe(panel_use_ssc, int, 0400,
42 "Use Spread Spectrum Clock with panels [LVDS/eDP] "
43 "(default: auto from VBT)");
44
45 intel_display_param_named_unsafe(vbt_sdvo_panel_type, int, 0400,
46 "Override/Ignore selection of SDVO panel mode in the VBT "
47 "(-2=ignore, -1=auto [default], index in VBT BIOS table)");
48
49 intel_display_param_named_unsafe(enable_dc, int, 0400,
50 "Enable power-saving display C-states. "
51 "(-1=auto [default]; 0=disable; 1=up to DC5; 2=up to DC6; "
52 "3=up to DC5 with DC3CO; 4=up to DC6 with DC3CO)");
53
54 intel_display_param_named_unsafe(enable_dpt, bool, 0400,
55 "Enable display page table (DPT) (default: true)");
56
57 intel_display_param_named_unsafe(enable_dsb, bool, 0400,
58 "Enable display state buffer (DSB) (default: true)");
59
60 intel_display_param_named_unsafe(enable_sagv, bool, 0400,
61 "Enable system agent voltage/frequency scaling (SAGV) (default: true)");
62
63 intel_display_param_named_unsafe(disable_power_well, int, 0400,
64 "Disable display power wells when possible "
65 "(-1=auto [default], 0=power wells always on, 1=power wells disabled when possible)");
66
67 intel_display_param_named_unsafe(enable_ips, bool, 0400, "Enable IPS (default: true)");
68
69 intel_display_param_named_unsafe(invert_brightness, int, 0400,
70 "Invert backlight brightness "
71 "(-1 force normal, 0 machine defaults, 1 force inversion), please "
72 "report PCI device ID, subsystem vendor and subsystem device ID "
73 "to dri-devel@lists.freedesktop.org, if your machine needs it. "
74 "It will then be included in an upcoming module version.");
75
76 /* WA to get away with the default setting in VBT for early platforms.Will be removed */
77 intel_display_param_named_unsafe(edp_vswing, int, 0400,
78 "Ignore/Override vswing pre-emph table selection from VBT "
79 "(0=use value from vbt [default], 1=low power swing(200mV),"
80 "2=default swing(400mV))");
81
82 intel_display_param_named(enable_dpcd_backlight, int, 0400,
83 "Enable support for DPCD backlight control"
84 "(-1=use per-VBT LFP backlight type setting [default], 0=disabled, 1=enable, 2=force VESA interface, 3=force Intel interface)");
85
86 intel_display_param_named_unsafe(load_detect_test, bool, 0400,
87 "Force-enable the VGA load detect code for testing (default:false). "
88 "For developers only.");
89
90 intel_display_param_named_unsafe(force_reset_modeset_test, bool, 0400,
91 "Force a modeset during gpu reset for testing (default:false). "
92 "For developers only.");
93
94 intel_display_param_named(disable_display, bool, 0400,
95 "Disable display (default: false)");
96
97 intel_display_param_named(verbose_state_checks, bool, 0400,
98 "Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions.");
99
100 intel_display_param_named_unsafe(nuclear_pageflip, bool, 0400,
101 "Force enable atomic functionality on platforms that don't have full support yet.");
102
103 intel_display_param_named_unsafe(enable_dp_mst, bool, 0400,
104 "Enable multi-stream transport (MST) for new DisplayPort sinks. (default: true)");
105
106 intel_display_param_named_unsafe(enable_fbc, int, 0400,
107 "Enable frame buffer compression for power savings "
108 "(default: -1 (use per-chip default))");
109
110 intel_display_param_named_unsafe(enable_psr, int, 0400,
111 "Enable PSR "
112 "(0=disabled, 1=enable up to PSR1, 2=enable up to PSR2) "
113 "Default: -1 (use per-chip default)");
114
115 intel_display_param_named(psr_safest_params, bool, 0400,
116 "Replace PSR VBT parameters by the safest and not optimal ones. This "
117 "is helpful to detect if PSR issues are related to bad values set in "
118 " VBT. (0=use VBT parameters, 1=use safest parameters)"
119 "Default: 0");
120
121 intel_display_param_named_unsafe(enable_psr2_sel_fetch, bool, 0400,
122 "Enable PSR2 and Panel Replay selective fetch "
123 "(0=disabled, 1=enabled) "
124 "Default: 1");
125
126 intel_display_param_named_unsafe(enable_dmc_wl, bool, 0400,
127 "Enable DMC wakelock "
128 "(0=disabled, 1=enabled) "
129 "Default: 0");
130
131 __maybe_unused
_param_print_bool(struct drm_printer * p,const char * driver_name,const char * name,bool val)132 static void _param_print_bool(struct drm_printer *p, const char *driver_name,
133 const char *name, bool val)
134 {
135 drm_printf(p, "%s.%s=%s\n", driver_name, name, str_yes_no(val));
136 }
137
138 __maybe_unused
_param_print_int(struct drm_printer * p,const char * driver_name,const char * name,int val)139 static void _param_print_int(struct drm_printer *p, const char *driver_name,
140 const char *name, int val)
141 {
142 drm_printf(p, "%s.%s=%d\n", driver_name, name, val);
143 }
144
145 __maybe_unused
_param_print_uint(struct drm_printer * p,const char * driver_name,const char * name,unsigned int val)146 static void _param_print_uint(struct drm_printer *p, const char *driver_name,
147 const char *name, unsigned int val)
148 {
149 drm_printf(p, "%s.%s=%u\n", driver_name, name, val);
150 }
151
152 __maybe_unused
_param_print_ulong(struct drm_printer * p,const char * driver_name,const char * name,unsigned long val)153 static void _param_print_ulong(struct drm_printer *p, const char *driver_name,
154 const char *name, unsigned long val)
155 {
156 drm_printf(p, "%s.%s=%lu\n", driver_name, name, val);
157 }
158
159 __maybe_unused
_param_print_charp(struct drm_printer * p,const char * driver_name,const char * name,const char * val)160 static void _param_print_charp(struct drm_printer *p, const char *driver_name,
161 const char *name, const char *val)
162 {
163 drm_printf(p, "%s.%s=%s\n", driver_name, name, val);
164 }
165
166 #define _param_print(p, driver_name, name, val) \
167 _Generic(val, \
168 bool : _param_print_bool, \
169 int : _param_print_int, \
170 unsigned int : _param_print_uint, \
171 unsigned long : _param_print_ulong, \
172 char * : _param_print_charp)(p, driver_name, name, val)
173
174 /**
175 * intel_display_params_dump - dump intel display modparams
176 * @display: display device
177 * @p: the &drm_printer
178 *
179 * Pretty printer for i915 modparams.
180 */
intel_display_params_dump(struct intel_display * display,struct drm_printer * p)181 void intel_display_params_dump(struct intel_display *display, struct drm_printer *p)
182 {
183 #define PRINT(T, x, ...) _param_print(p, display->drm->driver->name, #x, display->params.x);
184 INTEL_DISPLAY_PARAMS_FOR_EACH(PRINT);
185 #undef PRINT
186 }
187
_param_dup_charp(char ** valp)188 __maybe_unused static void _param_dup_charp(char **valp)
189 {
190 *valp = kstrdup(*valp ? *valp : "", GFP_ATOMIC);
191 }
192
_param_nop(void * valp)193 __maybe_unused static void _param_nop(void *valp)
194 {
195 }
196
197 #define _param_dup(valp) \
198 _Generic(valp, \
199 char ** : _param_dup_charp, \
200 default : _param_nop) \
201 (valp)
202
intel_display_params_copy(struct intel_display_params * dest)203 void intel_display_params_copy(struct intel_display_params *dest)
204 {
205 *dest = intel_display_modparams;
206 #define DUP(T, x, ...) _param_dup(&dest->x);
207 INTEL_DISPLAY_PARAMS_FOR_EACH(DUP);
208 #undef DUP
209 }
210
_param_free_charp(char ** valp)211 __maybe_unused static void _param_free_charp(char **valp)
212 {
213 kfree(*valp);
214 *valp = NULL;
215 }
216
217 #define _param_free(valp) \
218 _Generic(valp, \
219 char ** : _param_free_charp, \
220 default : _param_nop) \
221 (valp)
222
223 /* free the allocated members, *not* the passed in params itself */
intel_display_params_free(struct intel_display_params * params)224 void intel_display_params_free(struct intel_display_params *params)
225 {
226 #define FREE(T, x, ...) _param_free(¶ms->x);
227 INTEL_DISPLAY_PARAMS_FOR_EACH(FREE);
228 #undef FREE
229 }
230