Rev 5060 | Rev 6084 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5060 | Rev 5271 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include |
32 | #include |
33 | #include |
33 | #include |
34 | #include |
34 | #include |
Line 35... | Line 35... | ||
35 | 35 | ||
- | 36 | #include |
|
36 | #include |
37 | #include |
37 | #include |
38 | #include |
38 | #include |
39 | #include |
39 | #include |
40 | #include |
- | 41 | #include |
|
- | 42 | #include |
|
40 | #include |
43 | #include |
Line -... | Line 44... | ||
- | 44 | #include |
|
- | 45 | ||
- | 46 | /** |
|
- | 47 | * DOC: overview |
|
- | 48 | * |
|
- | 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 |
|
- | 51 | * the same callbacks which drivers can use to e.g. restore the modeset |
|
- | 52 | * configuration on resume with drm_helper_resume_force_mode(). |
|
- | 53 | * |
|
- | 54 | * 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 |
|
- | 56 | * 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 |
|
- | 58 | * implement the old semantics required by the CRTC helpers using the new plane |
|
- | 59 | * and atomic helper callbacks. |
|
- | 60 | * |
|
- | 61 | * 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 |
|
- | 63 | * but need to implement the atomic interface instead, potentially using the |
|
41 | #include |
64 | * atomic helpers for that. |
42 | 65 | */ |
|
43 | MODULE_AUTHOR("David Airlie, Jesse Barnes"); |
66 | MODULE_AUTHOR("David Airlie, Jesse Barnes"); |
Line 44... | Line 67... | ||
44 | MODULE_DESCRIPTION("DRM KMS helper"); |
67 | MODULE_DESCRIPTION("DRM KMS helper"); |
Line 869... | Line 892... | ||
869 | /* disable the unused connectors while restoring the modesetting */ |
892 | /* disable the unused connectors while restoring the modesetting */ |
870 | __drm_helper_disable_unused_functions(dev); |
893 | __drm_helper_disable_unused_functions(dev); |
871 | drm_modeset_unlock_all(dev); |
894 | drm_modeset_unlock_all(dev); |
872 | } |
895 | } |
873 | EXPORT_SYMBOL(drm_helper_resume_force_mode);>>>>>>> |
896 | EXPORT_SYMBOL(drm_helper_resume_force_mode); |
- | 897 | ||
- | 898 | /** |
|
- | 899 | * drm_helper_crtc_mode_set - mode_set implementation for atomic plane helpers |
|
- | 900 | * @crtc: DRM CRTC |
|
- | 901 | * @mode: DRM display mode which userspace requested |
|
- | 902 | * @adjusted_mode: DRM display mode adjusted by ->mode_fixup callbacks |
|
- | 903 | * @x: x offset of the CRTC scanout area on the underlying framebuffer |
|
- | 904 | * @y: y offset of the CRTC scanout area on the underlying framebuffer |
|
- | 905 | * @old_fb: previous framebuffer |
|
- | 906 | * |
|
- | 907 | * This function implements a callback useable as the ->mode_set callback |
|
- | 908 | * required by the crtc helpers. Besides the atomic plane helper functions for |
|
- | 909 | * the primary plane the driver must also provide the ->mode_set_nofb callback |
|
- | 910 | * to set up the crtc. |
|
- | 911 | * |
|
- | 912 | * This is a transitional helper useful for converting drivers to the atomic |
|
- | 913 | * interfaces. |
|
- | 914 | */ |
|
- | 915 | int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, |
|
- | 916 | struct drm_display_mode *adjusted_mode, int x, int y, |
|
- | 917 | struct drm_framebuffer *old_fb) |
|
- | 918 | { |
|
- | 919 | struct drm_crtc_state *crtc_state; |
|
- | 920 | struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; |
|
- | 921 | int ret; |
|
- | 922 | ||
- | 923 | if (crtc->funcs->atomic_duplicate_state) |
|
- | 924 | crtc_state = crtc->funcs->atomic_duplicate_state(crtc); |
|
- | 925 | else if (crtc->state) |
|
- | 926 | crtc_state = kmemdup(crtc->state, sizeof(*crtc_state), |
|
- | 927 | GFP_KERNEL); |
|
- | 928 | else |
|
- | 929 | crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL); |
|
- | 930 | if (!crtc_state) |
|
- | 931 | return -ENOMEM; |
|
- | 932 | ||
- | 933 | crtc_state->enable = true; |
|
- | 934 | crtc_state->planes_changed = true; |
|
- | 935 | crtc_state->mode_changed = true; |
|
- | 936 | drm_mode_copy(&crtc_state->mode, mode); |
|
- | 937 | drm_mode_copy(&crtc_state->adjusted_mode, adjusted_mode); |
|
- | 938 | ||
- | 939 | if (crtc_funcs->atomic_check) { |
|
- | 940 | ret = crtc_funcs->atomic_check(crtc, crtc_state); |
|
- | 941 | if (ret) { |
|
- | 942 | kfree(crtc_state); |
|
- | 943 | ||
- | 944 | return ret; |
|
- | 945 | } |
|
- | 946 | } |
|
- | 947 | ||
- | 948 | swap(crtc->state, crtc_state); |
|
- | 949 | ||
- | 950 | crtc_funcs->mode_set_nofb(crtc); |
|
- | 951 | ||
- | 952 | if (crtc_state) { |
|
- | 953 | if (crtc->funcs->atomic_destroy_state) |
|
- | 954 | crtc->funcs->atomic_destroy_state(crtc, crtc_state); |
|
- | 955 | else |
|
- | 956 | kfree(crtc_state); |
|
- | 957 | } |
|
- | 958 | ||
- | 959 | return drm_helper_crtc_mode_set_base(crtc, x, y, old_fb); |
|
- | 960 | } |
|
- | 961 | EXPORT_SYMBOL(drm_helper_crtc_mode_set); |
|
- | 962 | ||
- | 963 | /** |
|
- | 964 | * drm_helper_crtc_mode_set_base - mode_set_base implementation for atomic plane helpers |
|
- | 965 | * @crtc: DRM CRTC |
|
- | 966 | * @x: x offset of the CRTC scanout area on the underlying framebuffer |
|
- | 967 | * @y: y offset of the CRTC scanout area on the underlying framebuffer |
|
- | 968 | * @old_fb: previous framebuffer |
|
- | 969 | * |
|
- | 970 | * This function implements a callback useable as the ->mode_set_base used |
|
- | 971 | * required by the crtc helpers. The driver must provide the atomic plane helper |
|
- | 972 | * functions for the primary plane. |
|
- | 973 | * |
|
- | 974 | * This is a transitional helper useful for converting drivers to the atomic |
|
- | 975 | * interfaces. |
|
- | 976 | */ |
|
- | 977 | int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, |
|
- | 978 | struct drm_framebuffer *old_fb) |
|
- | 979 | { |
|
- | 980 | struct drm_plane_state *plane_state; |
|
- | 981 | struct drm_plane *plane = crtc->primary; |
|
- | 982 | ||
- | 983 | if (plane->funcs->atomic_duplicate_state) |
|
- | 984 | plane_state = plane->funcs->atomic_duplicate_state(plane); |
|
- | 985 | else if (plane->state) |
|
- | 986 | plane_state = drm_atomic_helper_plane_duplicate_state(plane); |
|
- | 987 | else |
|
- | 988 | plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL); |
|
- | 989 | if (!plane_state) |
|
- | 990 | return -ENOMEM; |
|
- | 991 | ||
- | 992 | plane_state->crtc = crtc; |
|
- | 993 | drm_atomic_set_fb_for_plane(plane_state, crtc->primary->fb); |
|
- | 994 | plane_state->crtc_x = 0; |
|
- | 995 | plane_state->crtc_y = 0; |
|
- | 996 | plane_state->crtc_h = crtc->mode.vdisplay; |
|
- | 997 | plane_state->crtc_w = crtc->mode.hdisplay; |
|
- | 998 | plane_state->src_x = x << 16; |
|
- | 999 | plane_state->src_y = y << 16; |
|
- | 1000 | plane_state->src_h = crtc->mode.vdisplay << 16; |
|
- | 1001 | plane_state->src_w = crtc->mode.hdisplay << 16; |
|
- | 1002 | ||
- | 1003 | return drm_plane_helper_commit(plane, plane_state, old_fb); |
|
- | 1004 | } |
|
- | 1005 | EXPORT_SYMBOL(drm_helper_crtc_mode_set_base);><>><>><>><>>>>>>>> |