Subversion Repositories Kolibri OS

Rev

Rev 6084 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6084 Rev 6937
Line 49... Line 49...
49
 * The CRTC modeset helper library provides a default set_config implementation
49
 * The CRTC modeset helper library provides a default set_config implementation
50
 * in drm_crtc_helper_set_config(). Plus a few other convenience functions using
50
 * in drm_crtc_helper_set_config(). Plus a few other convenience functions using
51
 * the same callbacks which drivers can use to e.g. restore the modeset
51
 * the same callbacks which drivers can use to e.g. restore the modeset
52
 * configuration on resume with drm_helper_resume_force_mode().
52
 * configuration on resume with drm_helper_resume_force_mode().
53
 *
53
 *
-
 
54
 * Note that this helper library doesn't track the current power state of CRTCs
-
 
55
 * and encoders. It can call callbacks like ->dpms() even though the hardware is
-
 
56
 * already in the desired state. This deficiency has been fixed in the atomic
-
 
57
 * helpers.
-
 
58
 *
54
 * The driver callbacks are mostly compatible with the atomic modeset helpers,
59
 * The driver callbacks are mostly compatible with the atomic modeset helpers,
55
 * except for the handling of the primary plane: Atomic helpers require that the
60
 * except for the handling of the primary plane: Atomic helpers require that the
56
 * primary plane is implemented as a real standalone plane and not directly tied
61
 * primary plane is implemented as a real standalone plane and not directly tied
57
 * to the CRTC state. For easier transition this library provides functions to
62
 * to the CRTC state. For easier transition this library provides functions to
58
 * implement the old semantics required by the CRTC helpers using the new plane
63
 * implement the old semantics required by the CRTC helpers using the new plane
Line 60... Line 65...
60
 *
65
 *
61
 * Drivers are strongly urged to convert to the atomic helpers (by way of first
66
 * Drivers are strongly urged to convert to the atomic helpers (by way of first
62
 * converting to the plane helpers). New drivers must not use these functions
67
 * converting to the plane helpers). New drivers must not use these functions
63
 * but need to implement the atomic interface instead, potentially using the
68
 * but need to implement the atomic interface instead, potentially using the
64
 * atomic helpers for that.
69
 * atomic helpers for that.
-
 
70
 *
-
 
71
 * These legacy modeset helpers use the same function table structures as
-
 
72
 * all other modesetting helpers. See the documentation for struct
-
 
73
 * &drm_crtc_helper_funcs, struct &drm_encoder_helper_funcs and struct
-
 
74
 * &drm_connector_helper_funcs.
65
 */
75
 */
66
MODULE_AUTHOR("David Airlie, Jesse Barnes");
76
MODULE_AUTHOR("David Airlie, Jesse Barnes");
67
MODULE_DESCRIPTION("DRM KMS helper");
77
MODULE_DESCRIPTION("DRM KMS helper");
68
MODULE_LICENSE("GPL and additional rights");
78
MODULE_LICENSE("GPL and additional rights");
Line 204... Line 214...
204
/**
214
/**
205
 * drm_helper_disable_unused_functions - disable unused objects
215
 * drm_helper_disable_unused_functions - disable unused objects
206
 * @dev: DRM device
216
 * @dev: DRM device
207
 *
217
 *
208
 * This function walks through the entire mode setting configuration of @dev. It
218
 * This function walks through the entire mode setting configuration of @dev. It
209
 * will remove any crtc links of unused encoders and encoder links of
219
 * will remove any CRTC links of unused encoders and encoder links of
210
 * disconnected connectors. Then it will disable all unused encoders and crtcs
220
 * disconnected connectors. Then it will disable all unused encoders and CRTCs
211
 * either by calling their disable callback if available or by calling their
221
 * either by calling their disable callback if available or by calling their
212
 * dpms callback with DRM_MODE_DPMS_OFF.
222
 * dpms callback with DRM_MODE_DPMS_OFF.
213
 */
223
 */
