xref: /linux/drivers/gpu/drm/i915/display/intel_cursor.c (revision 6812ce4e4379ffc99c52401ec28f0d7ffbc36206)
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2020 Intel Corporation
4  */
5 #include <linux/kernel.h>
6 
7 #include <drm/drm_atomic_helper.h>
8 #include <drm/drm_atomic_uapi.h>
9 #include <drm/drm_blend.h>
10 #include <drm/drm_damage_helper.h>
11 #include <drm/drm_fourcc.h>
12 #include <drm/drm_print.h>
13 #include <drm/drm_vblank.h>
14 
15 #include "intel_atomic.h"
16 #include "intel_cursor.h"
17 #include "intel_cursor_regs.h"
18 #include "intel_de.h"
19 #include "intel_display.h"
20 #include "intel_display_types.h"
21 #include "intel_display_utils.h"
22 #include "intel_display_wa.h"
23 #include "intel_fb.h"
24 #include "intel_frontbuffer.h"
25 #include "intel_plane.h"
26 #include "intel_psr.h"
27 #include "intel_psr_regs.h"
28 #include "intel_vblank.h"
29 #include "skl_watermark.h"
30 
31 /* Cursor formats */
32 static const u32 intel_cursor_formats[] = {
33 	DRM_FORMAT_ARGB8888,
34 };
35 
intel_cursor_surf_offset(const struct intel_plane_state * plane_state)36 static u32 intel_cursor_surf_offset(const struct intel_plane_state *plane_state)
37 {
38 	return plane_state->view.color_plane[0].offset;
39 }
40 
intel_cursor_position(const struct intel_crtc_state * crtc_state,const struct intel_plane_state * plane_state,bool early_tpt)41 static u32 intel_cursor_position(const struct intel_crtc_state *crtc_state,
42 				 const struct intel_plane_state *plane_state,
43 				 bool early_tpt)
44 {
45 	int x = plane_state->uapi.dst.x1;
46 	int y = plane_state->uapi.dst.y1;
47 	u32 pos = 0;
48 
49 	/*
50 	 * Formula from Bspec:
51 	 * MAX(-1 * <Cursor vertical size from CUR_CTL base on cursor mode
52 	 * select setting> + 1, CUR_POS Y Position - Update region Y position
53 	 */
54 	if (early_tpt)
55 		y = max(-1 * drm_rect_height(&plane_state->uapi.dst) + 1,
56 			y - crtc_state->psr2_su_area.y1);
57 
58 	if (x < 0) {
59 		pos |= CURSOR_POS_X_SIGN;
60 		x = -x;
61 	}
62 	pos |= CURSOR_POS_X(x);
63 
64 	if (y < 0) {
65 		pos |= CURSOR_POS_Y_SIGN;
66 		y = -y;
67 	}
68 	pos |= CURSOR_POS_Y(y);
69 
70 	return pos;
71 }
72 
intel_cursor_size_ok(const struct intel_plane_state * plane_state)73 static bool intel_cursor_size_ok(const struct intel_plane_state *plane_state)
74 {
75 	const struct drm_mode_config *config =
76 		&plane_state->uapi.plane->dev->mode_config;
77 	int width = drm_rect_width(&plane_state->uapi.dst);
78 	int height = drm_rect_height(&plane_state->uapi.dst);
79 
80 	return width > 0 && width <= config->cursor_width &&
81 		height > 0 && height <= config->cursor_height;
82 }
83 
intel_cursor_check_surface(struct intel_plane_state * plane_state)84 static int intel_cursor_check_surface(struct intel_plane_state *plane_state)
85 {
86 	struct intel_display *display = to_intel_display(plane_state);
87 	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
88 	unsigned int rotation = plane_state->hw.rotation;
89 	int src_x, src_y;
90 	u32 offset;
91 	int ret;
92 
93 	ret = intel_plane_compute_gtt(plane_state);
94 	if (ret)
95 		return ret;
96 
97 	if (!plane_state->uapi.visible)
98 		return 0;
99 
100 	src_x = plane_state->uapi.src.x1 >> 16;
101 	src_y = plane_state->uapi.src.y1 >> 16;
102 
103 	intel_add_fb_offsets(&src_x, &src_y, plane_state, 0);
104 	offset = intel_plane_compute_aligned_offset(&src_x, &src_y,
105 						    plane_state, 0);
106 
107 	if (src_x != 0 || src_y != 0) {
108 		drm_dbg_kms(display->drm,
109 			    "[PLANE:%d:%s] arbitrary cursor panning not supported\n",
110 			    plane->base.base.id, plane->base.name);
111 		return -EINVAL;
112 	}
113 
114 	/*
115 	 * Put the final coordinates back so that the src
116 	 * coordinate checks will see the right values.
117 	 */
118 	drm_rect_translate_to(&plane_state->uapi.src,
119 			      src_x << 16, src_y << 16);
120 
121 	/* ILK+ do this automagically in hardware */
122 	if (HAS_GMCH(display) && rotation & DRM_MODE_ROTATE_180) {
123 		const struct drm_framebuffer *fb = plane_state->hw.fb;
124 		int src_w = drm_rect_width(&plane_state->uapi.src) >> 16;
125 		int src_h = drm_rect_height(&plane_state->uapi.src) >> 16;
126 
127 		offset += (src_h * src_w - 1) * fb->format->cpp[0];
128 	}
129 
130 	plane_state->view.color_plane[0].offset = offset;
131 	plane_state->view.color_plane[0].x = src_x;
132 	plane_state->view.color_plane[0].y = src_y;
133 
134 	return 0;
135 }
136 
intel_check_cursor(struct intel_crtc_state * crtc_state,struct intel_plane_state * plane_state)137 static int intel_check_cursor(struct intel_crtc_state *crtc_state,
138 			      struct intel_plane_state *plane_state)
139 {
140 	struct intel_display *display = to_intel_display(plane_state);
141 	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
142 	const struct drm_framebuffer *fb = plane_state->hw.fb;
143 	const struct drm_rect src = plane_state->uapi.src;
144 	const struct drm_rect dst = plane_state->uapi.dst;
145 	int ret;
146 
147 	if (fb && fb->modifier != DRM_FORMAT_MOD_LINEAR) {
148 		drm_dbg_kms(display->drm, "[PLANE:%d:%s] cursor cannot be tiled\n",
149 			    plane->base.base.id, plane->base.name);
150 		return -EINVAL;
151 	}
152 
153 	ret = intel_plane_check_clipping(plane_state, crtc_state,
154 					 DRM_PLANE_NO_SCALING,
155 					 DRM_PLANE_NO_SCALING,
156 					 true);
157 	if (ret)
158 		return ret;
159 
160 	/* Use the unclipped src/dst rectangles, which we program to hw */
161 	plane_state->uapi.src = src;
162 	plane_state->uapi.dst = dst;
163 
164 	/* final plane coordinates will be relative to the plane's pipe */
165 	drm_rect_translate(&plane_state->uapi.dst,
166 			   -crtc_state->pipe_src.x1,
167 			   -crtc_state->pipe_src.y1);
168 
169 	ret = intel_cursor_check_surface(plane_state);
170 	if (ret)
171 		return ret;
172 
173 	if (!plane_state->uapi.visible)
174 		return 0;
175 
176 	ret = intel_plane_check_src_coordinates(plane_state);
177 	if (ret)
178 		return ret;
179 
180 	return 0;
181 }
182 
183 static unsigned int
i845_cursor_max_stride(struct intel_plane * plane,const struct drm_format_info * info,u64 modifier,unsigned int rotation)184 i845_cursor_max_stride(struct intel_plane *plane,
185 		       const struct drm_format_info *info,
186 		       u64 modifier, unsigned int rotation)
187 {
188 	return 2048;
189 }
190 
i845_cursor_min_alignment(struct intel_plane * plane,const struct drm_framebuffer * fb,int color_plane)191 static unsigned int i845_cursor_min_alignment(struct intel_plane *plane,
192 					      const struct drm_framebuffer *fb,
193 					      int color_plane)
194 {
195 	return 32;
196 }
197 
i845_cursor_ctl_crtc(const struct intel_crtc_state * crtc_state)198 static u32 i845_cursor_ctl_crtc(const struct intel_crtc_state *crtc_state)
199 {
200 	u32 cntl = 0;
201 
202 	if (crtc_state->gamma_enable)
203 		cntl |= CURSOR_PIPE_GAMMA_ENABLE;
204 
205 	return cntl;
206 }
207 
i845_cursor_ctl(const struct intel_plane_state * plane_state)208 static u32 i845_cursor_ctl(const struct intel_plane_state *plane_state)
209 {
210 	return CURSOR_ENABLE |
211 		CURSOR_FORMAT_ARGB |
212 		CURSOR_STRIDE(plane_state->view.color_plane[0].mapping_stride);
213 }
214 
i845_cursor_size_ok(const struct intel_plane_state * plane_state)215 static bool i845_cursor_size_ok(const struct intel_plane_state *plane_state)
216 {
217 	int width = drm_rect_width(&plane_state->uapi.dst);
218 
219 	/*
220 	 * 845g/865g are only limited by the width of their cursors,
221 	 * the height is arbitrary up to the precision of the register.
222 	 */
223 	return intel_cursor_size_ok(plane_state) && IS_ALIGNED(width, 64);
224 }
225 
i845_check_cursor(struct intel_crtc_state * crtc_state,struct intel_plane_state * plane_state)226 static int i845_check_cursor(struct intel_crtc_state *crtc_state,
227 			     struct intel_plane_state *plane_state)
228 {
229 	struct intel_display *display = to_intel_display(plane_state);
230 	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
231 	const struct drm_framebuffer *fb = plane_state->hw.fb;
232 	int ret;
233 
234 	ret = intel_check_cursor(crtc_state, plane_state);
235 	if (ret)
236 		return ret;
237 
238 	/* if we want to turn off the cursor ignore width and height */
239 	if (!fb)
240 		return 0;
241 
242 	/* Check for which cursor types we support */
243 	if (!i845_cursor_size_ok(plane_state)) {
244 		drm_dbg_kms(display->drm,
245 			    "[PLANE:%d:%s] cursor dimension %dx%d not supported\n",
246 			    plane->base.base.id, plane->base.name,
247 			    drm_rect_width(&plane_state->uapi.dst),
248 			    drm_rect_height(&plane_state->uapi.dst));
249 		return -EINVAL;
250 	}
251 
252 	drm_WARN_ON(display->drm, plane_state->uapi.visible &&
253 		    plane_state->view.color_plane[0].mapping_stride != fb->pitches[0]);
254 
255 	switch (fb->pitches[0]) {
256 	case 256:
257 	case 512:
258 	case 1024:
259 	case 2048:
260 		break;
261 	default:
262 		 drm_dbg_kms(display->drm, "[PLANE:%d:%s] invalid cursor stride (%u)\n",
263 			     plane->base.base.id, plane->base.name,
264 			     fb->pitches[0]);
265 		return -EINVAL;
266 	}
267 
268 	plane_state->ctl = i845_cursor_ctl(plane_state);
269 
270 	return 0;
271 }
272 
273 /* TODO: split into noarm+arm pair */
i845_cursor_update_arm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state,const struct intel_plane_state * plane_state)274 static void i845_cursor_update_arm(struct intel_dsb *dsb,
275 				   struct intel_plane *plane,
276 				   const struct intel_crtc_state *crtc_state,
277 				   const struct intel_plane_state *plane_state)
278 {
279 	struct intel_display *display = to_intel_display(plane);
280 	u32 cntl = 0, base = 0, pos = 0, size = 0;
281 
282 	if (plane_state && plane_state->uapi.visible) {
283 		unsigned int width = drm_rect_width(&plane_state->uapi.dst);
284 		unsigned int height = drm_rect_height(&plane_state->uapi.dst);
285 
286 		cntl = plane_state->ctl |
287 			i845_cursor_ctl_crtc(crtc_state);
288 
289 		size = CURSOR_HEIGHT(height) | CURSOR_WIDTH(width);
290 
291 		base = plane_state->surf;
292 		pos = intel_cursor_position(crtc_state, plane_state, false);
293 	}
294 
295 	/* On these chipsets we can only modify the base/size/stride
296 	 * whilst the cursor is disabled.
297 	 */
298 	if (plane->cursor.base != base ||
299 	    plane->cursor.size != size ||
300 	    plane->cursor.cntl != cntl) {
301 		intel_de_write_fw(display, CURCNTR(display, PIPE_A), 0);
302 		intel_de_write_fw(display, CURBASE(display, PIPE_A), base);
303 		intel_de_write_fw(display, CURSIZE(display, PIPE_A), size);
304 		intel_de_write_fw(display, CURPOS(display, PIPE_A), pos);
305 		intel_de_write_fw(display, CURCNTR(display, PIPE_A), cntl);
306 
307 		plane->cursor.base = base;
308 		plane->cursor.size = size;
309 		plane->cursor.cntl = cntl;
310 	} else {
311 		intel_de_write_fw(display, CURPOS(display, PIPE_A), pos);
312 	}
313 }
314 
i845_cursor_disable_arm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state)315 static void i845_cursor_disable_arm(struct intel_dsb *dsb,
316 				    struct intel_plane *plane,
317 				    const struct intel_crtc_state *crtc_state)
318 {
319 	i845_cursor_update_arm(dsb, plane, crtc_state, NULL);
320 }
321 
i845_cursor_get_hw_state(struct intel_plane * plane,enum pipe * pipe)322 static bool i845_cursor_get_hw_state(struct intel_plane *plane,
323 				     enum pipe *pipe)
324 {
325 	struct intel_display *display = to_intel_display(plane);
326 	enum intel_display_power_domain power_domain;
327 	struct ref_tracker *wakeref;
328 	bool ret;
329 
330 	power_domain = POWER_DOMAIN_PIPE(PIPE_A);
331 	wakeref = intel_display_power_get_if_enabled(display, power_domain);
332 	if (!wakeref)
333 		return false;
334 
335 	ret = intel_de_read(display, CURCNTR(display, PIPE_A)) & CURSOR_ENABLE;
336 
337 	*pipe = PIPE_A;
338 
339 	intel_display_power_put(display, power_domain, wakeref);
340 
341 	return ret;
342 }
343 
344 static unsigned int
i9xx_cursor_max_stride(struct intel_plane * plane,const struct drm_format_info * info,u64 modifier,unsigned int rotation)345 i9xx_cursor_max_stride(struct intel_plane *plane,
346 		       const struct drm_format_info *info,
347 		       u64 modifier, unsigned int rotation)
348 {
349 	return plane->base.dev->mode_config.cursor_width * 4;
350 }
351 
i830_cursor_min_alignment(struct intel_plane * plane,const struct drm_framebuffer * fb,int color_plane)352 static unsigned int i830_cursor_min_alignment(struct intel_plane *plane,
353 					      const struct drm_framebuffer *fb,
354 					      int color_plane)
355 {
356 	/* "AlmadorM Errata – Requires 32-bpp cursor data to be 16KB aligned." */
357 	return 16 * 1024; /* physical */
358 }
359 
i85x_cursor_min_alignment(struct intel_plane * plane,const struct drm_framebuffer * fb,int color_plane)360 static unsigned int i85x_cursor_min_alignment(struct intel_plane *plane,
361 					      const struct drm_framebuffer *fb,
362 					      int color_plane)
363 {
364 	return 256; /* physical */
365 }
366 
i9xx_cursor_min_alignment(struct intel_plane * plane,const struct drm_framebuffer * fb,int color_plane)367 static unsigned int i9xx_cursor_min_alignment(struct intel_plane *plane,
368 					      const struct drm_framebuffer *fb,
369 					      int color_plane)
370 {
371 	struct intel_display *display = to_intel_display(plane);
372 
373 	if (intel_scanout_needs_vtd_wa(display))
374 		return 64 * 1024;
375 
376 	return 4 * 1024; /* physical for i915/i945 */
377 }
378 
i9xx_cursor_ctl_crtc(const struct intel_crtc_state * crtc_state)379 static u32 i9xx_cursor_ctl_crtc(const struct intel_crtc_state *crtc_state)
380 {
381 	struct intel_display *display = to_intel_display(crtc_state);
382 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
383 	u32 cntl = 0;
384 
385 	if (DISPLAY_VER(display) >= 11)
386 		return cntl;
387 
388 	if (crtc_state->gamma_enable)
389 		cntl = MCURSOR_PIPE_GAMMA_ENABLE;
390 
391 	if (crtc_state->csc_enable)
392 		cntl |= MCURSOR_PIPE_CSC_ENABLE;
393 
394 	if (DISPLAY_VER(display) < 5 && !display->platform.g4x)
395 		cntl |= MCURSOR_PIPE_SEL(crtc->pipe);
396 
397 	return cntl;
398 }
399 
i9xx_cursor_ctl(const struct intel_plane_state * plane_state)400 static u32 i9xx_cursor_ctl(const struct intel_plane_state *plane_state)
401 {
402 	struct intel_display *display = to_intel_display(plane_state);
403 	u32 cntl = 0;
404 
405 	if (display->platform.sandybridge || display->platform.ivybridge)
406 		cntl |= MCURSOR_TRICKLE_FEED_DISABLE;
407 
408 	switch (drm_rect_width(&plane_state->uapi.dst)) {
409 	case 64:
410 		cntl |= MCURSOR_MODE_64_ARGB_AX;
411 		break;
412 	case 128:
413 		cntl |= MCURSOR_MODE_128_ARGB_AX;
414 		break;
415 	case 256:
416 		cntl |= MCURSOR_MODE_256_ARGB_AX;
417 		break;
418 	default:
419 		MISSING_CASE(drm_rect_width(&plane_state->uapi.dst));
420 		return 0;
421 	}
422 
423 	if (plane_state->hw.rotation & DRM_MODE_ROTATE_180)
424 		cntl |= MCURSOR_ROTATE_180;
425 
426 	/* Wa_22012358565:adl-p */
427 	if (intel_display_wa(display, INTEL_DISPLAY_WA_22012358565))
428 		cntl |= MCURSOR_ARB_SLOTS(1);
429 
430 	return cntl;
431 }
432 
i9xx_cursor_size_ok(const struct intel_plane_state * plane_state)433 static bool i9xx_cursor_size_ok(const struct intel_plane_state *plane_state)
434 {
435 	struct intel_display *display = to_intel_display(plane_state);
436 	int width = drm_rect_width(&plane_state->uapi.dst);
437 	int height = drm_rect_height(&plane_state->uapi.dst);
438 
439 	if (!intel_cursor_size_ok(plane_state))
440 		return false;
441 
442 	/* Cursor width is limited to a few power-of-two sizes */
443 	switch (width) {
444 	case 256:
445 	case 128:
446 	case 64:
447 		break;
448 	default:
449 		return false;
450 	}
451 
452 	/*
453 	 * IVB+ have CUR_FBC_CTL which allows an arbitrary cursor
454 	 * height from 8 lines up to the cursor width, when the
455 	 * cursor is not rotated. Everything else requires square
456 	 * cursors.
457 	 */
458 	if (HAS_CUR_FBC(display) &&
459 	    plane_state->hw.rotation & DRM_MODE_ROTATE_0) {
460 		if (height < 8 || height > width)
461 			return false;
462 	} else {
463 		if (height != width)
464 			return false;
465 	}
466 
467 	return true;
468 }
469 
i9xx_check_cursor(struct intel_crtc_state * crtc_state,struct intel_plane_state * plane_state)470 static int i9xx_check_cursor(struct intel_crtc_state *crtc_state,
471 			     struct intel_plane_state *plane_state)
472 {
473 	struct intel_display *display = to_intel_display(plane_state);
474 	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
475 	const struct drm_framebuffer *fb = plane_state->hw.fb;
476 	enum pipe pipe = plane->pipe;
477 	int ret;
478 
479 	ret = intel_check_cursor(crtc_state, plane_state);
480 	if (ret)
481 		return ret;
482 
483 	/* if we want to turn off the cursor ignore width and height */
484 	if (!fb)
485 		return 0;
486 
487 	/* Check for which cursor types we support */
488 	if (!i9xx_cursor_size_ok(plane_state)) {
489 		drm_dbg_kms(display->drm,
490 			    "[PLANE:%d:%s] cursor dimension %dx%d not supported\n",
491 			    plane->base.base.id, plane->base.name,
492 			    drm_rect_width(&plane_state->uapi.dst),
493 			    drm_rect_height(&plane_state->uapi.dst));
494 		return -EINVAL;
495 	}
496 
497 	drm_WARN_ON(display->drm, plane_state->uapi.visible &&
498 		    plane_state->view.color_plane[0].mapping_stride != fb->pitches[0]);
499 
500 	if (fb->pitches[0] !=
501 	    drm_rect_width(&plane_state->uapi.dst) * fb->format->cpp[0]) {
502 		drm_dbg_kms(display->drm,
503 			    "[PLANE:%d:%s] invalid cursor stride (%u) (cursor width %d)\n",
504 			    plane->base.base.id, plane->base.name,
505 			    fb->pitches[0], drm_rect_width(&plane_state->uapi.dst));
506 		return -EINVAL;
507 	}
508 
509 	/*
510 	 * There's something wrong with the cursor on CHV pipe C.
511 	 * If it straddles the left edge of the screen then
512 	 * moving it away from the edge or disabling it often
513 	 * results in a pipe underrun, and often that can lead to
514 	 * dead pipe (constant underrun reported, and it scans
515 	 * out just a solid color). To recover from that, the
516 	 * display power well must be turned off and on again.
517 	 * Refuse the put the cursor into that compromised position.
518 	 */
519 	if (display->platform.cherryview && pipe == PIPE_C &&
520 	    plane_state->uapi.visible && plane_state->uapi.dst.x1 < 0) {
521 		drm_dbg_kms(display->drm,
522 			    "[PLANE:%d:%s] cursor not allowed to straddle the left screen edge\n",
523 			    plane->base.base.id, plane->base.name);
524 		return -EINVAL;
525 	}
526 
527 	plane_state->ctl = i9xx_cursor_ctl(plane_state);
528 
529 	return 0;
530 }
531 
i9xx_cursor_disable_sel_fetch_arm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state)532 static void i9xx_cursor_disable_sel_fetch_arm(struct intel_dsb *dsb,
533 					      struct intel_plane *plane,
534 					      const struct intel_crtc_state *crtc_state)
535 {
536 	struct intel_display *display = to_intel_display(plane);
537 	enum pipe pipe = plane->pipe;
538 
539 	if (!crtc_state->enable_psr2_sel_fetch &&
540 	    !crtc_state->clear_psr2_sel_fetch)
541 		return;
542 
543 	intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), 0);
544 }
545 
wa_16021440873(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state,const struct intel_plane_state * plane_state)546 static void wa_16021440873(struct intel_dsb *dsb,
547 			   struct intel_plane *plane,
548 			   const struct intel_crtc_state *crtc_state,
549 			   const struct intel_plane_state *plane_state)
550 {
551 	struct intel_display *display = to_intel_display(plane);
552 	u32 ctl = plane_state->ctl;
553 	int et_y_position = drm_rect_height(&crtc_state->pipe_src) + 1;
554 	enum pipe pipe = plane->pipe;
555 
556 	ctl &= ~MCURSOR_MODE_MASK;
557 	ctl |= MCURSOR_MODE_64_2B;
558 
559 	intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), ctl);
560 
561 	intel_de_write_dsb(display, dsb, CURPOS_ERLY_TPT(display, pipe),
562 			   CURSOR_POS_Y(et_y_position));
563 }
564 
i9xx_cursor_update_sel_fetch_arm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state,const struct intel_plane_state * plane_state)565 static void i9xx_cursor_update_sel_fetch_arm(struct intel_dsb *dsb,
566 					     struct intel_plane *plane,
567 					     const struct intel_crtc_state *crtc_state,
568 					     const struct intel_plane_state *plane_state)
569 {
570 	struct intel_display *display = to_intel_display(plane);
571 	enum pipe pipe = plane->pipe;
572 
573 	if (!crtc_state->enable_psr2_sel_fetch) {
574 		i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state);
575 		return;
576 	}
577 
578 	if (drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) {
579 		if (crtc_state->enable_psr2_su_region_et) {
580 			u32 val = intel_cursor_position(crtc_state, plane_state,
581 				true);
582 
583 			intel_de_write_dsb(display, dsb, CURPOS_ERLY_TPT(display, pipe), val);
584 		}
585 
586 		intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), plane_state->ctl);
587 	} else {
588 		/* Wa_16021440873 */
589 		if (crtc_state->enable_psr2_su_region_et)
590 			wa_16021440873(dsb, plane, crtc_state, plane_state);
591 		else
592 			i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state);
593 	}
594 }
595 
skl_cursor_ddb_reg_val(const struct skl_ddb_entry * entry)596 static u32 skl_cursor_ddb_reg_val(const struct skl_ddb_entry *entry)
597 {
598 	if (!entry->end)
599 		return 0;
600 
601 	return CUR_BUF_END(entry->end - 1) |
602 		CUR_BUF_START(entry->start);
603 }
604 
skl_cursor_wm_reg_val(const struct skl_wm_level * level)605 static u32 skl_cursor_wm_reg_val(const struct skl_wm_level *level)
606 {
607 	u32 val = 0;
608 
609 	if (level->enable)
610 		val |= CUR_WM_EN;
611 	if (level->ignore_lines)
612 		val |= CUR_WM_IGNORE_LINES;
613 	val |= REG_FIELD_PREP(CUR_WM_BLOCKS_MASK, level->blocks);
614 	val |= REG_FIELD_PREP(CUR_WM_LINES_MASK, level->lines);
615 
616 	return val;
617 }
618 
skl_write_cursor_wm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state)619 static void skl_write_cursor_wm(struct intel_dsb *dsb,
620 				struct intel_plane *plane,
621 				const struct intel_crtc_state *crtc_state)
622 {
623 	struct intel_display *display = to_intel_display(plane->base.dev);
624 	enum plane_id plane_id = plane->id;
625 	enum pipe pipe = plane->pipe;
626 	const struct skl_pipe_wm *pipe_wm = &crtc_state->wm.skl.optimal;
627 	const struct skl_ddb_entry *ddb =
628 		&crtc_state->wm.skl.plane_ddb[plane_id];
629 	int level;
630 
631 	for (level = 0; level < display->wm.num_levels; level++)
632 		intel_de_write_dsb(display, dsb, CUR_WM(pipe, level),
633 				   skl_cursor_wm_reg_val(skl_plane_wm_level(pipe_wm, plane_id, level)));
634 
635 	intel_de_write_dsb(display, dsb, CUR_WM_TRANS(pipe),
636 			   skl_cursor_wm_reg_val(skl_plane_trans_wm(pipe_wm, plane_id)));
637 
638 	if (HAS_HW_SAGV_WM(display)) {
639 		const struct skl_plane_wm *wm = &pipe_wm->planes[plane_id];
640 
641 		intel_de_write_dsb(display, dsb, CUR_WM_SAGV(pipe),
642 				   skl_cursor_wm_reg_val(&wm->sagv.wm0));
643 		intel_de_write_dsb(display, dsb, CUR_WM_SAGV_TRANS(pipe),
644 				   skl_cursor_wm_reg_val(&wm->sagv.trans_wm));
645 	}
646 
647 	intel_de_write_dsb(display, dsb, CUR_BUF_CFG(pipe),
648 			   skl_cursor_ddb_reg_val(ddb));
649 }
650 
651 /* TODO: split into noarm+arm pair */
i9xx_cursor_update_arm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state,const struct intel_plane_state * plane_state)652 static void i9xx_cursor_update_arm(struct intel_dsb *dsb,
653 				   struct intel_plane *plane,
654 				   const struct intel_crtc_state *crtc_state,
655 				   const struct intel_plane_state *plane_state)
656 {
657 	struct intel_display *display = to_intel_display(plane);
658 	enum pipe pipe = plane->pipe;
659 	u32 cntl = 0, base = 0, pos = 0, fbc_ctl = 0;
660 
661 	if (plane_state && plane_state->uapi.visible) {
662 		int width = drm_rect_width(&plane_state->uapi.dst);
663 		int height = drm_rect_height(&plane_state->uapi.dst);
664 
665 		cntl = plane_state->ctl |
666 			i9xx_cursor_ctl_crtc(crtc_state);
667 
668 		if (DISPLAY_VER(display) < 14 && width != height)
669 			fbc_ctl = CUR_FBC_EN | CUR_FBC_HEIGHT(height - 1);
670 
671 		base = plane_state->surf;
672 		pos = intel_cursor_position(crtc_state, plane_state, false);
673 	}
674 
675 	/*
676 	 * On some platforms writing CURCNTR first will also
677 	 * cause CURPOS to be armed by the CURBASE write.
678 	 * Without the CURCNTR write the CURPOS write would
679 	 * arm itself. Thus we always update CURCNTR before
680 	 * CURPOS.
681 	 *
682 	 * On other platforms CURPOS always requires the
683 	 * CURBASE write to arm the update. Additionally
684 	 * a write to any of the cursor register will cancel
685 	 * an already armed cursor update. Thus leaving out
686 	 * the CURBASE write after CURPOS could lead to a
687 	 * cursor that doesn't appear to move, or even change
688 	 * shape. Thus we always write CURBASE.
689 	 *
690 	 * The other registers are armed by the CURBASE write
691 	 * except when the plane is getting enabled at which time
692 	 * the CURCNTR write arms the update.
693 	 */
694 
695 	if (DISPLAY_VER(display) >= 9)
696 		skl_write_cursor_wm(dsb, plane, crtc_state);
697 
698 	if (plane_state)
699 		i9xx_cursor_update_sel_fetch_arm(dsb, plane, crtc_state, plane_state);
700 	else
701 		i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state);
702 
703 	if (plane->cursor.base != base ||
704 	    plane->cursor.size != fbc_ctl ||
705 	    plane->cursor.cntl != cntl) {
706 		if (HAS_CUR_FBC(display))
707 			intel_de_write_dsb(display, dsb, CUR_FBC_CTL(display, pipe), fbc_ctl);
708 		intel_de_write_dsb(display, dsb, CURCNTR(display, pipe), cntl);
709 		intel_de_write_dsb(display, dsb, CURPOS(display, pipe), pos);
710 		intel_de_write_dsb(display, dsb, CURBASE(display, pipe), base);
711 
712 		plane->cursor.base = base;
713 		plane->cursor.size = fbc_ctl;
714 		plane->cursor.cntl = cntl;
715 	} else {
716 		intel_de_write_dsb(display, dsb, CURPOS(display, pipe), pos);
717 		intel_de_write_dsb(display, dsb, CURBASE(display, pipe), base);
718 	}
719 }
720 
i9xx_cursor_disable_arm(struct intel_dsb * dsb,struct intel_plane * plane,const struct intel_crtc_state * crtc_state)721 static void i9xx_cursor_disable_arm(struct intel_dsb *dsb,
722 				    struct intel_plane *plane,
723 				    const struct intel_crtc_state *crtc_state)
724 {
725 	i9xx_cursor_update_arm(dsb, plane, crtc_state, NULL);
726 }
727 
i9xx_cursor_get_hw_state(struct intel_plane * plane,enum pipe * pipe)728 static bool i9xx_cursor_get_hw_state(struct intel_plane *plane,
729 				     enum pipe *pipe)
730 {
731 	struct intel_display *display = to_intel_display(plane);
732 	enum intel_display_power_domain power_domain;
733 	struct ref_tracker *wakeref;
734 	bool ret;
735 	u32 val;
736 
737 	/*
738 	 * Not 100% correct for planes that can move between pipes,
739 	 * but that's only the case for gen2-3 which don't have any
740 	 * display power wells.
741 	 */
742 	power_domain = POWER_DOMAIN_PIPE(plane->pipe);
743 	wakeref = intel_display_power_get_if_enabled(display, power_domain);
744 	if (!wakeref)
745 		return false;
746 
747 	val = intel_de_read(display, CURCNTR(display, plane->pipe));
748 
749 	ret = val & MCURSOR_MODE_MASK;
750 
751 	if (DISPLAY_VER(display) >= 5 || display->platform.g4x)
752 		*pipe = plane->pipe;
753 	else
754 		*pipe = REG_FIELD_GET(MCURSOR_PIPE_SEL_MASK, val);
755 
756 	intel_display_power_put(display, power_domain, wakeref);
757 
758 	return ret;
759 }
760 
g4x_cursor_capture_error(struct intel_crtc * crtc,struct intel_plane * plane,struct intel_plane_error * error)761 static void g4x_cursor_capture_error(struct intel_crtc *crtc,
762 				     struct intel_plane *plane,
763 				     struct intel_plane_error *error)
764 {
765 	struct intel_display *display = to_intel_display(plane);
766 
767 	error->ctl = intel_de_read(display, CURCNTR(display, crtc->pipe));
768 	error->surf = intel_de_read(display, CURBASE(display, crtc->pipe));
769 	error->surflive = intel_de_read(display, CURSURFLIVE(display, crtc->pipe));
770 }
771 
i9xx_cursor_capture_error(struct intel_crtc * crtc,struct intel_plane * plane,struct intel_plane_error * error)772 static void i9xx_cursor_capture_error(struct intel_crtc *crtc,
773 				      struct intel_plane *plane,
774 				      struct intel_plane_error *error)
775 {
776 	struct intel_display *display = to_intel_display(plane);
777 
778 	error->ctl = intel_de_read(display, CURCNTR(display, crtc->pipe));
779 	error->surf = intel_de_read(display, CURBASE(display, crtc->pipe));
780 }
781 
intel_cursor_format_mod_supported(struct drm_plane * _plane,u32 format,u64 modifier)782 static bool intel_cursor_format_mod_supported(struct drm_plane *_plane,
783 					      u32 format, u64 modifier)
784 {
785 	if (!intel_fb_plane_supports_modifier(to_intel_plane(_plane), modifier))
786 		return false;
787 
788 	return format == DRM_FORMAT_ARGB8888;
789 }
790 
intel_cursor_unpin_work(struct kthread_work * base)791 void intel_cursor_unpin_work(struct kthread_work *base)
792 {
793 	struct drm_vblank_work *work = to_drm_vblank_work(base);
794 	struct intel_plane_state *plane_state =
795 		container_of(work, typeof(*plane_state), unpin_work);
796 	struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
797 
798 	intel_plane_unpin_fb(plane_state);
799 	intel_plane_destroy_state(&plane->base, &plane_state->uapi);
800 }
801 
802 static int
intel_legacy_cursor_update(struct drm_plane * _plane,struct drm_crtc * _crtc,struct drm_framebuffer * fb,int crtc_x,int crtc_y,unsigned int crtc_w,unsigned int crtc_h,u32 src_x,u32 src_y,u32 src_w,u32 src_h,struct drm_modeset_acquire_ctx * ctx)803 intel_legacy_cursor_update(struct drm_plane *_plane,
804 			   struct drm_crtc *_crtc,
805 			   struct drm_framebuffer *fb,
806 			   int crtc_x, int crtc_y,
807 			   unsigned int crtc_w, unsigned int crtc_h,
808 			   u32 src_x, u32 src_y,
809 			   u32 src_w, u32 src_h,
810 			   struct drm_modeset_acquire_ctx *ctx)
811 {
812 	struct intel_plane *plane = to_intel_plane(_plane);
813 	struct intel_crtc *crtc = to_intel_crtc(_crtc);
814 	struct intel_display *display = to_intel_display(plane);
815 	struct intel_plane_state *old_plane_state =
816 		to_intel_plane_state(plane->base.state);
817 	struct intel_plane_state *new_plane_state;
818 	struct intel_crtc_state *crtc_state =
819 		to_intel_crtc_state(crtc->base.state);
820 	struct intel_crtc_state *new_crtc_state;
821 	struct intel_vblank_evade_ctx evade;
822 	int ret;
823 
824 	/*
825 	 * When crtc is inactive or there is a modeset pending,
826 	 * wait for it to complete in the slowpath.
827 	 * PSR2 selective fetch also requires the slow path as
828 	 * PSR2 plane and transcoder registers can only be updated during
829 	 * vblank.
830 	 *
831 	 * FIXME joiner fastpath would be good
832 	 */
833 	if (!crtc_state->hw.active ||
834 	    intel_crtc_needs_modeset(crtc_state) ||
835 	    intel_crtc_needs_fastset(crtc_state) ||
836 	    crtc_state->joiner_pipes)
837 		goto slow;
838 
839 	/*
840 	 * Don't do an async update if there is an outstanding commit modifying
841 	 * the plane.  This prevents our async update's changes from getting
842 	 * overridden by a previous synchronous update's state.
843 	 */
844 	if (old_plane_state->uapi.commit &&
845 	    !try_wait_for_completion(&old_plane_state->uapi.commit->hw_done))
846 		goto slow;
847 
848 	/*
849 	 * If any parameters change that may affect watermarks,
850 	 * take the slowpath. Only changing fb or position should be
851 	 * in the fastpath.
852 	 */
853 	if (old_plane_state->uapi.crtc != &crtc->base ||
854 	    old_plane_state->uapi.src_w != src_w ||
855 	    old_plane_state->uapi.src_h != src_h ||
856 	    old_plane_state->uapi.crtc_w != crtc_w ||
857 	    old_plane_state->uapi.crtc_h != crtc_h ||
858 	    !old_plane_state->uapi.fb != !fb)
859 		goto slow;
860 
861 	new_plane_state = to_intel_plane_state(intel_plane_duplicate_state(&plane->base));
862 	if (!new_plane_state)
863 		return -ENOMEM;
864 
865 	new_crtc_state = to_intel_crtc_state(intel_crtc_duplicate_state(&crtc->base));
866 	if (!new_crtc_state) {
867 		ret = -ENOMEM;
868 		goto out_free;
869 	}
870 
871 	drm_atomic_set_fb_for_plane(&new_plane_state->uapi, fb);
872 
873 	new_plane_state->uapi.src_x = src_x;
874 	new_plane_state->uapi.src_y = src_y;
875 	new_plane_state->uapi.src_w = src_w;
876 	new_plane_state->uapi.src_h = src_h;
877 	new_plane_state->uapi.crtc_x = crtc_x;
878 	new_plane_state->uapi.crtc_y = crtc_y;
879 	new_plane_state->uapi.crtc_w = crtc_w;
880 	new_plane_state->uapi.crtc_h = crtc_h;
881 
882 	intel_plane_copy_uapi_to_hw_state(NULL, new_plane_state, new_plane_state, crtc);
883 
884 	ret = intel_plane_atomic_check_with_state(crtc_state, new_crtc_state,
885 						  old_plane_state, new_plane_state);
886 	if (ret)
887 		goto out_free;
888 
889 	ret = intel_plane_pin_fb(new_plane_state, old_plane_state);
890 	if (ret)
891 		goto out_free;
892 
893 	intel_frontbuffer_flush(to_intel_frontbuffer(new_plane_state->hw.fb),
894 				ORIGIN_CURSOR_UPDATE);
895 	intel_frontbuffer_track(to_intel_frontbuffer(old_plane_state->hw.fb),
896 				to_intel_frontbuffer(new_plane_state->hw.fb),
897 				plane->frontbuffer_bit);
898 
899 	/* Swap plane state */
900 	plane->base.state = &new_plane_state->uapi;
901 
902 	/*
903 	 * We cannot swap crtc_state as it may be in use by an atomic commit or
904 	 * page flip that's running simultaneously. If we swap crtc_state and
905 	 * destroy the old state, we will cause a use-after-free there.
906 	 *
907 	 * Only update active_planes, which is needed for our internal
908 	 * bookkeeping. Either value will do the right thing when updating
909 	 * planes atomically. If the cursor was part of the atomic update then
910 	 * we would have taken the slowpath.
911 	 */
912 	crtc_state->active_planes = new_crtc_state->active_planes;
913 
914 	intel_vblank_evade_init(crtc_state, crtc_state, &evade);
915 
916 	intel_psr_lock(crtc_state);
917 
918 	if (!drm_WARN_ON(display->drm, drm_crtc_vblank_get(&crtc->base))) {
919 		/*
920 		 * TODO: maybe check if we're still in PSR
921 		 * and skip the vblank evasion entirely?
922 		 */
923 		intel_psr_wait_for_idle_locked(crtc_state);
924 
925 		local_irq_disable();
926 
927 		intel_vblank_evade(&evade);
928 
929 		drm_crtc_vblank_put(&crtc->base);
930 	} else {
931 		local_irq_disable();
932 	}
933 
934 	if (new_plane_state->uapi.visible) {
935 		intel_plane_update_noarm(NULL, plane, crtc_state, new_plane_state);
936 		intel_plane_update_arm(NULL, plane, crtc_state, new_plane_state);
937 	} else {
938 		intel_plane_disable_arm(NULL, plane, crtc_state);
939 	}
940 
941 	local_irq_enable();
942 
943 	intel_psr_unlock(crtc_state);
944 
945 	if (old_plane_state->ggtt_vma != new_plane_state->ggtt_vma) {
946 		drm_vblank_work_init(&old_plane_state->unpin_work, &crtc->base,
947 				     intel_cursor_unpin_work);
948 
949 		drm_vblank_work_schedule(&old_plane_state->unpin_work,
950 					 drm_crtc_accurate_vblank_count(&crtc->base) + 1,
951 					 false);
952 
953 		old_plane_state = NULL;
954 	} else {
955 		intel_plane_unpin_fb(old_plane_state);
956 	}
957 
958 out_free:
959 	if (new_crtc_state)
960 		intel_crtc_destroy_state(&crtc->base, &new_crtc_state->uapi);
961 	if (ret)
962 		intel_plane_destroy_state(&plane->base, &new_plane_state->uapi);
963 	else if (old_plane_state)
964 		intel_plane_destroy_state(&plane->base, &old_plane_state->uapi);
965 	return ret;
966 
967 slow:
968 	return drm_atomic_helper_update_plane(&plane->base, &crtc->base, fb,
969 					      crtc_x, crtc_y, crtc_w, crtc_h,
970 					      src_x, src_y, src_w, src_h, ctx);
971 }
972 
973 static const struct drm_plane_funcs intel_cursor_plane_funcs = {
974 	.update_plane = intel_legacy_cursor_update,
975 	.disable_plane = drm_atomic_helper_disable_plane,
976 	.destroy = intel_plane_destroy,
977 	.atomic_duplicate_state = intel_plane_duplicate_state,
978 	.atomic_destroy_state = intel_plane_destroy_state,
979 	.format_mod_supported = intel_cursor_format_mod_supported,
980 	.format_mod_supported_async = intel_plane_format_mod_supported_async,
981 };
982 
intel_cursor_add_size_hints_property(struct intel_plane * plane)983 static void intel_cursor_add_size_hints_property(struct intel_plane *plane)
984 {
985 	struct intel_display *display = to_intel_display(plane);
986 	const struct drm_mode_config *config = &display->drm->mode_config;
987 	struct drm_plane_size_hint hints[4];
988 	int size, max_size, num_hints = 0;
989 
990 	max_size = min(config->cursor_width, config->cursor_height);
991 
992 	/* for simplicity only enumerate the supported square+POT sizes */
993 	for (size = 64; size <= max_size; size *= 2) {
994 		if (drm_WARN_ON(display->drm, num_hints >= ARRAY_SIZE(hints)))
995 			break;
996 
997 		hints[num_hints].width = size;
998 		hints[num_hints].height = size;
999 		num_hints++;
1000 	}
1001 
1002 	drm_plane_add_size_hints_property(&plane->base, hints, num_hints);
1003 }
1004 
1005 struct intel_plane *
intel_cursor_plane_create(struct intel_display * display,enum pipe pipe)1006 intel_cursor_plane_create(struct intel_display *display,
1007 			  enum pipe pipe)
1008 {
1009 	struct intel_plane *cursor;
1010 	int ret, zpos;
1011 	u64 *modifiers;
1012 
1013 	cursor = intel_plane_alloc();
1014 	if (IS_ERR(cursor))
1015 		return cursor;
1016 
1017 	cursor->pipe = pipe;
1018 	cursor->i9xx_plane = (enum i9xx_plane_id) pipe;
1019 	cursor->id = PLANE_CURSOR;
1020 	cursor->frontbuffer_bit = INTEL_FRONTBUFFER(pipe, cursor->id);
1021 
1022 	if (display->platform.i845g || display->platform.i865g) {
1023 		cursor->max_stride = i845_cursor_max_stride;
1024 		cursor->min_alignment = i845_cursor_min_alignment;
1025 		cursor->update_arm = i845_cursor_update_arm;
1026 		cursor->disable_arm = i845_cursor_disable_arm;
1027 		cursor->get_hw_state = i845_cursor_get_hw_state;
1028 		cursor->check_plane = i845_check_cursor;
1029 	} else {
1030 		cursor->max_stride = i9xx_cursor_max_stride;
1031 
1032 		if (display->platform.i830)
1033 			cursor->min_alignment = i830_cursor_min_alignment;
1034 		else if (display->platform.i85x)
1035 			cursor->min_alignment = i85x_cursor_min_alignment;
1036 		else
1037 			cursor->min_alignment = i9xx_cursor_min_alignment;
1038 
1039 		if (intel_scanout_needs_vtd_wa(display))
1040 			cursor->vtd_guard = 2;
1041 
1042 		cursor->update_arm = i9xx_cursor_update_arm;
1043 		cursor->disable_arm = i9xx_cursor_disable_arm;
1044 		cursor->get_hw_state = i9xx_cursor_get_hw_state;
1045 		cursor->check_plane = i9xx_check_cursor;
1046 	}
1047 
1048 	cursor->surf_offset = intel_cursor_surf_offset;
1049 
1050 	if (DISPLAY_VER(display) >= 5 || display->platform.g4x)
1051 		cursor->capture_error = g4x_cursor_capture_error;
1052 	else
1053 		cursor->capture_error = i9xx_cursor_capture_error;
1054 
1055 	cursor->cursor.base = ~0;
1056 	cursor->cursor.cntl = ~0;
1057 
1058 	if (display->platform.i845g || display->platform.i865g || HAS_CUR_FBC(display))
1059 		cursor->cursor.size = ~0;
1060 
1061 	modifiers = intel_fb_plane_get_modifiers(display, INTEL_PLANE_CAP_NONE);
1062 
1063 	ret = drm_universal_plane_init(display->drm, &cursor->base,
1064 				       0, &intel_cursor_plane_funcs,
1065 				       intel_cursor_formats,
1066 				       ARRAY_SIZE(intel_cursor_formats),
1067 				       modifiers,
1068 				       DRM_PLANE_TYPE_CURSOR,
1069 				       "cursor %c", pipe_name(pipe));
1070 
1071 	kfree(modifiers);
1072 
1073 	if (ret)
1074 		goto fail;
1075 
1076 	if (DISPLAY_VER(display) >= 4)
1077 		drm_plane_create_rotation_property(&cursor->base,
1078 						   DRM_MODE_ROTATE_0,
1079 						   DRM_MODE_ROTATE_0 |
1080 						   DRM_MODE_ROTATE_180);
1081 
1082 	intel_cursor_add_size_hints_property(cursor);
1083 
1084 	drm_plane_create_blend_mode_property(&cursor->base,
1085 					     BIT(DRM_MODE_BLEND_PREMULTI));
1086 
1087 	zpos = DISPLAY_RUNTIME_INFO(display)->num_sprites[pipe] + 1;
1088 	drm_plane_create_zpos_immutable_property(&cursor->base, zpos);
1089 
1090 	if (DISPLAY_VER(display) >= 12)
1091 		drm_plane_enable_fb_damage_clips(&cursor->base);
1092 
1093 	intel_plane_helper_add(cursor);
1094 
1095 	return cursor;
1096 
1097 fail:
1098 	intel_plane_free(cursor);
1099 
1100 	return ERR_PTR(ret);
1101 }
1102 
intel_cursor_mode_config_init(struct intel_display * display)1103 void intel_cursor_mode_config_init(struct intel_display *display)
1104 {
1105 	struct drm_mode_config *mode_config = &display->drm->mode_config;
1106 
1107 	if (display->platform.i845g) {
1108 		mode_config->cursor_width = 64;
1109 		mode_config->cursor_height = 1023;
1110 	} else if (display->platform.i865g) {
1111 		mode_config->cursor_width = 512;
1112 		mode_config->cursor_height = 1023;
1113 	} else if (display->platform.i830 || display->platform.i85x ||
1114 		   display->platform.i915g || display->platform.i915gm) {
1115 		mode_config->cursor_width = 64;
1116 		mode_config->cursor_height = 64;
1117 	} else {
1118 		mode_config->cursor_width = 256;
1119 		mode_config->cursor_height = 256;
1120 	}
1121 }
1122