aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2013-10-05 16:36:52 -0400
committerDave Airlie <airlied@redhat.com>2014-06-03 23:22:44 -0400
commita2b34e226ac9fbd20179091fad0ee1a24ad48669 (patch)
tree0b6b696d834373a1dbdeaab4c1bd8c644d5d873a /drivers/gpu/drm/drm_crtc.c
parentd5ab2b430b3cec65ba5b30b2e1de8ea46715cb93 (diff)
drm: helpers to find mode objects
Add a few more useful helpers to find mode objects. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r--drivers/gpu/drm/drm_crtc.c90
1 files changed, 28 insertions, 62 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index f6664a75ad57..c4b44be7d464 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -1692,7 +1692,6 @@ int drm_mode_getcrtc(struct drm_device *dev,
1692{ 1692{
1693 struct drm_mode_crtc *crtc_resp = data; 1693 struct drm_mode_crtc *crtc_resp = data;
1694 struct drm_crtc *crtc; 1694 struct drm_crtc *crtc;
1695 struct drm_mode_object *obj;
1696 int ret = 0; 1695 int ret = 0;
1697 1696
1698 if (!drm_core_check_feature(dev, DRIVER_MODESET)) 1697 if (!drm_core_check_feature(dev, DRIVER_MODESET))
@@ -1700,13 +1699,11 @@ int drm_mode_getcrtc(struct drm_device *dev,
1700 1699
1701 drm_modeset_lock_all(dev); 1700 drm_modeset_lock_all(dev);
1702 1701
1703 obj = drm_mode_object_find(dev, crtc_resp->crtc_id, 1702 crtc = drm_crtc_find(dev, crtc_resp->crtc_id);
1704 DRM_MODE_OBJECT_CRTC); 1703 if (!crtc) {
1705 if (!obj) {
1706 ret = -ENOENT; 1704 ret = -ENOENT;
1707 goto out; 1705 goto out;
1708 } 1706 }
1709 crtc = obj_to_crtc(obj);
1710 1707
1711 crtc_resp->x = crtc->x; 1708 crtc_resp->x = crtc->x;
1712 crtc_resp->y = crtc->y; 1709 crtc_resp->y = crtc->y;
@@ -1760,7 +1757,6 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
1760 struct drm_file *file_priv) 1757 struct drm_file *file_priv)
1761{ 1758{
1762 struct drm_mode_get_connector *out_resp = data; 1759 struct drm_mode_get_connector *out_resp = data;
1763 struct drm_mode_object *obj;
1764 struct drm_connector *connector; 1760 struct drm_connector *connector;
1765 struct drm_display_mode *mode; 1761 struct drm_display_mode *mode;
1766 int mode_count = 0; 1762 int mode_count = 0;
@@ -1784,13 +1780,11 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
1784 1780
1785 mutex_lock(&dev->mode_config.mutex); 1781 mutex_lock(&dev->mode_config.mutex);
1786 1782
1787 obj = drm_mode_object_find(dev, out_resp->connector_id, 1783 connector = drm_connector_find(dev, out_resp->connector_id);
1788 DRM_MODE_OBJECT_CONNECTOR); 1784 if (!connector) {
1789 if (!obj) {
1790 ret = -ENOENT; 1785 ret = -ENOENT;
1791 goto out; 1786 goto out;
1792 } 1787 }
1793 connector = obj_to_connector(obj);
1794 1788
1795 props_count = connector->properties.count; 1789 props_count = connector->properties.count;
1796 1790
@@ -1905,7 +1899,6 @@ int drm_mode_getencoder(struct drm_device *dev, void *data,
1905 struct drm_file *file_priv) 1899 struct drm_file *file_priv)
1906{ 1900{
1907 struct drm_mode_get_encoder *enc_resp = data; 1901 struct drm_mode_get_encoder *enc_resp = data;
1908 struct drm_mode_object *obj;
1909 struct drm_encoder *encoder; 1902 struct drm_encoder *encoder;
1910 int ret = 0; 1903 int ret = 0;
1911 1904
@@ -1913,13 +1906,11 @@ int drm_mode_getencoder(struct drm_device *dev, void *data,
1913 return -EINVAL; 1906 return -EINVAL;
1914 1907
1915 drm_modeset_lock_all(dev); 1908 drm_modeset_lock_all(dev);
1916 obj = drm_mode_object_find(dev, enc_resp->encoder_id, 1909 encoder = drm_encoder_find(dev, enc_resp->encoder_id);
1917 DRM_MODE_OBJECT_ENCODER); 1910 if (!encoder) {
1918 if (!obj) {
1919 ret = -ENOENT; 1911 ret = -ENOENT;
1920 goto out; 1912 goto out;
1921 } 1913 }
1922 encoder = obj_to_encoder(obj);
1923 1914
1924 if (encoder->crtc) 1915 if (encoder->crtc)
1925 enc_resp->crtc_id = encoder->crtc->base.id; 1916 enc_resp->crtc_id = encoder->crtc->base.id;
@@ -2017,7 +2008,6 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
2017 struct drm_file *file_priv) 2008 struct drm_file *file_priv)
2018{ 2009{
2019 struct drm_mode_get_plane *plane_resp = data; 2010 struct drm_mode_get_plane *plane_resp = data;
2020 struct drm_mode_object *obj;
2021 struct drm_plane *plane; 2011 struct drm_plane *plane;
2022 uint32_t __user *format_ptr; 2012 uint32_t __user *format_ptr;
2023 int ret = 0; 2013 int ret = 0;
@@ -2026,13 +2016,11 @@ int drm_mode_getplane(struct drm_device *dev, void *data,
2026 return -EINVAL; 2016 return -EINVAL;
2027 2017
2028 drm_modeset_lock_all(dev); 2018 drm_modeset_lock_all(dev);
2029 obj = drm_mode_object_find(dev, plane_resp->plane_id, 2019 plane = drm_plane_find(dev, plane_resp->plane_id);
2030 DRM_MODE_OBJECT_PLANE); 2020 if (!plane) {
2031 if (!obj) {
2032 ret = -ENOENT; 2021 ret = -ENOENT;
2033 goto out; 2022 goto out;
2034 } 2023 }
2035 plane = obj_to_plane(obj);
2036 2024
2037 if (plane->crtc) 2025 if (plane->crtc)
2038 plane_resp->crtc_id = plane->crtc->base.id; 2026 plane_resp->crtc_id = plane->crtc->base.id;
@@ -2085,7 +2073,6 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
2085 struct drm_file *file_priv) 2073 struct drm_file *file_priv)
2086{ 2074{
2087 struct drm_mode_set_plane *plane_req = data; 2075 struct drm_mode_set_plane *plane_req = data;
2088 struct drm_mode_object *obj;
2089 struct drm_plane *plane; 2076 struct drm_plane *plane;
2090 struct drm_crtc *crtc; 2077 struct drm_crtc *crtc;
2091 struct drm_framebuffer *fb = NULL, *old_fb = NULL; 2078 struct drm_framebuffer *fb = NULL, *old_fb = NULL;
@@ -2100,14 +2087,12 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
2100 * First, find the plane, crtc, and fb objects. If not available, 2087 * First, find the plane, crtc, and fb objects. If not available,
2101 * we don't bother to call the driver. 2088 * we don't bother to call the driver.
2102 */ 2089 */
2103 obj = drm_mode_object_find(dev, plane_req->plane_id, 2090 plane = drm_plane_find(dev, plane_req->plane_id);
2104 DRM_MODE_OBJECT_PLANE); 2091 if (!plane) {
2105 if (!obj) {
2106 DRM_DEBUG_KMS("Unknown plane ID %d\n", 2092 DRM_DEBUG_KMS("Unknown plane ID %d\n",
2107 plane_req->plane_id); 2093 plane_req->plane_id);
2108 return -ENOENT; 2094 return -ENOENT;
2109 } 2095 }
2110 plane = obj_to_plane(obj);
2111 2096
2112 /* No fb means shut it down */ 2097 /* No fb means shut it down */
2113 if (!plane_req->fb_id) { 2098 if (!plane_req->fb_id) {
@@ -2124,15 +2109,13 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
2124 goto out; 2109 goto out;
2125 } 2110 }
2126 2111
2127 obj = drm_mode_object_find(dev, plane_req->crtc_id, 2112 crtc = drm_crtc_find(dev, plane_req->crtc_id);
2128 DRM_MODE_OBJECT_CRTC); 2113 if (!crtc) {
2129 if (!obj) {
2130 DRM_DEBUG_KMS("Unknown crtc ID %d\n", 2114 DRM_DEBUG_KMS("Unknown crtc ID %d\n",
2131 plane_req->crtc_id); 2115 plane_req->crtc_id);
2132 ret = -ENOENT; 2116 ret = -ENOENT;
2133 goto out; 2117 goto out;
2134 } 2118 }
2135 crtc = obj_to_crtc(obj);
2136 2119
2137 fb = drm_framebuffer_lookup(dev, plane_req->fb_id); 2120 fb = drm_framebuffer_lookup(dev, plane_req->fb_id);
2138 if (!fb) { 2121 if (!fb) {
@@ -2319,7 +2302,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
2319{ 2302{
2320 struct drm_mode_config *config = &dev->mode_config; 2303 struct drm_mode_config *config = &dev->mode_config;
2321 struct drm_mode_crtc *crtc_req = data; 2304 struct drm_mode_crtc *crtc_req = data;
2322 struct drm_mode_object *obj;
2323 struct drm_crtc *crtc; 2305 struct drm_crtc *crtc;
2324 struct drm_connector **connector_set = NULL, *connector; 2306 struct drm_connector **connector_set = NULL, *connector;
2325 struct drm_framebuffer *fb = NULL; 2307 struct drm_framebuffer *fb = NULL;
@@ -2337,14 +2319,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
2337 return -ERANGE; 2319 return -ERANGE;
2338 2320
2339 drm_modeset_lock_all(dev); 2321 drm_modeset_lock_all(dev);
2340 obj = drm_mode_object_find(dev, crtc_req->crtc_id, 2322 crtc = drm_crtc_find(dev, crtc_req->crtc_id);
2341 DRM_MODE_OBJECT_CRTC); 2323 if (!crtc) {
2342 if (!obj) {
2343 DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id); 2324 DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id);
2344 ret = -ENOENT; 2325 ret = -ENOENT;
2345 goto out; 2326 goto out;
2346 } 2327 }
2347 crtc = obj_to_crtc(obj);
2348 DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); 2328 DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
2349 2329
2350 if (crtc_req->mode_valid) { 2330 if (crtc_req->mode_valid) {
@@ -2427,15 +2407,13 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
2427 goto out; 2407 goto out;
2428 } 2408 }
2429 2409
2430 obj = drm_mode_object_find(dev, out_id, 2410 connector = drm_connector_find(dev, out_id);
2431 DRM_MODE_OBJECT_CONNECTOR); 2411 if (!connector) {
2432 if (!obj) {
2433 DRM_DEBUG_KMS("Connector id %d unknown\n", 2412 DRM_DEBUG_KMS("Connector id %d unknown\n",
2434 out_id); 2413 out_id);
2435 ret = -ENOENT; 2414 ret = -ENOENT;
2436 goto out; 2415 goto out;
2437 } 2416 }
2438 connector = obj_to_connector(obj);
2439 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", 2417 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
2440 connector->base.id, 2418 connector->base.id,
2441 connector->name); 2419 connector->name);
@@ -2467,7 +2445,6 @@ static int drm_mode_cursor_common(struct drm_device *dev,
2467 struct drm_mode_cursor2 *req, 2445 struct drm_mode_cursor2 *req,
2468 struct drm_file *file_priv) 2446 struct drm_file *file_priv)
2469{ 2447{
2470 struct drm_mode_object *obj;
2471 struct drm_crtc *crtc; 2448 struct drm_crtc *crtc;
2472 int ret = 0; 2449 int ret = 0;
2473 2450
@@ -2477,12 +2454,11 @@ static int drm_mode_cursor_common(struct drm_device *dev,
2477 if (!req->flags || (~DRM_MODE_CURSOR_FLAGS & req->flags)) 2454 if (!req->flags || (~DRM_MODE_CURSOR_FLAGS & req->flags))
2478 return -EINVAL; 2455 return -EINVAL;
2479 2456
2480 obj = drm_mode_object_find(dev, req->crtc_id, DRM_MODE_OBJECT_CRTC); 2457 crtc = drm_crtc_find(dev, req->crtc_id);
2481 if (!obj) { 2458 if (!crtc) {
2482 DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id); 2459 DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id);
2483 return -ENOENT; 2460 return -ENOENT;
2484 } 2461 }
2485 crtc = obj_to_crtc(obj);
2486 2462
2487 mutex_lock(&crtc->mutex); 2463 mutex_lock(&crtc->mutex);
2488 if (req->flags & DRM_MODE_CURSOR_BO) { 2464 if (req->flags & DRM_MODE_CURSOR_BO) {
@@ -3439,7 +3415,6 @@ EXPORT_SYMBOL(drm_object_property_get_value);
3439int drm_mode_getproperty_ioctl(struct drm_device *dev, 3415int drm_mode_getproperty_ioctl(struct drm_device *dev,
3440 void *data, struct drm_file *file_priv) 3416 void *data, struct drm_file *file_priv)
3441{ 3417{
3442 struct drm_mode_object *obj;
3443 struct drm_mode_get_property *out_resp = data; 3418 struct drm_mode_get_property *out_resp = data;
3444 struct drm_property *property; 3419 struct drm_property *property;
3445 int enum_count = 0; 3420 int enum_count = 0;
@@ -3458,12 +3433,11 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
3458 return -EINVAL; 3433 return -EINVAL;
3459 3434
3460 drm_modeset_lock_all(dev); 3435 drm_modeset_lock_all(dev);
3461 obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); 3436 property = drm_property_find(dev, out_resp->prop_id);
3462 if (!obj) { 3437 if (!property) {
3463 ret = -ENOENT; 3438 ret = -ENOENT;
3464 goto done; 3439 goto done;
3465 } 3440 }
3466 property = obj_to_property(obj);
3467 3441
3468 if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) { 3442 if (property->flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) {
3469 list_for_each_entry(prop_enum, &property->enum_blob_list, head) 3443 list_for_each_entry(prop_enum, &property->enum_blob_list, head)
@@ -3591,7 +3565,6 @@ static void drm_property_destroy_blob(struct drm_device *dev,
3591int drm_mode_getblob_ioctl(struct drm_device *dev, 3565int drm_mode_getblob_ioctl(struct drm_device *dev,
3592 void *data, struct drm_file *file_priv) 3566 void *data, struct drm_file *file_priv)
3593{ 3567{
3594 struct drm_mode_object *obj;
3595 struct drm_mode_get_blob *out_resp = data; 3568 struct drm_mode_get_blob *out_resp = data;
3596 struct drm_property_blob *blob; 3569 struct drm_property_blob *blob;
3597 int ret = 0; 3570 int ret = 0;
@@ -3601,12 +3574,11 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
3601 return -EINVAL; 3574 return -EINVAL;
3602 3575
3603 drm_modeset_lock_all(dev); 3576 drm_modeset_lock_all(dev);
3604 obj = drm_mode_object_find(dev, out_resp->blob_id, DRM_MODE_OBJECT_BLOB); 3577 blob = drm_property_blob_find(dev, out_resp->blob_id);
3605 if (!obj) { 3578 if (!blob) {
3606 ret = -ENOENT; 3579 ret = -ENOENT;
3607 goto done; 3580 goto done;
3608 } 3581 }
3609 blob = obj_to_blob(obj);
3610 3582
3611 if (out_resp->length == blob->length) { 3583 if (out_resp->length == blob->length) {
3612 blob_ptr = (void __user *)(unsigned long)out_resp->data; 3584 blob_ptr = (void __user *)(unsigned long)out_resp->data;
@@ -3988,7 +3960,6 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
3988 void *data, struct drm_file *file_priv) 3960 void *data, struct drm_file *file_priv)
3989{ 3961{
3990 struct drm_mode_crtc_lut *crtc_lut = data; 3962 struct drm_mode_crtc_lut *crtc_lut = data;
3991 struct drm_mode_object *obj;
3992 struct drm_crtc *crtc; 3963 struct drm_crtc *crtc;
3993 void *r_base, *g_base, *b_base; 3964 void *r_base, *g_base, *b_base;
3994 int size; 3965 int size;
@@ -3998,12 +3969,11 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
3998 return -EINVAL; 3969 return -EINVAL;
3999 3970
4000 drm_modeset_lock_all(dev); 3971 drm_modeset_lock_all(dev);
4001 obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); 3972 crtc = drm_crtc_find(dev, crtc_lut->crtc_id);
4002 if (!obj) { 3973 if (!crtc) {
4003 ret = -ENOENT; 3974 ret = -ENOENT;
4004 goto out; 3975 goto out;
4005 } 3976 }
4006 crtc = obj_to_crtc(obj);
4007 3977
4008 if (crtc->funcs->gamma_set == NULL) { 3978 if (crtc->funcs->gamma_set == NULL) {
4009 ret = -ENOSYS; 3979 ret = -ENOSYS;
@@ -4062,7 +4032,6 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
4062 void *data, struct drm_file *file_priv) 4032 void *data, struct drm_file *file_priv)
4063{ 4033{
4064 struct drm_mode_crtc_lut *crtc_lut = data; 4034 struct drm_mode_crtc_lut *crtc_lut = data;
4065 struct drm_mode_object *obj;
4066 struct drm_crtc *crtc; 4035 struct drm_crtc *crtc;
4067 void *r_base, *g_base, *b_base; 4036 void *r_base, *g_base, *b_base;
4068 int size; 4037 int size;
@@ -4072,12 +4041,11 @@ int drm_mode_gamma_get_ioctl(struct drm_device *dev,
4072 return -EINVAL; 4041 return -EINVAL;
4073 4042
4074 drm_modeset_lock_all(dev); 4043 drm_modeset_lock_all(dev);
4075 obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); 4044 crtc = drm_crtc_find(dev, crtc_lut->crtc_id);
4076 if (!obj) { 4045 if (!crtc) {
4077 ret = -ENOENT; 4046 ret = -ENOENT;
4078 goto out; 4047 goto out;
4079 } 4048 }
4080 crtc = obj_to_crtc(obj);
4081 4049
4082 /* memcpy into gamma store */ 4050 /* memcpy into gamma store */
4083 if (crtc_lut->gamma_size != crtc->gamma_size) { 4051 if (crtc_lut->gamma_size != crtc->gamma_size) {
@@ -4130,7 +4098,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
4130 void *data, struct drm_file *file_priv) 4098 void *data, struct drm_file *file_priv)
4131{ 4099{
4132 struct drm_mode_crtc_page_flip *page_flip = data; 4100 struct drm_mode_crtc_page_flip *page_flip = data;
4133 struct drm_mode_object *obj;
4134 struct drm_crtc *crtc; 4101 struct drm_crtc *crtc;
4135 struct drm_framebuffer *fb = NULL, *old_fb = NULL; 4102 struct drm_framebuffer *fb = NULL, *old_fb = NULL;
4136 struct drm_pending_vblank_event *e = NULL; 4103 struct drm_pending_vblank_event *e = NULL;
@@ -4144,10 +4111,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
4144 if ((page_flip->flags & DRM_MODE_PAGE_FLIP_ASYNC) && !dev->mode_config.async_page_flip) 4111 if ((page_flip->flags & DRM_MODE_PAGE_FLIP_ASYNC) && !dev->mode_config.async_page_flip)
4145 return -EINVAL; 4112 return -EINVAL;
4146 4113
4147 obj = drm_mode_object_find(dev, page_flip->crtc_id, DRM_MODE_OBJECT_CRTC); 4114 crtc = drm_crtc_find(dev, page_flip->crtc_id);
4148 if (!obj) 4115 if (!crtc)
4149 return -ENOENT; 4116 return -ENOENT;
4150 crtc = obj_to_crtc(obj);
4151 4117
4152 mutex_lock(&crtc->mutex); 4118 mutex_lock(&crtc->mutex);
4153 if (crtc->primary->fb == NULL) { 4119 if (crtc->primary->fb == NULL) {