214
void drm_helper_disable_unused_functions(struct drm_device *dev)
224
void drm_helper_disable_unused_functions(struct drm_device *dev)
215
{
225
{
Line 327... Line 337...
327
 
337
 
328
	if (!(ret = crtc_funcs->mode_fixup(crtc, mode, adjusted_mode))) {
338
	if (!(ret = crtc_funcs->mode_fixup(crtc, mode, adjusted_mode))) {
329
		DRM_DEBUG_KMS("CRTC fixup failed\n");
339
		DRM_DEBUG_KMS("CRTC fixup failed\n");
330
		goto done;
340
		goto done;
331
	}
341
	}
Line 332... Line 342...
332
	DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
342
	DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
Line 333... Line 343...
333
 
343
 
334
	crtc->hwmode = *adjusted_mode;
344
	crtc->hwmode = *adjusted_mode;
Line 443... Line 453...
443
 
453
 
444
/**
454
/**
445
 * drm_crtc_helper_set_config - set a new config from userspace
455
 * drm_crtc_helper_set_config - set a new config from userspace
446
 * @set: mode set configuration
456
 * @set: mode set configuration
-
 
457
 *
-
 
458
 * The drm_crtc_helper_set_config() helper function implements the set_config
-
 
459
 * callback of struct &drm_crtc_funcs for drivers using the legacy CRTC helpers.
-
 
460
 *
-
 
461
 * It first tries to locate the best encoder for each connector by calling the
-
 
462
 * connector ->best_encoder() (struct &drm_connector_helper_funcs) helper
-
 
463
 * operation.
-
 
464
 *
-
 
465
 * After locating the appropriate encoders, the helper function will call the
-
 
466
 * mode_fixup encoder and CRTC helper operations to adjust the requested mode,
-
 
467
 * or reject it completely in which case an error will be returned to the
447
 *
468
 * application. If the new configuration after mode adjustment is identical to
-
 
469
 * the current configuration the helper function will return without performing
-
 
470
 * any other operation.
-
 
471
 *
-
 
472
 * If the adjusted mode is identical to the current mode but changes to the
-
 
473
 * frame buffer need to be applied, the drm_crtc_helper_set_config() function
-
 
474
 * will call the CRTC ->mode_set_base() (struct &drm_crtc_helper_funcs) helper
-
 
475
 * operation.
448
 * Setup a new configuration, provided by the upper layers (either an ioctl call
476
 *
449
 * from userspace or internally e.g. from the fbdev support code) in @set, and
477
 * If the adjusted mode differs from the current mode, or if the
-
 
478
 * ->mode_set_base() helper operation is not provided, the helper function
450
 * enable it. This is the main helper functions for drivers that implement
479
 * performs a full mode set sequence by calling the ->prepare(), ->mode_set()
451
 * kernel mode setting with the crtc helper functions and the assorted
480
 * and ->commit() CRTC and encoder helper operations, in that order.
-
 
481
 * Alternatively it can also use the dpms and disable helper operations. For
-
 
482
 * details see struct &drm_crtc_helper_funcs and struct
-
 
483
 * &drm_encoder_helper_funcs.
-
 
484
 *
-
 
485
 * This function is deprecated.  New drivers must implement atomic modeset
-
 
486
 * support, for which this function is unsuitable. Instead drivers should use
452
 * ->prepare(), ->modeset() and ->commit() helper callbacks.
487
 * drm_atomic_helper_set_config().
453
 *
488
 *
454
 * Returns:
489
 * Returns:
455
 * Returns 0 on success, negative errno numbers on failure.
490
 * Returns 0 on success, negative errno numbers on failure.
456
 */
491
 */
Line 482... Line 517...
482
 
517
 
483
	if (!set->mode)
518
	if (!set->mode)
Line 484... Line 519...
484
		set->fb = NULL;
519
		set->fb = NULL;
485
 
520
 
486
	if (set->fb) {
521
	if (set->fb) {
-
 
522
		DRM_DEBUG_KMS("[CRTC:%d:%s] [FB:%d] #connectors=%d (x y) (%i %i)\n",
487
		DRM_DEBUG_KMS("[CRTC:%d] [FB:%d] #connectors=%d (x y) (%i %i)\n",
523
			      set->crtc->base.id, set->crtc->name,
488
				set->crtc->base.id, set->fb->base.id,
524
			      set->fb->base.id,
489
				(int)set->num_connectors, set->x, set->y);
525
				(int)set->num_connectors, set->x, set->y);
-
 
526
	} else {
490
	} else {
527
		DRM_DEBUG_KMS("[CRTC:%d:%s] [NOFB]\n",
491
		DRM_DEBUG_KMS("[CRTC:%d] [NOFB]\n", set->crtc->base.id);
528
			      set->crtc->base.id, set->crtc->name);
492
		drm_crtc_helper_disable(set->crtc);
529
		drm_crtc_helper_disable(set->crtc);
Line 493... Line 530...
493
		return 0;
530
		return 0;
Line 626... Line 663...
626
			DRM_DEBUG_KMS("crtc changed, full mode switch\n");
663
			DRM_DEBUG_KMS("crtc changed, full mode switch\n");
627
			mode_changed = true;
664
			mode_changed = true;
628
			connector->encoder->crtc = new_crtc;
665
			connector->encoder->crtc = new_crtc;
629
		}
666
		}
630
		if (new_crtc) {
667
		if (new_crtc) {
631
			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [CRTC:%d]\n",
668
			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [CRTC:%d:%s]\n",
632
				connector->base.id, connector->name,
669
				connector->base.id, connector->name,
633
				new_crtc->base.id);
670
				      new_crtc->base.id, new_crtc->name);
634
		} else {
671
		} else {
635
			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [NOCRTC]\n",
672
			DRM_DEBUG_KMS("[CONNECTOR:%d:%s] to [NOCRTC]\n",
636
				connector->base.id, connector->name);
673
				connector->base.id, connector->name);
637
		}
