hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/drm/drm_modes.h
....@@ -48,7 +48,7 @@
4848 * @MODE_HSYNC: hsync out of range
4949 * @MODE_VSYNC: vsync out of range
5050 * @MODE_H_ILLEGAL: mode has illegal horizontal timings
51
- * @MODE_V_ILLEGAL: mode has illegal horizontal timings
51
+ * @MODE_V_ILLEGAL: mode has illegal vertical timings
5252 * @MODE_BAD_WIDTH: requires an unsupported linepitch
5353 * @MODE_NOMODE: no mode with a matching name
5454 * @MODE_NO_INTERLACE: interlaced mode not supported
....@@ -136,8 +136,24 @@
136136 .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
137137 .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
138138 .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
139
- .vscan = (vs), .flags = (f), \
140
- .base.type = DRM_MODE_OBJECT_MODE
139
+ .vscan = (vs), .flags = (f)
140
+
141
+/**
142
+ * DRM_SIMPLE_MODE - Simple display mode
143
+ * @hd: Horizontal resolution, width
144
+ * @vd: Vertical resolution, height
145
+ * @hd_mm: Display width in millimeters
146
+ * @vd_mm: Display height in millimeters
147
+ *
148
+ * This macro initializes a &drm_display_mode that only contains info about
149
+ * resolution and physical size.
150
+ */
151
+#define DRM_SIMPLE_MODE(hd, vd, hd_mm, vd_mm) \
152
+ .type = DRM_MODE_TYPE_DRIVER, .clock = 1 /* pass validation */, \
153
+ .hdisplay = (hd), .hsync_start = (hd), .hsync_end = (hd), \
154
+ .htotal = (hd), .vdisplay = (vd), .vsync_start = (vd), \
155
+ .vsync_end = (vd), .vtotal = (vd), .width_mm = (hd_mm), \
156
+ .height_mm = (vd_mm)
141157
142158 #define CRTC_INTERLACE_HALVE_V (1 << 0) /* halve V values for interlacing */
143159 #define CRTC_STEREO_DOUBLE (1 << 1) /* adjust timings for stereo modes */
....@@ -207,85 +223,21 @@
207223 */
208224 struct drm_display_mode {
209225 /**
210
- * @head:
211
- *
212
- * struct list_head for mode lists.
213
- */
214
- struct list_head head;
215
-
216
- /**
217
- * @base:
218
- *
219
- * A display mode is a normal modeset object, possibly including public
220
- * userspace id.
221
- *
222
- * FIXME:
223
- *
224
- * This can probably be removed since the entire concept of userspace
225
- * managing modes explicitly has never landed in upstream kernel mode
226
- * setting support.
227
- */
228
- struct drm_mode_object base;
229
-
230
- /**
231
- * @name:
232
- *
233
- * Human-readable name of the mode, filled out with drm_mode_set_name().
234
- */
235
- char name[DRM_DISPLAY_MODE_LEN];
236
-
237
- /**
238
- * @status:
239
- *
240
- * Status of the mode, used to filter out modes not supported by the
241
- * hardware. See enum &drm_mode_status.
242
- */
243
- enum drm_mode_status status;
244
-
245
- /**
246
- * @type:
247
- *
248
- * A bitmask of flags, mostly about the source of a mode. Possible flags
249
- * are:
250
- *
251
- * - DRM_MODE_TYPE_PREFERRED: Preferred mode, usually the native
252
- * resolution of an LCD panel. There should only be one preferred
253
- * mode per connector at any given time.
254
- * - DRM_MODE_TYPE_DRIVER: Mode created by the driver, which is all of
255
- * them really. Drivers must set this bit for all modes they create
256
- * and expose to userspace.
257
- * - DRM_MODE_TYPE_USERDEF: Mode defined via kernel command line
258
- *
259
- * Plus a big list of flags which shouldn't be used at all, but are
260
- * still around since these flags are also used in the userspace ABI.
261
- * We no longer accept modes with these types though:
262
- *
263
- * - DRM_MODE_TYPE_BUILTIN: Meant for hard-coded modes, unused.
264
- * Use DRM_MODE_TYPE_DRIVER instead.
265
- * - DRM_MODE_TYPE_DEFAULT: Again a leftover, use
266
- * DRM_MODE_TYPE_PREFERRED instead.
267
- * - DRM_MODE_TYPE_CLOCK_C and DRM_MODE_TYPE_CRTC_C: Define leftovers
268
- * which are stuck around for hysterical raisins only. No one has an
269
- * idea what they were meant for. Don't use.
270
- */
271
- unsigned int type;
272
-
273
- /**
274226 * @clock:
275227 *
276228 * Pixel clock in kHz.
277229 */
278230 int clock; /* in kHz */
279
- int hdisplay;
280
- int hsync_start;
281
- int hsync_end;
282
- int htotal;
283
- int hskew;
284
- int vdisplay;
285
- int vsync_start;
286
- int vsync_end;
287
- int vtotal;
288
- int vscan;
231
+ u16 hdisplay;
232
+ u16 hsync_start;
233
+ u16 hsync_end;
234
+ u16 htotal;
235
+ u16 hskew;
236
+ u16 vdisplay;
237
+ u16 vsync_start;
238
+ u16 vsync_end;
239
+ u16 vtotal;
240
+ u16 vscan;
289241 /**
290242 * @flags:
291243 *
....@@ -320,23 +272,7 @@
320272 * - DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF: frame split into left and
321273 * right parts.
322274 */
323
- unsigned int flags;
324
-
325
- /**
326
- * @width_mm:
327
- *
328
- * Addressable size of the output in mm, projectors should set this to
329
- * 0.
330
- */
331
- int width_mm;
332
-
333
- /**
334
- * @height_mm:
335
- *
336
- * Addressable size of the output in mm, projectors should set this to
337
- * 0.
338
- */
339
- int height_mm;
275
+ u32 flags;
340276
341277 /**
342278 * @crtc_clock:
....@@ -354,56 +290,97 @@
354290 * difference is exactly a factor of 10.
355291 */
356292 int crtc_clock;
357
- int crtc_hdisplay;
358
- int crtc_hblank_start;
359
- int crtc_hblank_end;
360
- int crtc_hsync_start;
361
- int crtc_hsync_end;
362
- int crtc_htotal;
363
- int crtc_hskew;
364
- int crtc_vdisplay;
365
- int crtc_vblank_start;
366
- int crtc_vblank_end;
367
- int crtc_vsync_start;
368
- int crtc_vsync_end;
369
- int crtc_vtotal;
293
+ u16 crtc_hdisplay;
294
+ u16 crtc_hblank_start;
295
+ u16 crtc_hblank_end;
296
+ u16 crtc_hsync_start;
297
+ u16 crtc_hsync_end;
298
+ u16 crtc_htotal;
299
+ u16 crtc_hskew;
300
+ u16 crtc_vdisplay;
301
+ u16 crtc_vblank_start;
302
+ u16 crtc_vblank_end;
303
+ u16 crtc_vsync_start;
304
+ u16 crtc_vsync_end;
305
+ u16 crtc_vtotal;
370306
371307 /**
372
- * @private:
308
+ * @width_mm:
373309 *
374
- * Pointer for driver private data. This can only be used for mode
375
- * objects passed to drivers in modeset operations. It shouldn't be used
376
- * by atomic drivers since they can store any additional data by
377
- * subclassing state structures.
310
+ * Addressable size of the output in mm, projectors should set this to
311
+ * 0.
378312 */
379
- int *private;
313
+ u16 width_mm;
380314
381315 /**
382
- * @private_flags:
316
+ * @height_mm:
383317 *
384
- * Similar to @private, but just an integer.
318
+ * Addressable size of the output in mm, projectors should set this to
319
+ * 0.
385320 */
386
- int private_flags;
321
+ u16 height_mm;
387322
388323 /**
389
- * @vrefresh:
324
+ * @type:
390325 *
391
- * Vertical refresh rate, for debug output in human readable form. Not
392
- * used in a functional way.
326
+ * A bitmask of flags, mostly about the source of a mode. Possible flags
327
+ * are:
393328 *
394
- * This value is in Hz.
329
+ * - DRM_MODE_TYPE_PREFERRED: Preferred mode, usually the native
330
+ * resolution of an LCD panel. There should only be one preferred
331
+ * mode per connector at any given time.
332
+ * - DRM_MODE_TYPE_DRIVER: Mode created by the driver, which is all of
333
+ * them really. Drivers must set this bit for all modes they create
334
+ * and expose to userspace.
335
+ * - DRM_MODE_TYPE_USERDEF: Mode defined or selected via the kernel
336
+ * command line.
337
+ *
338
+ * Plus a big list of flags which shouldn't be used at all, but are
339
+ * still around since these flags are also used in the userspace ABI.
340
+ * We no longer accept modes with these types though:
341
+ *
342
+ * - DRM_MODE_TYPE_BUILTIN: Meant for hard-coded modes, unused.
343
+ * Use DRM_MODE_TYPE_DRIVER instead.
344
+ * - DRM_MODE_TYPE_DEFAULT: Again a leftover, use
345
+ * DRM_MODE_TYPE_PREFERRED instead.
346
+ * - DRM_MODE_TYPE_CLOCK_C and DRM_MODE_TYPE_CRTC_C: Define leftovers
347
+ * which are stuck around for hysterical raisins only. No one has an
348
+ * idea what they were meant for. Don't use.
395349 */
396
- int vrefresh;
350
+ u8 type;
397351
398352 /**
399
- * @hsync:
353
+ * @expose_to_userspace:
400354 *
401
- * Horizontal refresh rate, for debug output in human readable form. Not
402
- * used in a functional way.
403
- *
404
- * This value is in kHz.
355
+ * Indicates whether the mode is to be exposed to the userspace.
356
+ * This is to maintain a set of exposed modes while preparing
357
+ * user-mode's list in drm_mode_getconnector ioctl. The purpose of
358
+ * this only lies in the ioctl function, and is not to be used
359
+ * outside the function.
405360 */
406
- int hsync;
361
+ bool expose_to_userspace;
362
+
363
+ /**
364
+ * @head:
365
+ *
366
+ * struct list_head for mode lists.
367
+ */
368
+ struct list_head head;
369
+
370
+ /**
371
+ * @name:
372
+ *
373
+ * Human-readable name of the mode, filled out with drm_mode_set_name().
374
+ */
375
+ char name[DRM_DISPLAY_MODE_LEN];
376
+
377
+ /**
378
+ * @status:
379
+ *
380
+ * Status of the mode, used to filter out modes not supported by the
381
+ * hardware. See enum &drm_mode_status.
382
+ */
383
+ enum drm_mode_status status;
407384
408385 /**
409386 * @picture_aspect_ratio:
....@@ -412,31 +389,19 @@
412389 */
413390 enum hdmi_picture_aspect picture_aspect_ratio;
414391
415
- /**
416
- * @export_head:
417
- *
418
- * struct list_head for modes to be exposed to the userspace.
419
- * This is to maintain a list of exposed modes while preparing
420
- * user-mode's list in drm_mode_getconnector ioctl. The purpose of this
421
- * list_head only lies in the ioctl function, and is not expected to be
422
- * used outside the function.
423
- * Once used, the stale pointers are not reset, but left as it is, to
424
- * avoid overhead of protecting it by mode_config.mutex.
425
- */
426
- struct list_head export_head;
427392 };
428393
429394 /**
430395 * DRM_MODE_FMT - printf string for &struct drm_display_mode
431396 */
432
-#define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
397
+#define DRM_MODE_FMT "\"%s\": %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
433398
434399 /**
435400 * DRM_MODE_ARG - printf arguments for &struct drm_display_mode
436401 * @m: display mode
437402 */
438403 #define DRM_MODE_ARG(m) \
439
- (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \
404
+ (m)->name, drm_mode_vrefresh(m), (m)->clock, \
440405 (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
441406 (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
442407 (m)->type, (m)->flags
....@@ -498,7 +463,6 @@
498463 int index);
499464
500465 void drm_mode_set_name(struct drm_display_mode *mode);
501
-int drm_mode_hsync(const struct drm_display_mode *mode);
502466 int drm_mode_vrefresh(const struct drm_display_mode *mode);
503467 void drm_mode_get_hv_timing(const struct drm_display_mode *mode,
504468 int *hdisplay, int *vdisplay);
....@@ -535,7 +499,7 @@
535499 /* parsing cmdline modes */
536500 bool
537501 drm_mode_parse_command_line_for_connector(const char *mode_option,
538
- struct drm_connector *connector,
502
+ const struct drm_connector *connector,
539503 struct drm_cmdline_mode *mode);
540504 struct drm_display_mode *
541505 drm_mode_create_from_cmdline_mode(struct drm_device *dev,