Rev 1630 | Rev 2004 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1630 | Rev 1963 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | * Eric Anholt |
28 | * Eric Anholt |
29 | * Dave Airlie |
29 | * Dave Airlie |
30 | * Jesse Barnes |
30 | * Jesse Barnes |
31 | */ |
31 | */ |
32 | #include |
32 | #include |
- | 33 | #include |
|
33 | #include "drm.h" |
34 | #include "drm.h" |
34 | #include "drmP.h" |
35 | #include "drmP.h" |
35 | #include "drm_crtc.h" |
36 | #include "drm_crtc.h" |
- | 37 | #include "drm_edid.h" |
|
Line 36... | Line 38... | ||
36 | 38 | ||
37 | struct drm_prop_enum_list { |
39 | struct drm_prop_enum_list { |
38 | int type; |
40 | int type; |
39 | char *name; |
41 | char *name; |
Line 76... | Line 78... | ||
76 | 78 | ||
77 | static struct drm_prop_enum_list drm_dithering_mode_enum_list[] = |
79 | static struct drm_prop_enum_list drm_dithering_mode_enum_list[] = |
78 | { |
80 | { |
79 | { DRM_MODE_DITHERING_OFF, "Off" }, |
81 | { DRM_MODE_DITHERING_OFF, "Off" }, |
- | 82 | { DRM_MODE_DITHERING_ON, "On" }, |
|
80 | { DRM_MODE_DITHERING_ON, "On" }, |
83 | { DRM_MODE_DITHERING_AUTO, "Automatic" }, |
Line 81... | Line 84... | ||
81 | }; |
84 | }; |
82 | 85 | ||
83 | /* |
86 | /* |
Line 151... | Line 154... | ||
151 | { DRM_MODE_CONNECTOR_DVIA, "DVI-A", 0 }, |
154 | { DRM_MODE_CONNECTOR_DVIA, "DVI-A", 0 }, |
152 | { DRM_MODE_CONNECTOR_Composite, "Composite", 0 }, |
155 | { DRM_MODE_CONNECTOR_Composite, "Composite", 0 }, |
153 | { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO", 0 }, |
156 | { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO", 0 }, |
154 | { DRM_MODE_CONNECTOR_LVDS, "LVDS", 0 }, |
157 | { DRM_MODE_CONNECTOR_LVDS, "LVDS", 0 }, |
155 | { DRM_MODE_CONNECTOR_Component, "Component", 0 }, |
158 | { DRM_MODE_CONNECTOR_Component, "Component", 0 }, |
156 | { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN", 0 }, |
159 | { DRM_MODE_CONNECTOR_9PinDIN, "DIN", 0 }, |
157 | { DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort", 0 }, |
160 | { DRM_MODE_CONNECTOR_DisplayPort, "DP", 0 }, |
158 | { DRM_MODE_CONNECTOR_HDMIA, "HDMI Type A", 0 }, |
161 | { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A", 0 }, |
159 | { DRM_MODE_CONNECTOR_HDMIB, "HDMI Type B", 0 }, |
162 | { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B", 0 }, |
160 | { DRM_MODE_CONNECTOR_TV, "TV", 0 }, |
163 | { DRM_MODE_CONNECTOR_TV, "TV", 0 }, |
161 | { DRM_MODE_CONNECTOR_eDP, "Embedded DisplayPort", 0 }, |
164 | { DRM_MODE_CONNECTOR_eDP, "eDP", 0 }, |
162 | }; |
165 | }; |
Line 163... | Line 166... | ||
163 | 166 | ||
164 | static struct drm_prop_enum_list drm_encoder_enum_list[] = |
167 | static struct drm_prop_enum_list drm_encoder_enum_list[] = |
165 | { { DRM_MODE_ENCODER_NONE, "None" }, |
168 | { { DRM_MODE_ENCODER_NONE, "None" }, |
Line 491... | Line 494... | ||
491 | drm_mode_remove(connector, mode); |
494 | drm_mode_remove(connector, mode); |
Line 492... | Line 495... | ||
492 | 495 | ||
493 | list_for_each_entry_safe(mode, t, &connector->user_modes, head) |
496 | list_for_each_entry_safe(mode, t, &connector->user_modes, head) |
Line 494... | Line -... | ||
494 | drm_mode_remove(connector, mode); |
- | |
495 | 497 | drm_mode_remove(connector, mode); |
|
496 | kfree(connector->fb_helper_private); |
498 | |
497 | mutex_lock(&dev->mode_config.mutex); |
499 | mutex_lock(&dev->mode_config.mutex); |
498 | drm_mode_object_put(dev, &connector->base); |
500 | drm_mode_object_put(dev, &connector->base); |
499 | list_del(&connector->head); |
501 | list_del(&connector->head); |
Line 855... | Line 857... | ||
855 | void drm_mode_config_init(struct drm_device *dev) |
857 | void drm_mode_config_init(struct drm_device *dev) |
856 | { |
858 | { |
857 | mutex_init(&dev->mode_config.mutex); |
859 | mutex_init(&dev->mode_config.mutex); |
858 | mutex_init(&dev->mode_config.idr_mutex); |
860 | mutex_init(&dev->mode_config.idr_mutex); |
859 | INIT_LIST_HEAD(&dev->mode_config.fb_list); |
861 | INIT_LIST_HEAD(&dev->mode_config.fb_list); |
860 | INIT_LIST_HEAD(&dev->mode_config.fb_kernel_list); |
- | |
861 | INIT_LIST_HEAD(&dev->mode_config.crtc_list); |
862 | INIT_LIST_HEAD(&dev->mode_config.crtc_list); |
862 | INIT_LIST_HEAD(&dev->mode_config.connector_list); |
863 | INIT_LIST_HEAD(&dev->mode_config.connector_list); |
863 | INIT_LIST_HEAD(&dev->mode_config.encoder_list); |
864 | INIT_LIST_HEAD(&dev->mode_config.encoder_list); |
864 | INIT_LIST_HEAD(&dev->mode_config.property_list); |
865 | INIT_LIST_HEAD(&dev->mode_config.property_list); |
865 | INIT_LIST_HEAD(&dev->mode_config.property_blob_list); |
866 | INIT_LIST_HEAD(&dev->mode_config.property_blob_list); |
Line 1072... | Line 1073... | ||
1072 | uint32_t __user *crtc_id; |
1073 | uint32_t __user *crtc_id; |
1073 | uint32_t __user *connector_id; |
1074 | uint32_t __user *connector_id; |
1074 | uint32_t __user *encoder_id; |
1075 | uint32_t __user *encoder_id; |
1075 | struct drm_mode_group *mode_group; |
1076 | struct drm_mode_group *mode_group; |
Line -... | Line 1077... | ||
- | 1077 | ||
- | 1078 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1079 | return -EINVAL; |
|
1076 | 1080 | ||
Line 1077... | Line 1081... | ||
1077 | mutex_lock(&dev->mode_config.mutex); |
1081 | mutex_lock(&dev->mode_config.mutex); |
1078 | 1082 | ||
1079 | /* |
1083 | /* |
Line 1109... | Line 1113... | ||
1109 | /* handle this in 4 parts */ |
1113 | /* handle this in 4 parts */ |
1110 | /* FBs */ |
1114 | /* FBs */ |
1111 | if (card_res->count_fbs >= fb_count) { |
1115 | if (card_res->count_fbs >= fb_count) { |
1112 | copied = 0; |
1116 | copied = 0; |
1113 | fb_id = (uint32_t __user *)(unsigned long)card_res->fb_id_ptr; |
1117 | fb_id = (uint32_t __user *)(unsigned long)card_res->fb_id_ptr; |
1114 | list_for_each_entry(fb, &file_priv->fbs, head) { |
1118 | list_for_each_entry(fb, &file_priv->fbs, filp_head) { |
1115 | if (put_user(fb->base.id, fb_id + copied)) { |
1119 | if (put_user(fb->base.id, fb_id + copied)) { |
1116 | ret = -EFAULT; |
1120 | ret = -EFAULT; |
1117 | goto out; |
1121 | goto out; |
1118 | } |
1122 | } |
1119 | copied++; |
1123 | copied++; |
Line 1126... | Line 1130... | ||
1126 | copied = 0; |
1130 | copied = 0; |
1127 | crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr; |
1131 | crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr; |
1128 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1132 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1129 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, |
1133 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, |
1130 | head) { |
1134 | head) { |
1131 | DRM_DEBUG_KMS("CRTC ID is %d\n", crtc->base.id); |
1135 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
1132 | if (put_user(crtc->base.id, crtc_id + copied)) { |
1136 | if (put_user(crtc->base.id, crtc_id + copied)) { |
1133 | ret = -EFAULT; |
1137 | ret = -EFAULT; |
1134 | goto out; |
1138 | goto out; |
1135 | } |
1139 | } |
1136 | copied++; |
1140 | copied++; |
Line 1154... | Line 1158... | ||
1154 | encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr; |
1158 | encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr; |
1155 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1159 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1156 | list_for_each_entry(encoder, |
1160 | list_for_each_entry(encoder, |
1157 | &dev->mode_config.encoder_list, |
1161 | &dev->mode_config.encoder_list, |
1158 | head) { |
1162 | head) { |
1159 | DRM_DEBUG_KMS("ENCODER ID is %d\n", |
1163 | DRM_DEBUG_KMS("[ENCODER:%d:%s]\n", encoder->base.id, |
1160 | encoder->base.id); |
1164 | drm_get_encoder_name(encoder)); |
1161 | if (put_user(encoder->base.id, encoder_id + |
1165 | if (put_user(encoder->base.id, encoder_id + |
1162 | copied)) { |
1166 | copied)) { |
1163 | ret = -EFAULT; |
1167 | ret = -EFAULT; |
1164 | goto out; |
1168 | goto out; |
1165 | } |
1169 | } |
Line 1185... | Line 1189... | ||
1185 | connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr; |
1189 | connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr; |
1186 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1190 | if (file_priv->master->minor->type == DRM_MINOR_CONTROL) { |
1187 | list_for_each_entry(connector, |
1191 | list_for_each_entry(connector, |
1188 | &dev->mode_config.connector_list, |
1192 | &dev->mode_config.connector_list, |
1189 | head) { |
1193 | head) { |
1190 | DRM_DEBUG_KMS("CONNECTOR ID is %d\n", |
1194 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
1191 | connector->base.id); |
1195 | connector->base.id, |
- | 1196 | drm_get_connector_name(connector)); |
|
1192 | if (put_user(connector->base.id, |
1197 | if (put_user(connector->base.id, |
1193 | connector_id + copied)) { |
1198 | connector_id + copied)) { |
1194 | ret = -EFAULT; |
1199 | ret = -EFAULT; |
1195 | goto out; |
1200 | goto out; |
1196 | } |
1201 | } |
Line 1209... | Line 1214... | ||
1209 | } |
1214 | } |
1210 | } |
1215 | } |
1211 | } |
1216 | } |
1212 | card_res->count_connectors = connector_count; |
1217 | card_res->count_connectors = connector_count; |
Line 1213... | Line 1218... | ||
1213 | 1218 | ||
1214 | DRM_DEBUG_KMS("Counted %d %d %d\n", card_res->count_crtcs, |
1219 | DRM_DEBUG_KMS("CRTC[%d] CONNECTORS[%d] ENCODERS[%d]\n", card_res->count_crtcs, |
Line 1215... | Line 1220... | ||
1215 | card_res->count_connectors, card_res->count_encoders); |
1220 | card_res->count_connectors, card_res->count_encoders); |
1216 | 1221 | ||
1217 | out: |
1222 | out: |
Line 1242... | Line 1247... | ||
1242 | struct drm_mode_crtc *crtc_resp = data; |
1247 | struct drm_mode_crtc *crtc_resp = data; |
1243 | struct drm_crtc *crtc; |
1248 | struct drm_crtc *crtc; |
1244 | struct drm_mode_object *obj; |
1249 | struct drm_mode_object *obj; |
1245 | int ret = 0; |
1250 | int ret = 0; |
Line -... | Line 1251... | ||
- | 1251 | ||
- | 1252 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1253 | return -EINVAL; |
|
1246 | 1254 | ||
Line 1247... | Line 1255... | ||
1247 | mutex_lock(&dev->mode_config.mutex); |
1255 | mutex_lock(&dev->mode_config.mutex); |
1248 | 1256 | ||
1249 | obj = drm_mode_object_find(dev, crtc_resp->crtc_id, |
1257 | obj = drm_mode_object_find(dev, crtc_resp->crtc_id, |
Line 1310... | Line 1318... | ||
1310 | struct drm_mode_modeinfo __user *mode_ptr; |
1318 | struct drm_mode_modeinfo __user *mode_ptr; |
1311 | uint32_t __user *prop_ptr; |
1319 | uint32_t __user *prop_ptr; |
1312 | uint64_t __user *prop_values; |
1320 | uint64_t __user *prop_values; |
1313 | uint32_t __user *encoder_ptr; |
1321 | uint32_t __user *encoder_ptr; |
Line -... | Line 1322... | ||
- | 1322 | ||
- | 1323 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1324 | return -EINVAL; |
|
1314 | 1325 | ||
Line 1315... | Line 1326... | ||
1315 | memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); |
1326 | memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); |
Line 1316... | Line 1327... | ||
1316 | 1327 | ||
Line 1317... | Line 1328... | ||
1317 | DRM_DEBUG_KMS("connector id %d:\n", out_resp->connector_id); |
1328 | DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id); |
1318 | 1329 | ||
Line 1429... | Line 1440... | ||
1429 | struct drm_mode_get_encoder *enc_resp = data; |
1440 | struct drm_mode_get_encoder *enc_resp = data; |
1430 | struct drm_mode_object *obj; |
1441 | struct drm_mode_object *obj; |
1431 | struct drm_encoder *encoder; |
1442 | struct drm_encoder *encoder; |
1432 | int ret = 0; |
1443 | int ret = 0; |
Line -... | Line 1444... | ||
- | 1444 | ||
- | 1445 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1446 | return -EINVAL; |
|
1433 | 1447 | ||
1434 | mutex_lock(&dev->mode_config.mutex); |
1448 | mutex_lock(&dev->mode_config.mutex); |
1435 | obj = drm_mode_object_find(dev, enc_resp->encoder_id, |
1449 | obj = drm_mode_object_find(dev, enc_resp->encoder_id, |
1436 | DRM_MODE_OBJECT_ENCODER); |
1450 | DRM_MODE_OBJECT_ENCODER); |
1437 | if (!obj) { |
1451 | if (!obj) { |
Line 1484... | Line 1498... | ||
1484 | struct drm_mode_set set; |
1498 | struct drm_mode_set set; |
1485 | uint32_t __user *set_connectors_ptr; |
1499 | uint32_t __user *set_connectors_ptr; |
1486 | int ret = 0; |
1500 | int ret = 0; |
1487 | int i; |
1501 | int i; |
Line -... | Line 1502... | ||
- | 1502 | ||
- | 1503 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1504 | return -EINVAL; |
|
1488 | 1505 | ||
1489 | mutex_lock(&dev->mode_config.mutex); |
1506 | mutex_lock(&dev->mode_config.mutex); |
1490 | obj = drm_mode_object_find(dev, crtc_req->crtc_id, |
1507 | obj = drm_mode_object_find(dev, crtc_req->crtc_id, |
1491 | DRM_MODE_OBJECT_CRTC); |
1508 | DRM_MODE_OBJECT_CRTC); |
1492 | if (!obj) { |
1509 | if (!obj) { |
1493 | DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id); |
1510 | DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id); |
1494 | ret = -EINVAL; |
1511 | ret = -EINVAL; |
1495 | goto out; |
1512 | goto out; |
1496 | } |
1513 | } |
- | 1514 | crtc = obj_to_crtc(obj); |
|
Line 1497... | Line 1515... | ||
1497 | crtc = obj_to_crtc(obj); |
1515 | DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id); |
1498 | 1516 | ||
1499 | if (crtc_req->mode_valid) { |
1517 | if (crtc_req->mode_valid) { |
1500 | /* If we have a mode we need a framebuffer. */ |
1518 | /* If we have a mode we need a framebuffer. */ |
Line 1569... | Line 1587... | ||
1569 | out_id); |
1587 | out_id); |
1570 | ret = -EINVAL; |
1588 | ret = -EINVAL; |
1571 | goto out; |
1589 | goto out; |
1572 | } |
1590 | } |
1573 | connector = obj_to_connector(obj); |
1591 | connector = obj_to_connector(obj); |
- | 1592 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", |
|
- | 1593 | connector->base.id, |
|
- | 1594 | drm_get_connector_name(connector)); |
|
Line 1574... | Line 1595... | ||
1574 | 1595 | ||
1575 | connector_set[i] = connector; |
1596 | connector_set[i] = connector; |
1576 | } |
1597 | } |
Line 1597... | Line 1618... | ||
1597 | struct drm_mode_cursor *req = data; |
1618 | struct drm_mode_cursor *req = data; |
1598 | struct drm_mode_object *obj; |
1619 | struct drm_mode_object *obj; |
1599 | struct drm_crtc *crtc; |
1620 | struct drm_crtc *crtc; |
1600 | int ret = 0; |
1621 | int ret = 0; |
Line -... | Line 1622... | ||
- | 1622 | ||
- | 1623 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1624 | return -EINVAL; |
|
1601 | 1625 | ||
1602 | if (!req->flags) { |
1626 | if (!req->flags) { |
1603 | DRM_ERROR("no operation set\n"); |
1627 | DRM_ERROR("no operation set\n"); |
1604 | return -EINVAL; |
1628 | return -EINVAL; |
Line 1661... | Line 1685... | ||
1661 | struct drm_mode_fb_cmd *r = data; |
1685 | struct drm_mode_fb_cmd *r = data; |
1662 | struct drm_mode_config *config = &dev->mode_config; |
1686 | struct drm_mode_config *config = &dev->mode_config; |
1663 | struct drm_framebuffer *fb; |
1687 | struct drm_framebuffer *fb; |
1664 | int ret = 0; |
1688 | int ret = 0; |
Line -... | Line 1689... | ||
- | 1689 | ||
- | 1690 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1691 | return -EINVAL; |
|
1665 | 1692 | ||
1666 | if ((config->min_width > r->width) || (r->width > config->max_width)) { |
1693 | if ((config->min_width > r->width) || (r->width > config->max_width)) { |
1667 | DRM_ERROR("mode new framebuffer width not within limits\n"); |
1694 | DRM_ERROR("mode new framebuffer width not within limits\n"); |
1668 | return -EINVAL; |
1695 | return -EINVAL; |
1669 | } |
1696 | } |
Line 1672... | Line 1699... | ||
1672 | return -EINVAL; |
1699 | return -EINVAL; |
1673 | } |
1700 | } |
Line 1674... | Line 1701... | ||
1674 | 1701 | ||
Line 1675... | Line 1702... | ||
1675 | mutex_lock(&dev->mode_config.mutex); |
1702 | mutex_lock(&dev->mode_config.mutex); |
1676 | 1703 | ||
Line 1677... | Line 1704... | ||
1677 | /* TODO check buffer is sufficently large */ |
1704 | /* TODO check buffer is sufficiently large */ |
1678 | /* TODO setup destructor callback */ |
1705 | /* TODO setup destructor callback */ |
1679 | 1706 | ||
1680 | fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); |
1707 | fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); |
1681 | if (!fb) { |
1708 | if (IS_ERR(fb)) { |
1682 | DRM_ERROR("could not create framebuffer\n"); |
1709 | DRM_ERROR("could not create framebuffer\n"); |
Line 1683... | Line 1710... | ||
1683 | ret = -EINVAL; |
1710 | ret = PTR_ERR(fb); |
1684 | goto out; |
1711 | goto out; |
- | 1712 | } |
|
Line 1685... | Line 1713... | ||
1685 | } |
1713 | |
1686 | 1714 | r->fb_id = fb->base.id; |
|
1687 | r->fb_id = fb->base.id; |
1715 | list_add(&fb->filp_head, &file_priv->fbs); |
1688 | list_add(&fb->filp_head, &file_priv->fbs); |
1716 | DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id); |
Line 1717... | Line 1745... | ||
1717 | struct drm_framebuffer *fbl = NULL; |
1745 | struct drm_framebuffer *fbl = NULL; |
1718 | uint32_t *id = data; |
1746 | uint32_t *id = data; |
1719 | int ret = 0; |
1747 | int ret = 0; |
1720 | int found = 0; |
1748 | int found = 0; |
Line -... | Line 1749... | ||
- | 1749 | ||
- | 1750 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1751 | return -EINVAL; |
|
1721 | 1752 | ||
1722 | mutex_lock(&dev->mode_config.mutex); |
1753 | mutex_lock(&dev->mode_config.mutex); |
1723 | obj = drm_mode_object_find(dev, *id, DRM_MODE_OBJECT_FB); |
1754 | obj = drm_mode_object_find(dev, *id, DRM_MODE_OBJECT_FB); |
1724 | /* TODO check that we realy get a framebuffer back. */ |
1755 | /* TODO check that we really get a framebuffer back. */ |
1725 | if (!obj) { |
1756 | if (!obj) { |
1726 | DRM_ERROR("mode invalid framebuffer id\n"); |
1757 | DRM_ERROR("mode invalid framebuffer id\n"); |
1727 | ret = -EINVAL; |
1758 | ret = -EINVAL; |
1728 | goto out; |
1759 | goto out; |
Line 1773... | Line 1804... | ||
1773 | struct drm_mode_fb_cmd *r = data; |
1804 | struct drm_mode_fb_cmd *r = data; |
1774 | struct drm_mode_object *obj; |
1805 | struct drm_mode_object *obj; |
1775 | struct drm_framebuffer *fb; |
1806 | struct drm_framebuffer *fb; |
1776 | int ret = 0; |
1807 | int ret = 0; |
Line -... | Line 1808... | ||
- | 1808 | ||
- | 1809 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1810 | return -EINVAL; |
|
1777 | 1811 | ||
1778 | mutex_lock(&dev->mode_config.mutex); |
1812 | mutex_lock(&dev->mode_config.mutex); |
1779 | obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); |
1813 | obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); |
1780 | if (!obj) { |
1814 | if (!obj) { |
1781 | DRM_ERROR("invalid framebuffer id\n"); |
1815 | DRM_ERROR("invalid framebuffer id\n"); |
Line 1806... | Line 1840... | ||
1806 | struct drm_framebuffer *fb; |
1840 | struct drm_framebuffer *fb; |
1807 | unsigned flags; |
1841 | unsigned flags; |
1808 | int num_clips; |
1842 | int num_clips; |
1809 | int ret = 0; |
1843 | int ret = 0; |
Line -... | Line 1844... | ||
- | 1844 | ||
- | 1845 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 1846 | return -EINVAL; |
|
1810 | 1847 | ||
1811 | mutex_lock(&dev->mode_config.mutex); |
1848 | mutex_lock(&dev->mode_config.mutex); |
1812 | obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); |
1849 | obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB); |
1813 | if (!obj) { |
1850 | if (!obj) { |
1814 | DRM_ERROR("invalid framebuffer id\n"); |
1851 | DRM_ERROR("invalid framebuffer id\n"); |
Line 1840... | Line 1877... | ||
1840 | goto out_err1; |
1877 | goto out_err1; |
1841 | } |
1878 | } |
Line 1842... | Line 1879... | ||
1842 | 1879 | ||
1843 | ret = copy_from_user(clips, clips_ptr, |
1880 | ret = copy_from_user(clips, clips_ptr, |
1844 | num_clips * sizeof(*clips)); |
1881 | num_clips * sizeof(*clips)); |
- | 1882 | if (ret) { |
|
1845 | if (ret) |
1883 | ret = -EFAULT; |
1846 | goto out_err2; |
1884 | goto out_err2; |
- | 1885 | } |
|
Line 1847... | Line 1886... | ||
1847 | } |
1886 | } |
1848 | 1887 | ||
- | 1888 | if (fb->funcs->dirty) { |
|
1849 | if (fb->funcs->dirty) { |
1889 | ret = fb->funcs->dirty(fb, file_priv, flags, r->color, |
1850 | ret = fb->funcs->dirty(fb, flags, r->color, clips, num_clips); |
1890 | clips, num_clips); |
1851 | } else { |
1891 | } else { |
1852 | ret = -ENOSYS; |
1892 | ret = -ENOSYS; |
Line 1989... | Line 2029... | ||
1989 | struct drm_display_mode *mode; |
2029 | struct drm_display_mode *mode; |
1990 | struct drm_mode_object *obj; |
2030 | struct drm_mode_object *obj; |
1991 | struct drm_mode_modeinfo *umode = &mode_cmd->mode; |
2031 | struct drm_mode_modeinfo *umode = &mode_cmd->mode; |
1992 | int ret = 0; |
2032 | int ret = 0; |
Line -... | Line 2033... | ||
- | 2033 | ||
- | 2034 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2035 | return -EINVAL; |
|
1993 | 2036 | ||
Line 1994... | Line 2037... | ||
1994 | mutex_lock(&dev->mode_config.mutex); |
2037 | mutex_lock(&dev->mode_config.mutex); |
1995 | 2038 | ||
1996 | obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR); |
2039 | obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR); |
Line 2035... | Line 2078... | ||
2035 | struct drm_connector *connector; |
2078 | struct drm_connector *connector; |
2036 | struct drm_display_mode mode; |
2079 | struct drm_display_mode mode; |
2037 | struct drm_mode_modeinfo *umode = &mode_cmd->mode; |
2080 | struct drm_mode_modeinfo *umode = &mode_cmd->mode; |
2038 | int ret = 0; |
2081 | int ret = 0; |
Line -... | Line 2082... | ||
- | 2082 | ||
- | 2083 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2084 | return -EINVAL; |
|
2039 | 2085 | ||
Line 2040... | Line 2086... | ||
2040 | mutex_lock(&dev->mode_config.mutex); |
2086 | mutex_lock(&dev->mode_config.mutex); |
2041 | 2087 | ||
2042 | obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR); |
2088 | obj = drm_mode_object_find(dev, mode_cmd->connector_id, DRM_MODE_OBJECT_CONNECTOR); |
Line 2206... | Line 2252... | ||
2206 | struct drm_property_blob *prop_blob; |
2252 | struct drm_property_blob *prop_blob; |
2207 | uint32_t *blob_id_ptr; |
2253 | uint32_t *blob_id_ptr; |
2208 | uint64_t __user *values_ptr; |
2254 | uint64_t __user *values_ptr; |
2209 | uint32_t __user *blob_length_ptr; |
2255 | uint32_t __user *blob_length_ptr; |
Line -... | Line 2256... | ||
- | 2256 | ||
- | 2257 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2258 | return -EINVAL; |
|
2210 | 2259 | ||
2211 | mutex_lock(&dev->mode_config.mutex); |
2260 | mutex_lock(&dev->mode_config.mutex); |
2212 | obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); |
2261 | obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); |
2213 | if (!obj) { |
2262 | if (!obj) { |
2214 | ret = -EINVAL; |
2263 | ret = -EINVAL; |
Line 2330... | Line 2379... | ||
2330 | struct drm_mode_get_blob *out_resp = data; |
2379 | struct drm_mode_get_blob *out_resp = data; |
2331 | struct drm_property_blob *blob; |
2380 | struct drm_property_blob *blob; |
2332 | int ret = 0; |
2381 | int ret = 0; |
2333 | void *blob_ptr; |
2382 | void *blob_ptr; |
Line -... | Line 2383... | ||
- | 2383 | ||
- | 2384 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2385 | return -EINVAL; |
|
2334 | 2386 | ||
2335 | mutex_lock(&dev->mode_config.mutex); |
2387 | mutex_lock(&dev->mode_config.mutex); |
2336 | obj = drm_mode_object_find(dev, out_resp->blob_id, DRM_MODE_OBJECT_BLOB); |
2388 | obj = drm_mode_object_find(dev, out_resp->blob_id, DRM_MODE_OBJECT_BLOB); |
2337 | if (!obj) { |
2389 | if (!obj) { |
2338 | ret = -EINVAL; |
2390 | ret = -EINVAL; |
Line 2357... | Line 2409... | ||
2357 | 2409 | ||
2358 | int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
2410 | int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
2359 | struct edid *edid) |
2411 | struct edid *edid) |
2360 | { |
2412 | { |
2361 | struct drm_device *dev = connector->dev; |
2413 | struct drm_device *dev = connector->dev; |
Line 2362... | Line 2414... | ||
2362 | int ret = 0; |
2414 | int ret = 0, size; |
2363 | 2415 | ||
Line 2364... | Line 2416... | ||
2364 | if (connector->edid_blob_ptr) |
2416 | if (connector->edid_blob_ptr) |
Line 2369... | Line 2421... | ||
2369 | connector->edid_blob_ptr = NULL; |
2421 | connector->edid_blob_ptr = NULL; |
2370 | ret = drm_connector_property_set_value(connector, dev->mode_config.edid_property, 0); |
2422 | ret = drm_connector_property_set_value(connector, dev->mode_config.edid_property, 0); |
2371 | return ret; |
2423 | return ret; |
2372 | } |
2424 | } |
Line -... | Line 2425... | ||
- | 2425 | ||
2373 | 2426 | size = EDID_LENGTH * (1 + edid->extensions); |
|
- | 2427 | connector->edid_blob_ptr = drm_property_create_blob(connector->dev, |
|
Line 2374... | Line 2428... | ||
2374 | connector->edid_blob_ptr = drm_property_create_blob(connector->dev, 128, edid); |
2428 | size, edid); |
2375 | 2429 | ||
2376 | ret = drm_connector_property_set_value(connector, |
2430 | ret = drm_connector_property_set_value(connector, |
Line 2390... | Line 2444... | ||
2390 | struct drm_property *property; |
2444 | struct drm_property *property; |
2391 | struct drm_connector *connector; |
2445 | struct drm_connector *connector; |
2392 | int ret = -EINVAL; |
2446 | int ret = -EINVAL; |
2393 | int i; |
2447 | int i; |
Line -... | Line 2448... | ||
- | 2448 | ||
- | 2449 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2450 | return -EINVAL; |
|
2394 | 2451 | ||
Line 2395... | Line 2452... | ||
2395 | mutex_lock(&dev->mode_config.mutex); |
2452 | mutex_lock(&dev->mode_config.mutex); |
2396 | 2453 | ||
2397 | obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR); |
2454 | obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR); |
Line 2508... | Line 2565... | ||
2508 | struct drm_crtc *crtc; |
2565 | struct drm_crtc *crtc; |
2509 | void *r_base, *g_base, *b_base; |
2566 | void *r_base, *g_base, *b_base; |
2510 | int size; |
2567 | int size; |
2511 | int ret = 0; |
2568 | int ret = 0; |
Line -... | Line 2569... | ||
- | 2569 | ||
- | 2570 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2571 | return -EINVAL; |
|
2512 | 2572 | ||
2513 | mutex_lock(&dev->mode_config.mutex); |
2573 | mutex_lock(&dev->mode_config.mutex); |
2514 | obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); |
2574 | obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); |
2515 | if (!obj) { |
2575 | if (!obj) { |
2516 | ret = -EINVAL; |
2576 | ret = -EINVAL; |
Line 2541... | Line 2601... | ||
2541 | if (copy_from_user(b_base, (void __user *)(unsigned long)crtc_lut->blue, size)) { |
2601 | if (copy_from_user(b_base, (void __user *)(unsigned long)crtc_lut->blue, size)) { |
2542 | ret = -EFAULT; |
2602 | ret = -EFAULT; |
2543 | goto out; |
2603 | goto out; |
2544 | } |
2604 | } |
Line 2545... | Line 2605... | ||
2545 | 2605 | ||
Line 2546... | Line 2606... | ||
2546 | crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size); |
2606 | crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size); |
2547 | 2607 | ||
2548 | out: |
2608 | out: |
Line 2559... | Line 2619... | ||
2559 | struct drm_crtc *crtc; |
2619 | struct drm_crtc *crtc; |
2560 | void *r_base, *g_base, *b_base; |
2620 | void *r_base, *g_base, *b_base; |
2561 | int size; |
2621 | int size; |
2562 | int ret = 0; |
2622 | int ret = 0; |
Line -... | Line 2623... | ||
- | 2623 | ||
- | 2624 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
|
- | 2625 | return -EINVAL; |
|
2563 | 2626 | ||
2564 | mutex_lock(&dev->mode_config.mutex); |
2627 | mutex_lock(&dev->mode_config.mutex); |
2565 | obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); |
2628 | obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC); |
2566 | if (!obj) { |
2629 | if (!obj) { |
2567 | ret = -EINVAL; |
2630 | ret = -EINVAL; |
Line 2599... | Line 2662... | ||
2599 | } |
2662 | } |
Line 2600... | Line 2663... | ||
2600 | 2663 | ||
Line -... | Line 2664... | ||
- | 2664 | #endif |
|
- | 2665 | ||
- | 2666 | ||
- | 2667 | void drm_mode_config_reset(struct drm_device *dev) |
|
- | 2668 | { |
|
- | 2669 | struct drm_crtc *crtc; |
|
- | 2670 | struct drm_encoder *encoder; |
|
- | 2671 | struct drm_connector *connector; |
|
- | 2672 | ||
- | 2673 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) |
|
- | 2674 | if (crtc->funcs->reset) |
|
- | 2675 | crtc->funcs->reset(crtc); |
|
- | 2676 | ||
- | 2677 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) |
|
- | 2678 | if (encoder->funcs->reset) |
|
- | 2679 | encoder->funcs->reset(encoder); |
|
- | 2680 | ||
- | 2681 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) |
|
- | 2682 | if (connector->funcs->reset) |