674
		}
638
	}
675
	}
Line 648... Line 685...
648
			drm_mode_debug_printmodeline(set->mode);
685
			drm_mode_debug_printmodeline(set->mode);
649
			set->crtc->primary->fb = set->fb;
686
			set->crtc->primary->fb = set->fb;
650
			if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
687
			if (!drm_crtc_helper_set_mode(set->crtc, set->mode,
651
						      set->x, set->y,
688
						      set->x, set->y,
652
						      save_set.fb)) {
689
						      save_set.fb)) {
653
				DRM_ERROR("failed to set mode on [CRTC:%d]\n",
690
				DRM_ERROR("failed to set mode on [CRTC:%d:%s]\n",
654
					  set->crtc->base.id);
691
					  set->crtc->base.id, set->crtc->name);
655
				set->crtc->primary->fb = save_set.fb;
692
				set->crtc->primary->fb = save_set.fb;
656
				ret = -EINVAL;
693
				ret = -EINVAL;
657
				goto fail;
694
				goto fail;
658
			}
695
			}
659
			DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
696
			DRM_DEBUG_KMS("Setting connector DPMS state to on\n");
Line 756... Line 793...
756
/**
793
/**
757
 * drm_helper_connector_dpms() - connector dpms helper implementation
794
 * drm_helper_connector_dpms() - connector dpms helper implementation
758
 * @connector: affected connector
795
 * @connector: affected connector
759
 * @mode: DPMS mode
796
 * @mode: DPMS mode
760
 *
797
 *
-
 
798
 * The drm_helper_connector_dpms() helper function implements the ->dpms()
-
 
799
 * callback of struct &drm_connector_funcs for drivers using the legacy CRTC helpers.
-
 
800
 *
761
 * This is the main helper function provided by the crtc helper framework for
801
 * This is the main helper function provided by the CRTC helper framework for
762
 * implementing the DPMS connector attribute. It computes the new desired DPMS
802
 * implementing the DPMS connector attribute. It computes the new desired DPMS
763
 * state for all encoders and crtcs in the output mesh and calls the ->dpms()
803
 * state for all encoders and CRTCs in the output mesh and calls the ->dpms()
-
 
804
 * callbacks provided by the driver in struct &drm_crtc_helper_funcs and struct
764
 * callback provided by the driver appropriately.
805
 * &drm_encoder_helper_funcs appropriately.
-
 
806
 *
-
 
807
 * This function is deprecated.  New drivers must implement atomic modeset
-
 
808
 * support, for which this function is unsuitable. Instead drivers should use
-
 
809
 * drm_atomic_helper_connector_dpms().
765
 *
810
 *
766
 * Returns:
811
 * Returns:
767
 * Always returns 0.
812
 * Always returns 0.
768
 */
813
 */
