aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-01-08 18:13:41 -0500
committerDave Airlie <airlied@redhat.com>2015-01-08 18:13:41 -0500
commite5202a2289d746a94703ad937157d398fb2607cf (patch)
treeb0b8869adfa0e4c0dc05f7a11588e5e21a580755
parentb1940cd21c0f4abdce101253e860feff547291b0 (diff)
parent7552e7dd9527c41f891c87854418896eaf309c20 (diff)
Merge tag 'topic/core-stuff-2014-12-19' of git://anongit.freedesktop.org/drm-intel into drm-next
Misc drm patches with mostly polish patches from Thierry, with a bit of generic mode validation from Ville and a few other oddball things. * tag 'topic/core-stuff-2014-12-19' of git://anongit.freedesktop.org/drm-intel: (25 commits) drm: Include drm_crtc_helper.h in DocBook drm: Make drm_crtc_helper.h standalone includible drm: Move IRQ related fields to proper section drm: Remove stale comment drm: Do basic sanity checks for user modes drm: Perform basic sanity checks on probed modes drm: Reorganize probed mode validation drm/doc: Remove duplicate "by" drm/info: Remove unused code drm/cache: Use wbinvd helpers drm/plane-helper: Test for plane disable earlier drm/doc: Document drm_add_modes_noedid() usage drm: bit of spell-check / editorializing. drm: Prefer sizeof(type) over sizeof type drm: Remove useless else block drm: Remove unneeded braces for single statement blocks drm: Do not assign in if condition drm: Prefer kmalloc_array() over kmalloc() with multiply drm: Prefer kcalloc() over kzalloc() with multiply drm: Miscellaneous checkpatch whitespace cleanups ...
-rw-r--r--Documentation/DocBook/drm.tmpl3
-rw-r--r--drivers/gpu/drm/armada/armada_crtc.c5
-rw-r--r--drivers/gpu/drm/bochs/bochs_kms.c5
-rw-r--r--drivers/gpu/drm/drm_cache.c13
-rw-r--r--drivers/gpu/drm/drm_crtc.c103
-rw-r--r--drivers/gpu/drm/drm_info.c24
-rw-r--r--drivers/gpu/drm/drm_internal.h1
-rw-r--r--drivers/gpu/drm/drm_irq.c11
-rw-r--r--drivers/gpu/drm/drm_modes.c56
-rw-r--r--drivers/gpu/drm/drm_plane_helper.c16
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c43
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c5
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c5
-rw-r--r--drivers/gpu/drm/sti/sti_drm_crtc.c6
-rw-r--r--drivers/gpu/drm/tegra/dc.c5
-rw-r--r--include/drm/drmP.h4
-rw-r--r--include/drm/drm_crtc.h2
-rw-r--r--include/drm/drm_crtc_helper.h32
-rw-r--r--include/drm/drm_modes.h6
-rw-r--r--include/uapi/drm/drm_mode.h8
20 files changed, 179 insertions, 174 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 4b592ffbafee..8a0b2a84f4bf 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -1377,7 +1377,7 @@ int max_width, max_height;</synopsis>
1377 <itemizedlist> 1377 <itemizedlist>
1378 <listitem> 1378 <listitem>
1379 DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. Primary 1379 DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. Primary
1380 planes are the planes operated upon by by CRTC modesetting and flipping 1380 planes are the planes operated upon by CRTC modesetting and flipping
1381 operations described in <xref linkend="drm-kms-crtcops"/>. 1381 operations described in <xref linkend="drm-kms-crtcops"/>.
1382 </listitem> 1382 </listitem>
1383 <listitem> 1383 <listitem>
@@ -2362,6 +2362,7 @@ void intel_crt_init(struct drm_device *dev)
2362 </sect2> 2362 </sect2>
2363 <sect2> 2363 <sect2>
2364 <title>Modeset Helper Functions Reference</title> 2364 <title>Modeset Helper Functions Reference</title>
2365!Iinclude/drm/drm_crtc_helper.h
2365!Edrivers/gpu/drm/drm_crtc_helper.c 2366!Edrivers/gpu/drm/drm_crtc_helper.c
2366!Pdrivers/gpu/drm/drm_crtc_helper.c overview 2367!Pdrivers/gpu/drm/drm_crtc_helper.c overview
2367 </sect2> 2368 </sect2>
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index e3a7a5078e5c..42d2ffa08716 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -653,10 +653,6 @@ static int armada_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
653 return 0; 653 return 0;
654} 654}
655 655
656static void armada_drm_crtc_load_lut(struct drm_crtc *crtc)
657{
658}
659
660/* The mode_config.mutex will be held for this call */ 656/* The mode_config.mutex will be held for this call */
661static void armada_drm_crtc_disable(struct drm_crtc *crtc) 657static void armada_drm_crtc_disable(struct drm_crtc *crtc)
662{ 658{
@@ -678,7 +674,6 @@ static const struct drm_crtc_helper_funcs armada_crtc_helper_funcs = {
678 .mode_fixup = armada_drm_crtc_mode_fixup, 674 .mode_fixup = armada_drm_crtc_mode_fixup,
679 .mode_set = armada_drm_crtc_mode_set, 675 .mode_set = armada_drm_crtc_mode_set,
680 .mode_set_base = armada_drm_crtc_mode_set_base, 676 .mode_set_base = armada_drm_crtc_mode_set_base,
681 .load_lut = armada_drm_crtc_load_lut,
682 .disable = armada_drm_crtc_disable, 677 .disable = armada_drm_crtc_disable,
683}; 678};
684 679
diff --git a/drivers/gpu/drm/bochs/bochs_kms.c b/drivers/gpu/drm/bochs/bochs_kms.c
index 85f0f8cf1fb8..26bcd03a8cb6 100644
--- a/drivers/gpu/drm/bochs/bochs_kms.c
+++ b/drivers/gpu/drm/bochs/bochs_kms.c
@@ -18,10 +18,6 @@ MODULE_PARM_DESC(defy, "default y resolution");
18 18
19/* ---------------------------------------------------------------------- */ 19/* ---------------------------------------------------------------------- */
20 20
21static void bochs_crtc_load_lut(struct drm_crtc *crtc)
22{
23}
24
25static void bochs_crtc_dpms(struct drm_crtc *crtc, int mode) 21static void bochs_crtc_dpms(struct drm_crtc *crtc, int mode)
26{ 22{
27 switch (mode) { 23 switch (mode) {
@@ -144,7 +140,6 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
144 .mode_set_base = bochs_crtc_mode_set_base, 140 .mode_set_base = bochs_crtc_mode_set_base,
145 .prepare = bochs_crtc_prepare, 141 .prepare = bochs_crtc_prepare,
146 .commit = bochs_crtc_commit, 142 .commit = bochs_crtc_commit,
147 .load_lut = bochs_crtc_load_lut,
148}; 143};
149 144
150static void bochs_crtc_init(struct drm_device *dev) 145static void bochs_crtc_init(struct drm_device *dev)
diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index a6b690626a6b..9a62d7a53553 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -32,6 +32,7 @@
32#include <drm/drmP.h> 32#include <drm/drmP.h>
33 33
34#if defined(CONFIG_X86) 34#if defined(CONFIG_X86)
35#include <asm/smp.h>
35 36
36/* 37/*
37 * clflushopt is an unordered instruction which needs fencing with mfence or 38 * clflushopt is an unordered instruction which needs fencing with mfence or
@@ -64,12 +65,6 @@ static void drm_cache_flush_clflush(struct page *pages[],
64 drm_clflush_page(*pages++); 65 drm_clflush_page(*pages++);
65 mb(); 66 mb();
66} 67}
67
68static void
69drm_clflush_ipi_handler(void *null)
70{
71 wbinvd();
72}
73#endif 68#endif
74 69
75void 70void
@@ -82,7 +77,7 @@ drm_clflush_pages(struct page *pages[], unsigned long num_pages)
82 return; 77 return;
83 } 78 }
84 79
85 if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) 80 if (wbinvd_on_all_cpus())
86 printk(KERN_ERR "Timed out waiting for cache flush.\n"); 81 printk(KERN_ERR "Timed out waiting for cache flush.\n");
87 82
88#elif defined(__powerpc__) 83#elif defined(__powerpc__)
@@ -121,7 +116,7 @@ drm_clflush_sg(struct sg_table *st)
121 return; 116 return;
122 } 117 }
123 118
124 if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) 119 if (wbinvd_on_all_cpus())
125 printk(KERN_ERR "Timed out waiting for cache flush.\n"); 120 printk(KERN_ERR "Timed out waiting for cache flush.\n");
126#else 121#else
127 printk(KERN_ERR "Architecture has no drm_cache.c support\n"); 122 printk(KERN_ERR "Architecture has no drm_cache.c support\n");
@@ -144,7 +139,7 @@ drm_clflush_virt_range(void *addr, unsigned long length)
144 return; 139 return;
145 } 140 }
146 141
147 if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0) 142 if (wbinvd_on_all_cpus())
148 printk(KERN_ERR "Timed out waiting for cache flush.\n"); 143 printk(KERN_ERR "Timed out waiting for cache flush.\n");
149#else 144#else
150 printk(KERN_ERR "Architecture has no drm_cache.c support\n"); 145 printk(KERN_ERR "Architecture has no drm_cache.c support\n");
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 5213da499d39..2892d746a1e9 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -61,8 +61,8 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev,
61/* 61/*
62 * Global properties 62 * Global properties
63 */ 63 */
64static const struct drm_prop_enum_list drm_dpms_enum_list[] = 64static const struct drm_prop_enum_list drm_dpms_enum_list[] = {
65{ { DRM_MODE_DPMS_ON, "On" }, 65 { DRM_MODE_DPMS_ON, "On" },
66 { DRM_MODE_DPMS_STANDBY, "Standby" }, 66 { DRM_MODE_DPMS_STANDBY, "Standby" },
67 { DRM_MODE_DPMS_SUSPEND, "Suspend" }, 67 { DRM_MODE_DPMS_SUSPEND, "Suspend" },
68 { DRM_MODE_DPMS_OFF, "Off" } 68 { DRM_MODE_DPMS_OFF, "Off" }
@@ -70,8 +70,7 @@ static const struct drm_prop_enum_list drm_dpms_enum_list[] =
70 70
71DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list) 71DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
72 72
73static const struct drm_prop_enum_list drm_plane_type_enum_list[] = 73static const struct drm_prop_enum_list drm_plane_type_enum_list[] = {
74{
75 { DRM_PLANE_TYPE_OVERLAY, "Overlay" }, 74 { DRM_PLANE_TYPE_OVERLAY, "Overlay" },
76 { DRM_PLANE_TYPE_PRIMARY, "Primary" }, 75 { DRM_PLANE_TYPE_PRIMARY, "Primary" },
77 { DRM_PLANE_TYPE_CURSOR, "Cursor" }, 76 { DRM_PLANE_TYPE_CURSOR, "Cursor" },
@@ -80,8 +79,7 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] =
80/* 79/*
81 * Optional properties 80 * Optional properties
82 */ 81 */
83static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = 82static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = {
84{
85 { DRM_MODE_SCALE_NONE, "None" }, 83 { DRM_MODE_SCALE_NONE, "None" },
86 { DRM_MODE_SCALE_FULLSCREEN, "Full" }, 84 { DRM_MODE_SCALE_FULLSCREEN, "Full" },
87 { DRM_MODE_SCALE_CENTER, "Center" }, 85 { DRM_MODE_SCALE_CENTER, "Center" },
@@ -97,8 +95,7 @@ static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = {
97/* 95/*
98 * Non-global properties, but "required" for certain connectors. 96 * Non-global properties, but "required" for certain connectors.
99 */ 97 */
100static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = 98static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] = {
101{
102 { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ 99 { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
103 { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ 100 { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */
104 { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */ 101 { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */
@@ -106,8 +103,7 @@ static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
106 103
107DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list) 104DRM_ENUM_NAME_FN(drm_get_dvi_i_select_name, drm_dvi_i_select_enum_list)
108 105
109static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = 106static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = {
110{
111 { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */ 107 { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */
112 { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */ 108 { DRM_MODE_SUBCONNECTOR_DVID, "DVI-D" }, /* DVI-I */
113 { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */ 109 { DRM_MODE_SUBCONNECTOR_DVIA, "DVI-A" }, /* DVI-I */
@@ -116,8 +112,7 @@ static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] =
116DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name, 112DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name,
117 drm_dvi_i_subconnector_enum_list) 113 drm_dvi_i_subconnector_enum_list)
118 114
119static const struct drm_prop_enum_list drm_tv_select_enum_list[] = 115static const struct drm_prop_enum_list drm_tv_select_enum_list[] = {
120{
121 { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ 116 { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
122 { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ 117 { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
123 { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */ 118 { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */
@@ -127,8 +122,7 @@ static const struct drm_prop_enum_list drm_tv_select_enum_list[] =
127 122
128DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list) 123DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
129 124
130static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = 125static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
131{
132 { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */ 126 { DRM_MODE_SUBCONNECTOR_Unknown, "Unknown" }, /* DVI-I and TV-out */
133 { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ 127 { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
134 { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */ 128 { DRM_MODE_SUBCONNECTOR_SVIDEO, "SVIDEO" }, /* TV-out */
@@ -154,8 +148,8 @@ struct drm_conn_prop_enum_list {
154/* 148/*
155 * Connector and encoder types. 149 * Connector and encoder types.
156 */ 150 */
157static struct drm_conn_prop_enum_list drm_connector_enum_list[] = 151static struct drm_conn_prop_enum_list drm_connector_enum_list[] = {
158{ { DRM_MODE_CONNECTOR_Unknown, "Unknown" }, 152 { DRM_MODE_CONNECTOR_Unknown, "Unknown" },
159 { DRM_MODE_CONNECTOR_VGA, "VGA" }, 153 { DRM_MODE_CONNECTOR_VGA, "VGA" },
160 { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, 154 { DRM_MODE_CONNECTOR_DVII, "DVI-I" },
161 { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, 155 { DRM_MODE_CONNECTOR_DVID, "DVI-D" },
@@ -174,8 +168,8 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
174 { DRM_MODE_CONNECTOR_DSI, "DSI" }, 168 { DRM_MODE_CONNECTOR_DSI, "DSI" },
175}; 169};
176 170
177static const struct drm_prop_enum_list drm_encoder_enum_list[] = 171static const struct drm_prop_enum_list drm_encoder_enum_list[] = {
178{ { DRM_MODE_ENCODER_NONE, "None" }, 172 { DRM_MODE_ENCODER_NONE, "None" },
179 { DRM_MODE_ENCODER_DAC, "DAC" }, 173 { DRM_MODE_ENCODER_DAC, "DAC" },
180 { DRM_MODE_ENCODER_TMDS, "TMDS" }, 174 { DRM_MODE_ENCODER_TMDS, "TMDS" },
181 { DRM_MODE_ENCODER_LVDS, "LVDS" }, 175 { DRM_MODE_ENCODER_LVDS, "LVDS" },
@@ -185,8 +179,7 @@ static const struct drm_prop_enum_list drm_encoder_enum_list[] =
185 { DRM_MODE_ENCODER_DPMST, "DP MST" }, 179 { DRM_MODE_ENCODER_DPMST, "DP MST" },
186}; 180};
187 181
188static const struct drm_prop_enum_list drm_subpixel_enum_list[] = 182static const struct drm_prop_enum_list drm_subpixel_enum_list[] = {
189{
190 { SubPixelUnknown, "Unknown" }, 183 { SubPixelUnknown, "Unknown" },
191 { SubPixelHorizontalRGB, "Horizontal RGB" }, 184 { SubPixelHorizontalRGB, "Horizontal RGB" },
192 { SubPixelHorizontalBGR, "Horizontal BGR" }, 185 { SubPixelHorizontalBGR, "Horizontal BGR" },
@@ -1142,6 +1135,7 @@ EXPORT_SYMBOL(drm_encoder_init);
1142void drm_encoder_cleanup(struct drm_encoder *encoder) 1135void drm_encoder_cleanup(struct drm_encoder *encoder)
1143{ 1136{
1144 struct drm_device *dev = encoder->dev; 1137 struct drm_device *dev = encoder->dev;
1138
1145 drm_modeset_lock_all(dev); 1139 drm_modeset_lock_all(dev);
1146 drm_mode_object_put(dev, &encoder->base); 1140 drm_mode_object_put(dev, &encoder->base);
1147 kfree(encoder->name); 1141 kfree(encoder->name);
@@ -1185,8 +1179,8 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
1185 plane->base.properties = &plane->properties; 1179 plane->base.properties = &plane->properties;
1186 plane->dev = dev; 1180 plane->dev = dev;
1187 plane->funcs = funcs; 1181 plane->funcs = funcs;
1188 plane->format_types = kmalloc(sizeof(uint32_t) * format_count, 1182 plane->format_types = kmalloc_array(format_count, sizeof(uint32_t),
1189 GFP_KERNEL); 1183 GFP_KERNEL);
1190 if (!plane->format_types) { 1184 if (!plane->format_types) {
1191 DRM_DEBUG_KMS("out of memory when allocating plane\n"); 1185 DRM_DEBUG_KMS("out of memory when allocating plane\n");
1192 drm_mode_object_put(dev, &plane->base); 1186 drm_mode_object_put(dev, &plane->base);
@@ -1599,7 +1593,7 @@ static int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *gr
1599 total_objects += dev->mode_config.num_encoder; 1593 total_objects += dev->mode_config.num_encoder;
1600 total_objects += dev->mode_config.num_bridge; 1594 total_objects += dev->mode_config.num_bridge;
1601 1595
1602 group->id_list = kzalloc(total_objects * sizeof(uint32_t), GFP_KERNEL); 1596 group->id_list = kcalloc(total_objects, sizeof(uint32_t), GFP_KERNEL);
1603 if (!group->id_list) 1597 if (!group->id_list)
1604 return -ENOMEM; 1598 return -ENOMEM;
1605 1599
@@ -1629,7 +1623,8 @@ int drm_mode_group_init_legacy_group(struct drm_device *dev,
1629 struct drm_bridge *bridge; 1623 struct drm_bridge *bridge;
1630 int ret; 1624 int ret;
1631 1625
1632 if ((ret = drm_mode_group_init(dev, group))) 1626 ret = drm_mode_group_init(dev, group);
1627 if (ret)
1633 return ret; 1628 return ret;
1634 1629
1635 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) 1630 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
@@ -2045,11 +2040,9 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
2045 2040
2046 props_count = connector->properties.count; 2041 props_count = connector->properties.count;
2047 2042
2048 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { 2043 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++)
2049 if (connector->encoder_ids[i] != 0) { 2044 if (connector->encoder_ids[i] != 0)
2050 encoders_count++; 2045 encoders_count++;
2051 }
2052 }
2053 2046
2054 if (out_resp->count_modes == 0) { 2047 if (out_resp->count_modes == 0) {
2055 connector->funcs->fill_modes(connector, 2048 connector->funcs->fill_modes(connector,
@@ -2529,7 +2522,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,
2529 * 2522 *
2530 * This is a little helper to wrap internal calls to the ->set_config driver 2523 * This is a little helper to wrap internal calls to the ->set_config driver
2531 * interface. The only thing it adds is correct refcounting dance. 2524 * interface. The only thing it adds is correct refcounting dance.
2532 * 2525 *
2533 * Returns: 2526 * Returns:
2534 * Zero on success, negative errno on failure. 2527 * Zero on success, negative errno on failure.
2535 */ 2528 */
@@ -2690,6 +2683,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
2690 goto out; 2683 goto out;
2691 } 2684 }
2692 2685
2686 mode->status = drm_mode_validate_basic(mode);
2687 if (mode->status != MODE_OK) {
2688 ret = -EINVAL;
2689 goto out;
2690 }
2691
2693 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); 2692 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
2694 2693
2695 ret = drm_crtc_check_viewport(crtc, crtc_req->x, crtc_req->y, 2694 ret = drm_crtc_check_viewport(crtc, crtc_req->x, crtc_req->y,
@@ -2721,9 +2720,9 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
2721 goto out; 2720 goto out;
2722 } 2721 }
2723 2722
2724 connector_set = kmalloc(crtc_req->count_connectors * 2723 connector_set = kmalloc_array(crtc_req->count_connectors,
2725 sizeof(struct drm_connector *), 2724 sizeof(struct drm_connector *),
2726 GFP_KERNEL); 2725 GFP_KERNEL);
2727 if (!connector_set) { 2726 if (!connector_set) {
2728 ret = -ENOMEM; 2727 ret = -ENOMEM;
2729 goto out; 2728 goto out;
@@ -2968,6 +2967,7 @@ int drm_mode_cursor2_ioctl(struct drm_device *dev,
2968 void *data, struct drm_file *file_priv) 2967 void *data, struct drm_file *file_priv)
2969{ 2968{
2970 struct drm_mode_cursor2 *req = data; 2969 struct drm_mode_cursor2 *req = data;
2970
2971 return drm_mode_cursor_common(dev, req, file_priv); 2971 return drm_mode_cursor_common(dev, req, file_priv);
2972} 2972}
2973 2973
@@ -3415,7 +3415,7 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
3415 ret = -EINVAL; 3415 ret = -EINVAL;
3416 goto out_err1; 3416 goto out_err1;
3417 } 3417 }
3418 clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL); 3418 clips = kcalloc(num_clips, sizeof(*clips), GFP_KERNEL);
3419 if (!clips) { 3419 if (!clips) {
3420 ret = -ENOMEM; 3420 ret = -ENOMEM;
3421 goto out_err1; 3421 goto out_err1;
@@ -3516,7 +3516,8 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
3516 property->dev = dev; 3516 property->dev = dev;
3517 3517
3518 if (num_values) { 3518 if (num_values) {
3519 property->values = kzalloc(sizeof(uint64_t)*num_values, GFP_KERNEL); 3519 property->values = kcalloc(num_values, sizeof(uint64_t),
3520 GFP_KERNEL);
3520 if (!property->values) 3521 if (!property->values)
3521 goto fail; 3522 goto fail;
3522 } 3523 }
@@ -4057,7 +4058,7 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
4057 4058
4058 if (out_resp->length == blob->length) { 4059 if (out_resp->length == blob->length) {
4059 blob_ptr = (void __user *)(unsigned long)out_resp->data; 4060 blob_ptr = (void __user *)(unsigned long)out_resp->data;
4060 if (copy_to_user(blob_ptr, blob->data, blob->length)){ 4061 if (copy_to_user(blob_ptr, blob->data, blob->length)) {
4061 ret = -EFAULT; 4062 ret = -EFAULT;
4062 goto done; 4063 goto done;
4063 } 4064 }
@@ -4196,6 +4197,8 @@ EXPORT_SYMBOL(drm_mode_connector_update_edid_property);
4196static bool drm_property_change_is_valid(struct drm_property *property, 4197static bool drm_property_change_is_valid(struct drm_property *property,
4197 uint64_t value) 4198 uint64_t value)
4198{ 4199{
4200 int i;
4201
4199 if (property->flags & DRM_MODE_PROP_IMMUTABLE) 4202 if (property->flags & DRM_MODE_PROP_IMMUTABLE)
4200 return false; 4203 return false;
4201 4204
@@ -4205,13 +4208,14 @@ static bool drm_property_change_is_valid(struct drm_property *property,
4205 return true; 4208 return true;
4206 } else if (drm_property_type_is(property, DRM_MODE_PROP_SIGNED_RANGE)) { 4209 } else if (drm_property_type_is(property, DRM_MODE_PROP_SIGNED_RANGE)) {
4207 int64_t svalue = U642I64(value); 4210 int64_t svalue = U642I64(value);
4211
4208 if (svalue < U642I64(property->values[0]) || 4212 if (svalue < U642I64(property->values[0]) ||
4209 svalue > U642I64(property->values[1])) 4213 svalue > U642I64(property->values[1]))
4210 return false; 4214 return false;
4211 return true; 4215 return true;
4212 } else if (drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) { 4216 } else if (drm_property_type_is(property, DRM_MODE_PROP_BITMASK)) {
4213 int i;
4214 uint64_t valid_mask = 0; 4217 uint64_t valid_mask = 0;
4218
4215 for (i = 0; i < property->num_values; i++) 4219 for (i = 0; i < property->num_values; i++)
4216 valid_mask |= (1ULL << property->values[i]); 4220 valid_mask |= (1ULL << property->values[i]);
4217 return !(value & ~valid_mask); 4221 return !(value & ~valid_mask);
@@ -4220,6 +4224,7 @@ static bool drm_property_change_is_valid(struct drm_property *property,
4220 return true; 4224 return true;
4221 } else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) { 4225 } else if (drm_property_type_is(property, DRM_MODE_PROP_OBJECT)) {
4222 struct drm_mode_object *obj; 4226 struct drm_mode_object *obj;
4227
4223 /* a zero value for an object property translates to null: */ 4228 /* a zero value for an object property translates to null: */
4224 if (value == 0) 4229 if (value == 0)
4225 return true; 4230 return true;
@@ -4232,13 +4237,12 @@ static bool drm_property_change_is_valid(struct drm_property *property,
4232 */ 4237 */
4233 obj = _object_find(property->dev, value, property->values[0]); 4238 obj = _object_find(property->dev, value, property->values[0]);
4234 return obj != NULL; 4239 return obj != NULL;
4235 } else {
4236 int i;
4237 for (i = 0; i < property->num_values; i++)
4238 if (property->values[i] == value)
4239 return true;
4240 return false;
4241 } 4240 }
4241
4242 for (i = 0; i < property->num_values; i++)
4243 if (property->values[i] == value)
4244 return true;
4245 return false;
4242} 4246}
4243 4247
4244/** 4248/**
@@ -4526,7 +4530,8 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
4526{ 4530{
4527 crtc->gamma_size = gamma_size; 4531 crtc->gamma_size = gamma_size;
4528 4532
4529 crtc->gamma_store = kzalloc(gamma_size * sizeof(uint16_t) * 3, GFP_KERNEL); 4533 crtc->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3,
4534 GFP_KERNEL);
4530 if (!crtc->gamma_store) { 4535 if (!crtc->gamma_store) {
4531 crtc->gamma_size = 0; 4536 crtc->gamma_size = 0;
4532 return -ENOMEM; 4537 return -ENOMEM;
@@ -4741,23 +4746,23 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
4741 if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) { 4746 if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
4742 ret = -ENOMEM; 4747 ret = -ENOMEM;
4743 spin_lock_irqsave(&dev->event_lock, flags); 4748 spin_lock_irqsave(&dev->event_lock, flags);
4744 if (file_priv->event_space < sizeof e->event) { 4749 if (file_priv->event_space < sizeof(e->event)) {
4745 spin_unlock_irqrestore(&dev->event_lock, flags); 4750 spin_unlock_irqrestore(&dev->event_lock, flags);
4746 goto out; 4751 goto out;
4747 } 4752 }
4748 file_priv->event_space -= sizeof e->event; 4753 file_priv->event_space -= sizeof(e->event);
4749 spin_unlock_irqrestore(&dev->event_lock, flags); 4754 spin_unlock_irqrestore(&dev->event_lock, flags);
4750 4755
4751 e = kzalloc(sizeof *e, GFP_KERNEL); 4756 e = kzalloc(sizeof(*e), GFP_KERNEL);
4752 if (e == NULL) { 4757 if (e == NULL) {
4753 spin_lock_irqsave(&dev->event_lock, flags); 4758 spin_lock_irqsave(&dev->event_lock, flags);
4754 file_priv->event_space += sizeof e->event; 4759 file_priv->event_space += sizeof(e->event);
4755 spin_unlock_irqrestore(&dev->event_lock, flags); 4760 spin_unlock_irqrestore(&dev->event_lock, flags);
4756 goto out; 4761 goto out;
4757 } 4762 }
4758 4763
4759 e->event.base.type = DRM_EVENT_FLIP_COMPLETE; 4764 e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
4760 e->event.base.length = sizeof e->event; 4765 e->event.base.length = sizeof(e->event);
4761 e->event.user_data = page_flip->user_data; 4766 e->event.user_data = page_flip->user_data;
4762 e->base.event = &e->event.base; 4767 e->base.event = &e->event.base;
4763 e->base.file_priv = file_priv; 4768 e->base.file_priv = file_priv;
@@ -4770,7 +4775,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
4770 if (ret) { 4775 if (ret) {
4771 if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) { 4776 if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
4772 spin_lock_irqsave(&dev->event_lock, flags); 4777 spin_lock_irqsave(&dev->event_lock, flags);
4773 file_priv->event_space += sizeof e->event; 4778 file_priv->event_space += sizeof(e->event);
4774 spin_unlock_irqrestore(&dev->event_lock, flags); 4779 spin_unlock_irqrestore(&dev->event_lock, flags);
4775 kfree(e); 4780 kfree(e);
4776 } 4781 }
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index 51efebd434f3..f1b32f91d941 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -153,30 +153,6 @@ int drm_bufs_info(struct seq_file *m, void *data)
153} 153}
154 154
155/** 155/**
156 * Called when "/proc/dri/.../vblank" is read.
157 */
158int drm_vblank_info(struct seq_file *m, void *data)
159{
160 struct drm_info_node *node = (struct drm_info_node *) m->private;
161 struct drm_device *dev = node->minor->dev;
162 int crtc;
163
164 mutex_lock(&dev->struct_mutex);
165 for (crtc = 0; crtc < dev->num_crtcs; crtc++) {
166 seq_printf(m, "CRTC %d enable: %d\n",
167 crtc, atomic_read(&dev->vblank[crtc].refcount));
168 seq_printf(m, "CRTC %d counter: %d\n",
169 crtc, drm_vblank_count(dev, crtc));
170 seq_printf(m, "CRTC %d last wait: %d\n",
171 crtc, dev->vblank[crtc].last_wait);
172 seq_printf(m, "CRTC %d in modeset: %d\n",
173 crtc, dev->vblank[crtc].inmodeset);
174 }
175 mutex_unlock(&dev->struct_mutex);
176 return 0;
177}
178
179/**
180 * Called when "/proc/dri/.../clients" is read. 156 * Called when "/proc/dri/.../clients" is read.
181 * 157 *
182 */ 158 */
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 7cc0a3516871..12a61d706827 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -55,7 +55,6 @@ void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpr
55int drm_name_info(struct seq_file *m, void *data); 55int drm_name_info(struct seq_file *m, void *data);
56int drm_vm_info(struct seq_file *m, void *data); 56int drm_vm_info(struct seq_file *m, void *data);
57int drm_bufs_info(struct seq_file *m, void *data); 57int drm_bufs_info(struct seq_file *m, void *data);
58int drm_vblank_info(struct seq_file *m, void *data);
59int drm_clients_info(struct seq_file *m, void* data); 58int drm_clients_info(struct seq_file *m, void* data);
60int drm_gem_name_info(struct seq_file *m, void *data); 59int drm_gem_name_info(struct seq_file *m, void *data);
61 60
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 4d79dad9d44f..75647e7f012b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -778,7 +778,7 @@ static struct timeval get_drm_timestamp(void)
778 778
779/** 779/**
780 * drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent 780 * drm_get_last_vbltimestamp - retrieve raw timestamp for the most recent
781 * vblank interval 781 * vblank interval
782 * @dev: DRM device 782 * @dev: DRM device
783 * @crtc: which CRTC's vblank timestamp to retrieve 783 * @crtc: which CRTC's vblank timestamp to retrieve
784 * @tvblank: Pointer to target struct timeval which should receive the timestamp 784 * @tvblank: Pointer to target struct timeval which should receive the timestamp
@@ -933,6 +933,7 @@ void drm_send_vblank_event(struct drm_device *dev, int crtc,
933{ 933{
934 struct timeval now; 934 struct timeval now;
935 unsigned int seq; 935 unsigned int seq;
936
936 if (crtc >= 0) { 937 if (crtc >= 0) {
937 seq = drm_vblank_count_and_time(dev, crtc, &now); 938 seq = drm_vblank_count_and_time(dev, crtc, &now);
938 } else { 939 } else {
@@ -1422,7 +1423,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
1422 unsigned int seq; 1423 unsigned int seq;
1423 int ret; 1424 int ret;
1424 1425
1425 e = kzalloc(sizeof *e, GFP_KERNEL); 1426 e = kzalloc(sizeof(*e), GFP_KERNEL);
1426 if (e == NULL) { 1427 if (e == NULL) {
1427 ret = -ENOMEM; 1428 ret = -ENOMEM;
1428 goto err_put; 1429 goto err_put;
@@ -1431,7 +1432,7 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
1431 e->pipe = pipe; 1432 e->pipe = pipe;
1432 e->base.pid = current->pid; 1433 e->base.pid = current->pid;
1433 e->event.base.type = DRM_EVENT_VBLANK; 1434 e->event.base.type = DRM_EVENT_VBLANK;
1434 e->event.base.length = sizeof e->event; 1435 e->event.base.length = sizeof(e->event);
1435 e->event.user_data = vblwait->request.signal; 1436 e->event.user_data = vblwait->request.signal;
1436 e->base.event = &e->event.base; 1437 e->base.event = &e->event.base;
1437 e->base.file_priv = file_priv; 1438 e->base.file_priv = file_priv;
@@ -1451,12 +1452,12 @@ static int drm_queue_vblank_event(struct drm_device *dev, int pipe,
1451 goto err_unlock; 1452 goto err_unlock;
1452 } 1453 }
1453 1454
1454 if (file_priv->event_space < sizeof e->event) { 1455 if (file_priv->event_space < sizeof(e->event)) {
1455 ret = -EBUSY; 1456 ret = -EBUSY;
1456 goto err_unlock; 1457 goto err_unlock;
1457 } 1458 }
1458 1459
1459 file_priv->event_space -= sizeof e->event; 1460 file_priv->event_space -= sizeof(e->event);
1460 seq = drm_vblank_count_and_time(dev, pipe, &now); 1461 seq = drm_vblank_count_and_time(dev, pipe, &now);
1461 1462
1462 if ((vblwait->request.type & _DRM_VBLANK_NEXTONMISS) && 1463 if ((vblwait->request.type & _DRM_VBLANK_NEXTONMISS) &&
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 6d8b941c8200..11cc4deca55b 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -906,9 +906,40 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
906EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo); 906EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
907 907
908/** 908/**
909 * drm_mode_validate_basic - make sure the mode is somewhat sane
910 * @mode: mode to check
911 *
912 * Check that the mode timings are at least somewhat reasonable.
913 * Any hardware specific limits are left up for each driver to check.
914 *
915 * Returns:
916 * The mode status
917 */
918enum drm_mode_status
919drm_mode_validate_basic(const struct drm_display_mode *mode)
920{
921 if (mode->clock == 0)
922 return MODE_CLOCK_LOW;
923
924 if (mode->hdisplay == 0 ||
925 mode->hsync_start < mode->hdisplay ||
926 mode->hsync_end < mode->hsync_start ||
927 mode->htotal < mode->hsync_end)
928 return MODE_H_ILLEGAL;
929
930 if (mode->vdisplay == 0 ||
931 mode->vsync_start < mode->vdisplay ||
932 mode->vsync_end < mode->vsync_start ||
933 mode->vtotal < mode->vsync_end)
934 return MODE_V_ILLEGAL;
935
936 return MODE_OK;
937}
938EXPORT_SYMBOL(drm_mode_validate_basic);
939
940/**
909 * drm_mode_validate_size - make sure modes adhere to size constraints 941 * drm_mode_validate_size - make sure modes adhere to size constraints
910 * @dev: DRM device 942 * @mode: mode to check
911 * @mode_list: list of modes to check
912 * @maxX: maximum width 943 * @maxX: maximum width
913 * @maxY: maximum height 944 * @maxY: maximum height
914 * 945 *
@@ -916,20 +947,21 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
916 * limitations of the DRM device/connector. If a mode is too big its status 947 * limitations of the DRM device/connector. If a mode is too big its status
917 * member is updated with the appropriate validation failure code. The list 948 * member is updated with the appropriate validation failure code. The list
918 * itself is not changed. 949 * itself is not changed.
950 *
951 * Returns:
952 * The mode status
919 */ 953 */
920void drm_mode_validate_size(struct drm_device *dev, 954enum drm_mode_status
921 struct list_head *mode_list, 955drm_mode_validate_size(const struct drm_display_mode *mode,
922 int maxX, int maxY) 956 int maxX, int maxY)
923{ 957{
924 struct drm_display_mode *mode; 958 if (maxX > 0 && mode->hdisplay > maxX)
959 return MODE_VIRTUAL_X;
925 960
926 list_for_each_entry(mode, mode_list, head) { 961 if (maxY > 0 && mode->vdisplay > maxY)
927 if (maxX > 0 && mode->hdisplay > maxX) 962 return MODE_VIRTUAL_Y;
928 mode->status = MODE_VIRTUAL_X;
929 963
930 if (maxY > 0 && mode->vdisplay > maxY) 964 return MODE_OK;
931 mode->status = MODE_VIRTUAL_Y;
932 }
933} 965}
934EXPORT_SYMBOL(drm_mode_validate_size); 966EXPORT_SYMBOL(drm_mode_validate_size);
935 967
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index 18a1ac6ac22f..391dfb7d1086 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -142,6 +142,17 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
142{ 142{
143 int hscale, vscale; 143 int hscale, vscale;
144 144
145 if (!fb) {
146 *visible = false;
147 return 0;
148 }
149
150 /* crtc should only be NULL when disabling (i.e., !fb) */
151 if (WARN_ON(!crtc)) {
152 *visible = false;
153 return 0;
154 }
155
145 if (!crtc->enabled && !can_update_disabled) { 156 if (!crtc->enabled && !can_update_disabled) {
146 DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n"); 157 DRM_DEBUG_KMS("Cannot update plane of a disabled CRTC.\n");
147 return -EINVAL; 158 return -EINVAL;
@@ -155,11 +166,6 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
155 return -ERANGE; 166 return -ERANGE;
156 } 167 }
157 168
158 if (!fb) {
159 *visible = false;
160 return 0;
161 }
162
163 *visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale); 169 *visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale);
164 if (!*visible) 170 if (!*visible)
165 /* 171 /*
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 7483a47de8e4..2fbdcca7ca9a 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -58,28 +58,23 @@
58static bool drm_kms_helper_poll = true; 58static bool drm_kms_helper_poll = true;
59module_param_named(poll, drm_kms_helper_poll, bool, 0600); 59module_param_named(poll, drm_kms_helper_poll, bool, 0600);
60 60
61static void drm_mode_validate_flag(struct drm_connector *connector, 61static enum drm_mode_status
62 int flags) 62drm_mode_validate_flag(const struct drm_display_mode *mode,
63 int flags)
63{ 64{
64 struct drm_display_mode *mode; 65 if ((mode->flags & DRM_MODE_FLAG_INTERLACE) &&
66 !(flags & DRM_MODE_FLAG_INTERLACE))
67 return MODE_NO_INTERLACE;
65 68
66 if (flags == (DRM_MODE_FLAG_DBLSCAN | DRM_MODE_FLAG_INTERLACE | 69 if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) &&
67 DRM_MODE_FLAG_3D_MASK)) 70 !(flags & DRM_MODE_FLAG_DBLSCAN))
68 return; 71 return MODE_NO_DBLESCAN;
69 72
70 list_for_each_entry(mode, &connector->modes, head) { 73 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) &&
71 if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && 74 !(flags & DRM_MODE_FLAG_3D_MASK))
72 !(flags & DRM_MODE_FLAG_INTERLACE)) 75 return MODE_NO_STEREO;
73 mode->status = MODE_NO_INTERLACE;
74 if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) &&
75 !(flags & DRM_MODE_FLAG_DBLSCAN))
76 mode->status = MODE_NO_DBLESCAN;
77 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) &&
78 !(flags & DRM_MODE_FLAG_3D_MASK))
79 mode->status = MODE_NO_STEREO;
80 }
81 76
82 return; 77 return MODE_OK;
83} 78}
84 79
85static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector) 80static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector)
@@ -164,18 +159,22 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
164 159
165 drm_mode_connector_list_update(connector, merge_type_bits); 160 drm_mode_connector_list_update(connector, merge_type_bits);
166 161
167 if (maxX && maxY)
168 drm_mode_validate_size(dev, &connector->modes, maxX, maxY);
169
170 if (connector->interlace_allowed) 162 if (connector->interlace_allowed)
171 mode_flags |= DRM_MODE_FLAG_INTERLACE; 163 mode_flags |= DRM_MODE_FLAG_INTERLACE;
172 if (connector->doublescan_allowed) 164 if (connector->doublescan_allowed)
173 mode_flags |= DRM_MODE_FLAG_DBLSCAN; 165 mode_flags |= DRM_MODE_FLAG_DBLSCAN;
174 if (connector->stereo_allowed) 166 if (connector->stereo_allowed)
175 mode_flags |= DRM_MODE_FLAG_3D_MASK; 167 mode_flags |= DRM_MODE_FLAG_3D_MASK;
176 drm_mode_validate_flag(connector, mode_flags);
177 168
178 list_for_each_entry(mode, &connector->modes, head) { 169 list_for_each_entry(mode, &connector->modes, head) {
170 mode->status = drm_mode_validate_basic(mode);
171
172 if (mode->status == MODE_OK)
173 mode->status = drm_mode_validate_size(mode, maxX, maxY);
174
175 if (mode->status == MODE_OK)
176 mode->status = drm_mode_validate_flag(mode, mode_flags);
177
179 if (mode->status == MODE_OK && connector_funcs->mode_valid) 178 if (mode->status == MODE_OK && connector_funcs->mode_valid)
180 mode->status = connector_funcs->mode_valid(connector, 179 mode->status = connector_funcs->mode_valid(connector,
181 mode); 180 mode);
diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
index 3449213f1e76..20ae50385e5b 100644
--- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
@@ -323,10 +323,6 @@ static void mdp4_crtc_commit(struct drm_crtc *crtc)
323 drm_crtc_vblank_put(crtc); 323 drm_crtc_vblank_put(crtc);
324} 324}
325 325
326static void mdp4_crtc_load_lut(struct drm_crtc *crtc)
327{
328}
329
330static int mdp4_crtc_atomic_check(struct drm_crtc *crtc, 326static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
331 struct drm_crtc_state *state) 327 struct drm_crtc_state *state)
332{ 328{
@@ -515,7 +511,6 @@ static const struct drm_crtc_helper_funcs mdp4_crtc_helper_funcs = {
515 .mode_set_base = drm_helper_crtc_mode_set_base, 511 .mode_set_base = drm_helper_crtc_mode_set_base,
516 .prepare = mdp4_crtc_prepare, 512 .prepare = mdp4_crtc_prepare,
517 .commit = mdp4_crtc_commit, 513 .commit = mdp4_crtc_commit,
518 .load_lut = mdp4_crtc_load_lut,
519 .atomic_check = mdp4_crtc_atomic_check, 514 .atomic_check = mdp4_crtc_atomic_check,
520 .atomic_begin = mdp4_crtc_atomic_begin, 515 .atomic_begin = mdp4_crtc_atomic_begin,
521 .atomic_flush = mdp4_crtc_atomic_flush, 516 .atomic_flush = mdp4_crtc_atomic_flush,
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index f021f960a8a2..6b25f9f731ed 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -275,10 +275,6 @@ static void mdp5_crtc_commit(struct drm_crtc *crtc)
275 mdp5_disable(get_kms(crtc)); 275 mdp5_disable(get_kms(crtc));
276} 276}
277 277
278static void mdp5_crtc_load_lut(struct drm_crtc *crtc)
279{
280}
281
282struct plane_state { 278struct plane_state {
283 struct drm_plane *plane; 279 struct drm_plane *plane;
284 struct mdp5_plane_state *state; 280 struct mdp5_plane_state *state;
@@ -402,7 +398,6 @@ static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
402 .mode_set_base = drm_helper_crtc_mode_set_base, 398 .mode_set_base = drm_helper_crtc_mode_set_base,
403 .prepare = mdp5_crtc_prepare, 399 .prepare = mdp5_crtc_prepare,
404 .commit = mdp5_crtc_commit, 400 .commit = mdp5_crtc_commit,
405 .load_lut = mdp5_crtc_load_lut,
406 .atomic_check = mdp5_crtc_atomic_check, 401 .atomic_check = mdp5_crtc_atomic_check,
407 .atomic_begin = mdp5_crtc_atomic_begin, 402 .atomic_begin = mdp5_crtc_atomic_begin,
408 .atomic_flush = mdp5_crtc_atomic_flush, 403 .atomic_flush = mdp5_crtc_atomic_flush,
diff --git a/drivers/gpu/drm/sti/sti_drm_crtc.c b/drivers/gpu/drm/sti/sti_drm_crtc.c
index 4c651c200f20..e6f6ef7c4866 100644
--- a/drivers/gpu/drm/sti/sti_drm_crtc.c
+++ b/drivers/gpu/drm/sti/sti_drm_crtc.c
@@ -190,11 +190,6 @@ out:
190 return ret; 190 return ret;
191} 191}
192 192
193static void sti_drm_crtc_load_lut(struct drm_crtc *crtc)
194{
195 /* do nothing */
196}
197
198static void sti_drm_crtc_disable(struct drm_crtc *crtc) 193static void sti_drm_crtc_disable(struct drm_crtc *crtc)
199{ 194{
200 struct sti_mixer *mixer = to_sti_mixer(crtc); 195 struct sti_mixer *mixer = to_sti_mixer(crtc);
@@ -249,7 +244,6 @@ static struct drm_crtc_helper_funcs sti_crtc_helper_funcs = {
249 .mode_fixup = sti_drm_crtc_mode_fixup, 244 .mode_fixup = sti_drm_crtc_mode_fixup,
250 .mode_set = sti_drm_crtc_mode_set, 245 .mode_set = sti_drm_crtc_mode_set,
251 .mode_set_base = sti_drm_crtc_mode_set_base, 246 .mode_set_base = sti_drm_crtc_mode_set_base,
252 .load_lut = sti_drm_crtc_load_lut,
253 .disable = sti_drm_crtc_disable, 247 .disable = sti_drm_crtc_disable,
254}; 248};
255 249
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 978993fa3a36..ae26cc054fff 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -1119,10 +1119,6 @@ static void tegra_crtc_commit(struct drm_crtc *crtc)
1119 tegra_dc_commit(dc); 1119 tegra_dc_commit(dc);
1120} 1120}
1121 1121
1122static void tegra_crtc_load_lut(struct drm_crtc *crtc)
1123{
1124}
1125
1126static const struct drm_crtc_helper_funcs tegra_crtc_helper_funcs = { 1122static const struct drm_crtc_helper_funcs tegra_crtc_helper_funcs = {
1127 .disable = tegra_crtc_disable, 1123 .disable = tegra_crtc_disable,
1128 .mode_fixup = tegra_crtc_mode_fixup, 1124 .mode_fixup = tegra_crtc_mode_fixup,
@@ -1130,7 +1126,6 @@ static const struct drm_crtc_helper_funcs tegra_crtc_helper_funcs = {
1130 .mode_set_base = tegra_crtc_mode_set_base, 1126 .mode_set_base = tegra_crtc_mode_set_base,
1131 .prepare = tegra_crtc_prepare, 1127 .prepare = tegra_crtc_prepare,
1132 .commit = tegra_crtc_commit, 1128 .commit = tegra_crtc_commit,
1133 .load_lut = tegra_crtc_load_lut,
1134}; 1129};
1135 1130
1136static irqreturn_t tegra_dc_irq(int irq, void *data) 1131static irqreturn_t tegra_dc_irq(int irq, void *data)
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index e1b2e8b98af7..a5f6a1f563c4 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -744,8 +744,6 @@ struct drm_device {
744 744
745 /** \name Context support */ 745 /** \name Context support */
746 /*@{ */ 746 /*@{ */
747 bool irq_enabled; /**< True if irq handler is enabled */
748 int irq;
749 747
750 __volatile__ long context_flag; /**< Context swapping flag */ 748 __volatile__ long context_flag; /**< Context swapping flag */
751 int last_context; /**< Last current context */ 749 int last_context; /**< Last current context */
@@ -753,6 +751,8 @@ struct drm_device {
753 751
754 /** \name VBLANK IRQ support */ 752 /** \name VBLANK IRQ support */
755 /*@{ */ 753 /*@{ */
754 bool irq_enabled;
755 int irq;
756 756
757 /* 757 /*
758 * At load time, disabling the vblank interrupt won't be allowed since 758 * At load time, disabling the vblank interrupt won't be allowed since
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b86329813ad3..291239f2fafc 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -463,7 +463,7 @@ struct drm_connector_state {
463 463
464/** 464/**
465 * struct drm_connector_funcs - control connectors on a given device 465 * struct drm_connector_funcs - control connectors on a given device
466 * @dpms: set power state (see drm_crtc_funcs above) 466 * @dpms: set power state
467 * @save: save connector state 467 * @save: save connector state
468 * @restore: restore connector state 468 * @restore: restore connector state
469 * @reset: reset connector after state has been invalidated (e.g. resume) 469 * @reset: reset connector after state has been invalidated (e.g. resume)
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index 7adbb65ea8ae..e76828d81a8b 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -39,15 +39,28 @@
39 39
40#include <linux/fb.h> 40#include <linux/fb.h>
41 41
42#include <drm/drm_crtc.h>
43
42enum mode_set_atomic { 44enum mode_set_atomic {
43 LEAVE_ATOMIC_MODE_SET, 45 LEAVE_ATOMIC_MODE_SET,
44 ENTER_ATOMIC_MODE_SET, 46 ENTER_ATOMIC_MODE_SET,
45}; 47};
46 48
47/** 49/**
48 * drm_crtc_helper_funcs - helper operations for CRTCs 50 * struct drm_crtc_helper_funcs - helper operations for CRTCs
49 * @mode_fixup: try to fixup proposed mode for this connector 51 * @dpms: set power state
52 * @prepare: prepare the CRTC, called before @mode_set
53 * @commit: commit changes to CRTC, called after @mode_set
54 * @mode_fixup: try to fixup proposed mode for this CRTC
50 * @mode_set: set this mode 55 * @mode_set: set this mode
56 * @mode_set_nofb: set mode only (no scanout buffer attached)
57 * @mode_set_base: update the scanout buffer
58 * @mode_set_base_atomic: non-blocking mode set (used for kgdb support)
59 * @load_lut: load color palette
60 * @disable: disable CRTC when no longer in use
61 * @atomic_check: check for validity of an atomic state
62 * @atomic_begin: begin atomic update
63 * @atomic_flush: flush atomic update
51 * 64 *
52 * The helper operations are called by the mid-layer CRTC helper. 65 * The helper operations are called by the mid-layer CRTC helper.
53 */ 66 */
@@ -91,9 +104,17 @@ struct drm_crtc_helper_funcs {
91}; 104};
92 105
93/** 106/**
94 * drm_encoder_helper_funcs - helper operations for encoders 107 * struct drm_encoder_helper_funcs - helper operations for encoders
108 * @dpms: set power state
109 * @save: save connector state
110 * @restore: restore connector state
95 * @mode_fixup: try to fixup proposed mode for this connector 111 * @mode_fixup: try to fixup proposed mode for this connector
112 * @prepare: part of the disable sequence, called before the CRTC modeset
113 * @commit: called after the CRTC modeset
96 * @mode_set: set this mode 114 * @mode_set: set this mode
115 * @get_crtc: return CRTC that the encoder is currently attached to
116 * @detect: connection status detection
117 * @disable: disable encoder when not in use (overrides DPMS off)
97 * 118 *
98 * The helper operations are called by the mid-layer CRTC helper. 119 * The helper operations are called by the mid-layer CRTC helper.
99 */ 120 */
@@ -119,9 +140,10 @@ struct drm_encoder_helper_funcs {
119}; 140};
120 141
121/** 142/**
122 * drm_connector_helper_funcs - helper operations for connectors 143 * struct drm_connector_helper_funcs - helper operations for connectors
123 * @get_modes: get mode list for this connector 144 * @get_modes: get mode list for this connector
124 * @mode_valid (optional): is this mode valid on the given connector? 145 * @mode_valid: is this mode valid on the given connector? (optional)
146 * @best_encoder: return the preferred encoder for this connector
125 * 147 *
126 * The helper operations are called by the mid-layer CRTC helper. 148 * The helper operations are called by the mid-layer CRTC helper.
127 */ 149 */
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
index 91d0582f924e..a36a5bfce2f5 100644
--- a/include/drm/drm_modes.h
+++ b/include/drm/drm_modes.h
@@ -217,9 +217,9 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
217 const struct drm_display_mode *mode2); 217 const struct drm_display_mode *mode2);
218 218
219/* for use by the crtc helper probe functions */ 219/* for use by the crtc helper probe functions */
220void drm_mode_validate_size(struct drm_device *dev, 220enum drm_mode_status drm_mode_validate_basic(const struct drm_display_mode *mode);
221 struct list_head *mode_list, 221enum drm_mode_status drm_mode_validate_size(const struct drm_display_mode *mode,
222 int maxX, int maxY); 222 int maxX, int maxY);
223void drm_mode_prune_invalid(struct drm_device *dev, 223void drm_mode_prune_invalid(struct drm_device *dev,
224 struct list_head *mode_list, bool verbose); 224 struct list_head *mode_list, bool verbose);
225void drm_mode_sort(struct list_head *mode_list); 225void drm_mode_sort(struct list_head *mode_list);
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 86574b0005ff..aae71cb32123 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -338,7 +338,7 @@ struct drm_mode_fb_cmd2 {
338 338
339 /* 339 /*
340 * In case of planar formats, this ioctl allows up to 4 340 * In case of planar formats, this ioctl allows up to 4
341 * buffer objects with offets and pitches per plane. 341 * buffer objects with offsets and pitches per plane.
342 * The pitch and offset order is dictated by the fourcc, 342 * The pitch and offset order is dictated by the fourcc,
343 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as: 343 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
344 * 344 *
@@ -346,9 +346,9 @@ struct drm_mode_fb_cmd2 {
346 * followed by an interleaved U/V plane containing 346 * followed by an interleaved U/V plane containing
347 * 8 bit 2x2 subsampled colour difference samples. 347 * 8 bit 2x2 subsampled colour difference samples.
348 * 348 *
349 * So it would consist of Y as offset[0] and UV as 349 * So it would consist of Y as offsets[0] and UV as
350 * offeset[1]. Note that offset[0] will generally 350 * offsets[1]. Note that offsets[0] will generally
351 * be 0. 351 * be 0 (but this is not required).
352 */ 352 */
353 __u32 handles[4]; 353 __u32 handles[4];
354 __u32 pitches[4]; /* pitch for each plane */ 354 __u32 pitches[4]; /* pitch for each plane */