aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Osipenko <digetx@gmail.com>2018-03-14 21:00:25 -0400
committerThierry Reding <treding@nvidia.com>2018-03-15 06:42:03 -0400
commit9f446d83b233d2773fd934eed41d795484a08422 (patch)
tree69d0b7ef7c669c41cf68cf17ec91a2f467ab1191
parent5e2e86f12cba9591b4ad3c1e7f76e149319af9e7 (diff)
drm/tegra: dc: Dedicate overlay plane to cursor on older Tegra's
Older Tegra's do not support RGBA format for the cursor, but instead overlay plane could be used for it. Since there is no much use for the overlays on a regular desktop and HW-accelerated cursor is much better than a SW cursor, let's dedicate one overlay plane to the mouse cursor. Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--drivers/gpu/drm/tegra/dc.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index b8403ed48285..ead13ac325b0 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -864,11 +864,13 @@ static const u32 tegra124_overlay_formats[] = {
864 864
865static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm, 865static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
866 struct tegra_dc *dc, 866 struct tegra_dc *dc,
867 unsigned int index) 867 unsigned int index,
868 bool cursor)
868{ 869{
869 unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm); 870 unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
870 struct tegra_plane *plane; 871 struct tegra_plane *plane;
871 unsigned int num_formats; 872 unsigned int num_formats;
873 enum drm_plane_type type;
872 const u32 *formats; 874 const u32 *formats;
873 int err; 875 int err;
874 876
@@ -883,10 +885,14 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
883 num_formats = dc->soc->num_overlay_formats; 885 num_formats = dc->soc->num_overlay_formats;
884 formats = dc->soc->overlay_formats; 886 formats = dc->soc->overlay_formats;
885 887
888 if (!cursor)
889 type = DRM_PLANE_TYPE_OVERLAY;
890 else
891 type = DRM_PLANE_TYPE_CURSOR;
892
886 err = drm_universal_plane_init(drm, &plane->base, possible_crtcs, 893 err = drm_universal_plane_init(drm, &plane->base, possible_crtcs,
887 &tegra_plane_funcs, formats, 894 &tegra_plane_funcs, formats,
888 num_formats, NULL, 895 num_formats, NULL, type, NULL);
889 DRM_PLANE_TYPE_OVERLAY, NULL);
890 if (err < 0) { 896 if (err < 0) {
891 kfree(plane); 897 kfree(plane);
892 return ERR_PTR(err); 898 return ERR_PTR(err);
@@ -938,6 +944,7 @@ static struct drm_plane *tegra_dc_add_planes(struct drm_device *drm,
938 struct tegra_dc *dc) 944 struct tegra_dc *dc)
939{ 945{
940 struct drm_plane *planes[2], *primary; 946 struct drm_plane *planes[2], *primary;
947 unsigned int planes_num;
941 unsigned int i; 948 unsigned int i;
942 int err; 949 int err;
943 950
@@ -945,8 +952,14 @@ static struct drm_plane *tegra_dc_add_planes(struct drm_device *drm,
945 if (IS_ERR(primary)) 952 if (IS_ERR(primary))
946 return primary; 953 return primary;
947 954
948 for (i = 0; i < 2; i++) { 955 if (dc->soc->supports_cursor)
949 planes[i] = tegra_dc_overlay_plane_create(drm, dc, 1 + i); 956 planes_num = 2;
957 else
958 planes_num = 1;
959
960 for (i = 0; i < planes_num; i++) {
961 planes[i] = tegra_dc_overlay_plane_create(drm, dc, 1 + i,
962 false);
950 if (IS_ERR(planes[i])) { 963 if (IS_ERR(planes[i])) {
951 err = PTR_ERR(planes[i]); 964 err = PTR_ERR(planes[i]);
952 965
@@ -1864,6 +1877,13 @@ static int tegra_dc_init(struct host1x_client *client)
1864 err = PTR_ERR(cursor); 1877 err = PTR_ERR(cursor);
1865 goto cleanup; 1878 goto cleanup;
1866 } 1879 }
1880 } else {
1881 /* dedicate one overlay to mouse cursor */
1882 cursor = tegra_dc_overlay_plane_create(drm, dc, 2, true);
1883 if (IS_ERR(cursor)) {
1884 err = PTR_ERR(cursor);
1885 goto cleanup;
1886 }
1867 } 1887 }
1868 1888
1869 err = drm_crtc_init_with_planes(drm, &dc->base, primary, cursor, 1889 err = drm_crtc_init_with_planes(drm, &dc->base, primary, cursor,