@@ -247,11 +247,19 @@ static void intel_plane_clear_hw_state(struct intel_plane_state *plane_state)
247247}
248248
249249void intel_plane_copy_uapi_to_hw_state (struct intel_plane_state * plane_state ,
250- const struct intel_plane_state * from_plane_state )
250+ const struct intel_plane_state * from_plane_state ,
251+ struct intel_crtc * crtc )
251252{
252253 intel_plane_clear_hw_state (plane_state );
253254
254- plane_state -> hw .crtc = from_plane_state -> uapi .crtc ;
255+ /*
256+ * For the bigjoiner slave uapi.crtc will point at
257+ * the master crtc. So we explicitly assign the right
258+ * slave crtc to hw.crtc. uapi.crtc!=NULL simply indicates
259+ * the plane is logically enabled on the uapi level.
260+ */
261+ plane_state -> hw .crtc = from_plane_state -> uapi .crtc ? & crtc -> base : NULL ;
262+
255263 plane_state -> hw .fb = from_plane_state -> uapi .fb ;
256264 if (plane_state -> hw .fb )
257265 drm_framebuffer_get (plane_state -> hw .fb );
@@ -263,6 +271,21 @@ void intel_plane_copy_uapi_to_hw_state(struct intel_plane_state *plane_state,
263271 plane_state -> hw .color_encoding = from_plane_state -> uapi .color_encoding ;
264272 plane_state -> hw .color_range = from_plane_state -> uapi .color_range ;
265273 plane_state -> hw .scaling_filter = from_plane_state -> uapi .scaling_filter ;
274+
275+ plane_state -> uapi .src = drm_plane_state_src (& from_plane_state -> uapi );
276+ plane_state -> uapi .dst = drm_plane_state_dest (& from_plane_state -> uapi );
277+ }
278+
279+ void intel_plane_copy_hw_state (struct intel_plane_state * plane_state ,
280+ const struct intel_plane_state * from_plane_state )
281+ {
282+ intel_plane_clear_hw_state (plane_state );
283+
284+ memcpy (& plane_state -> hw , & from_plane_state -> hw ,
285+ sizeof (plane_state -> hw ));
286+
287+ if (plane_state -> hw .fb )
288+ drm_framebuffer_get (plane_state -> hw .fb );
266289}
267290
268291void intel_plane_set_invisible (struct intel_crtc_state * crtc_state ,
@@ -319,39 +342,54 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_
319342 old_plane_state , new_plane_state );
320343}
321344
322- static struct intel_crtc *
323- get_crtc_from_states (const struct intel_plane_state * old_plane_state ,
324- const struct intel_plane_state * new_plane_state )
345+ static struct intel_plane *
346+ intel_crtc_get_plane (struct intel_crtc * crtc , enum plane_id plane_id )
325347{
326- if ( new_plane_state -> uapi . crtc )
327- return to_intel_crtc ( new_plane_state -> uapi . crtc ) ;
348+ struct drm_i915_private * i915 = to_i915 ( crtc -> base . dev );
349+ struct intel_plane * plane ;
328350
329- if (old_plane_state -> uapi .crtc )
330- return to_intel_crtc (old_plane_state -> uapi .crtc );
351+ for_each_intel_plane_on_crtc (& i915 -> drm , crtc , plane ) {
352+ if (plane -> id == plane_id )
353+ return plane ;
354+ }
331355
332356 return NULL ;
333357}
334358
335359int intel_plane_atomic_check (struct intel_atomic_state * state ,
336360 struct intel_plane * plane )
337361{
362+ struct drm_i915_private * i915 = to_i915 (state -> base .dev );
338363 struct intel_plane_state * new_plane_state =
339364 intel_atomic_get_new_plane_state (state , plane );
340365 const struct intel_plane_state * old_plane_state =
341366 intel_atomic_get_old_plane_state (state , plane );
342- struct intel_crtc * crtc =
343- get_crtc_from_states (old_plane_state , new_plane_state );
344- const struct intel_crtc_state * old_crtc_state ;
345- struct intel_crtc_state * new_crtc_state ;
367+ const struct intel_plane_state * new_master_plane_state ;
368+ struct intel_crtc * crtc = intel_get_crtc_for_pipe (i915 , plane -> pipe );
369+ const struct intel_crtc_state * old_crtc_state =
370+ intel_atomic_get_old_crtc_state (state , crtc );
371+ struct intel_crtc_state * new_crtc_state =
372+ intel_atomic_get_new_crtc_state (state , crtc );
373+
374+ if (new_crtc_state && new_crtc_state -> bigjoiner_slave ) {
375+ struct intel_plane * master_plane =
376+ intel_crtc_get_plane (new_crtc_state -> bigjoiner_linked_crtc ,
377+ plane -> id );
378+
379+ new_master_plane_state =
380+ intel_atomic_get_new_plane_state (state , master_plane );
381+ } else {
382+ new_master_plane_state = new_plane_state ;
383+ }
384+
385+ intel_plane_copy_uapi_to_hw_state (new_plane_state ,
386+ new_master_plane_state ,
387+ crtc );
346388
347- intel_plane_copy_uapi_to_hw_state (new_plane_state , new_plane_state );
348389 new_plane_state -> uapi .visible = false;
349- if (!crtc )
390+ if (!new_crtc_state )
350391 return 0 ;
351392
352- old_crtc_state = intel_atomic_get_old_crtc_state (state , crtc );
353- new_crtc_state = intel_atomic_get_new_crtc_state (state , crtc );
354-
355393 return intel_plane_atomic_check_with_state (old_crtc_state ,
356394 new_crtc_state ,
357395 old_plane_state ,
@@ -479,6 +517,63 @@ void i9xx_update_planes_on_crtc(struct intel_atomic_state *state,
479517 }
480518}
481519
520+ int intel_atomic_plane_check_clipping (struct intel_plane_state * plane_state ,
521+ struct intel_crtc_state * crtc_state ,
522+ int min_scale , int max_scale ,
523+ bool can_position )
524+ {
525+ struct drm_framebuffer * fb = plane_state -> hw .fb ;
526+ struct drm_rect * src = & plane_state -> uapi .src ;
527+ struct drm_rect * dst = & plane_state -> uapi .dst ;
528+ unsigned int rotation = plane_state -> hw .rotation ;
529+ struct drm_rect clip = {};
530+ int hscale , vscale ;
531+
532+ if (!fb ) {
533+ plane_state -> uapi .visible = false;
534+ return 0 ;
535+ }
536+
537+ drm_rect_rotate (src , fb -> width << 16 , fb -> height << 16 , rotation );
538+
539+ /* Check scaling */
540+ hscale = drm_rect_calc_hscale (src , dst , min_scale , max_scale );
541+ vscale = drm_rect_calc_vscale (src , dst , min_scale , max_scale );
542+ if (hscale < 0 || vscale < 0 ) {
543+ DRM_DEBUG_KMS ("Invalid scaling of plane\n" );
544+ drm_rect_debug_print ("src: " , src , true);
545+ drm_rect_debug_print ("dst: " , dst , false);
546+ return - ERANGE ;
547+ }
548+
549+ if (crtc_state -> hw .enable ) {
550+ clip .x2 = crtc_state -> pipe_src_w ;
551+ clip .y2 = crtc_state -> pipe_src_h ;
552+ }
553+
554+ /* right side of the image is on the slave crtc, adjust dst to match */
555+ if (crtc_state -> bigjoiner_slave )
556+ drm_rect_translate (dst , - crtc_state -> pipe_src_w , 0 );
557+
558+ /*
559+ * FIXME: This might need further adjustment for seamless scaling
560+ * with phase information, for the 2p2 and 2p1 scenarios.
561+ */
562+ plane_state -> uapi .visible = drm_rect_clip_scaled (src , dst , & clip );
563+
564+ drm_rect_rotate_inv (src , fb -> width << 16 , fb -> height << 16 , rotation );
565+
566+ if (!can_position && plane_state -> uapi .visible &&
567+ !drm_rect_equals (dst , & clip )) {
568+ DRM_DEBUG_KMS ("Plane must cover entire CRTC\n" );
569+ drm_rect_debug_print ("dst: " , dst , false);
570+ drm_rect_debug_print ("clip: " , & clip , false);
571+ return - EINVAL ;
572+ }
573+
574+ return 0 ;
575+ }
576+
482577const struct drm_plane_helper_funcs intel_plane_helper_funcs = {
483578 .prepare_fb = intel_prepare_plane_fb ,
484579 .cleanup_fb = intel_cleanup_plane_fb ,
0 commit comments