769
int drm_helper_connector_dpms(struct drm_connector *connector, int mode)
814
int drm_helper_connector_dpms(struct drm_connector *connector, int mode)
Line 816... Line 861...
816
 *
861
 *
817
 * This helper can be used in a drivers fb_create callback to pre-fill the fb's
862
 * This helper can be used in a drivers fb_create callback to pre-fill the fb's
818
 * metadata fields.
863
 * metadata fields.
819
 */
864
 */
820
void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
865
void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
821
				    struct drm_mode_fb_cmd2 *mode_cmd)
866
				    const struct drm_mode_fb_cmd2 *mode_cmd)
822
{
867
{
823
	int i;
868
	int i;
Line 824... Line 869...
824
 
869
 
825
	fb->width = mode_cmd->width;
870
	fb->width = mode_cmd->width;
Line 853... Line 898...
853
 *
898
 *
854
 * Drivers where simply restoring an old configuration again might fail (e.g.
899
 * Drivers where simply restoring an old configuration again might fail (e.g.
855
 * due to slight differences in allocating shared resources when the
900
 * due to slight differences in allocating shared resources when the
856
 * configuration is restored in a different order than when userspace set it up)
901
 * configuration is restored in a different order than when userspace set it up)
857
 * need to use their own restore logic.
902
 * need to use their own restore logic.
-
 
903
 *
-
 
904
 * This function is deprecated. New drivers should implement atomic mode-
-
 
905
 * setting and use the atomic suspend/resume helpers.
-
 
906
 *
-
 
907
 * See also:
-
 
908
 * drm_atomic_helper_suspend(), drm_atomic_helper_resume()
858
 */
909
 */
859
void drm_helper_resume_force_mode(struct drm_device *dev)
910
void drm_helper_resume_force_mode(struct drm_device *dev)
860
{
911
{
861
	struct drm_crtc *crtc;
912
	struct drm_crtc *crtc;
862
	struct drm_encoder *encoder;
913
	struct drm_encoder *encoder;
Line 911... Line 962...
911
 * @x: x offset of the CRTC scanout area on the underlying framebuffer
962
 * @x: x offset of the CRTC scanout area on the underlying framebuffer
912
 * @y: y offset of the CRTC scanout area on the underlying framebuffer
963
 * @y: y offset of the CRTC scanout area on the underlying framebuffer
913
 * @old_fb: previous framebuffer
964
 * @old_fb: previous framebuffer
914
 *
965
 *
915
 * This function implements a callback useable as the ->mode_set callback
966
 * This function implements a callback useable as the ->mode_set callback
916
 * required by the crtc helpers. Besides the atomic plane helper functions for
967
 * required by the CRTC helpers. Besides the atomic plane helper functions for
917
 * the primary plane the driver must also provide the ->mode_set_nofb callback
968
 * the primary plane the driver must also provide the ->mode_set_nofb callback
918
 * to set up the crtc.
969
 * to set up the CRTC.
919
 *
970
 *
920
 * This is a transitional helper useful for converting drivers to the atomic
971
 * This is a transitional helper useful for converting drivers to the atomic
921
 * interfaces.
972
 * interfaces.
922
 */
973
 */
923
int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
974
int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
Line 977... Line 1028...
977
 * @x: x offset of the CRTC scanout area on the underlying framebuffer
1028
 * @x: x offset of the CRTC scanout area on the underlying framebuffer
978
 * @y: y offset of the CRTC scanout area on the underlying framebuffer
1029
 * @y: y offset of the CRTC scanout area on the underlying framebuffer
979
 * @old_fb: previous framebuffer
1030
 * @old_fb: previous framebuffer
980
 *
1031
 *
981
 * This function implements a callback useable as the ->mode_set_base used
1032
 * This function implements a callback useable as the ->mode_set_base used
982
 * required by the crtc helpers. The driver must provide the atomic plane helper
1033
 * required by the CRTC helpers. The driver must provide the atomic plane helper
983
 * functions for the primary plane.
1034
 * functions for the primary plane.
984
 *
1035
 *
985
 * This is a transitional helper useful for converting drivers to the atomic
1036
 * This is a transitional helper useful for converting drivers to the atomic
986
 * interfaces.
1037
 * interfaces.
987
 */
1038
 */