Subversion Repositories Kolibri OS

Rev

Rev 6660 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6660 Rev 6937
Line 43... Line 43...
43
#include "drm_crtc_internal.h"
43
#include "drm_crtc_internal.h"
44
#include "drm_internal.h"
44
#include "drm_internal.h"
Line 45... Line 45...
45
 
45
 
46
static struct drm_framebuffer *
46
static struct drm_framebuffer *
47
internal_framebuffer_create(struct drm_device *dev,
47
internal_framebuffer_create(struct drm_device *dev,
48
			    struct drm_mode_fb_cmd2 *r,
48
			    const struct drm_mode_fb_cmd2 *r,
Line 49... Line 49...
49
			    struct drm_file *file_priv);
49
			    struct drm_file *file_priv);
50
 
50
 
51
/* Avoid boilerplate.  I'm tired of typing. */
51
/* Avoid boilerplate.  I'm tired of typing. */
Line 647... Line 647...
647
}
647
}
648
EXPORT_SYMBOL(drm_framebuffer_remove);
648
EXPORT_SYMBOL(drm_framebuffer_remove);
Line 649... Line 649...
649
 
649
 
Line -... Line 650...
-
 
650
DEFINE_WW_CLASS(crtc_ww_class);
-
 
651
 
-
 
652
static unsigned int drm_num_crtcs(struct drm_device *dev)
-
 
653
{
-
 
654
	unsigned int num = 0;
-
 
655
	struct drm_crtc *tmp;
-
 
656
 
-
 
657
	drm_for_each_crtc(tmp, dev) {
-
 
658
		num++;
-
 
659
	}
-
 
660
 
-
 
661
	return num;
650
DEFINE_WW_CLASS(crtc_ww_class);
662
}
651
 
663
 
652
/**
664
/**
653
 * drm_crtc_init_with_planes - Initialise a new CRTC object with
665
 * drm_crtc_init_with_planes - Initialise a new CRTC object with
654
 *    specified primary and cursor planes.
666
 *    specified primary and cursor planes.
655
 * @dev: DRM device
667
 * @dev: DRM device
656
 * @crtc: CRTC object to init
668
 * @crtc: CRTC object to init
657
 * @primary: Primary plane for CRTC
669
 * @primary: Primary plane for CRTC
-
 
670
 * @cursor: Cursor plane for CRTC
658
 * @cursor: Cursor plane for CRTC
671
 * @funcs: callbacks for the new CRTC
659
 * @funcs: callbacks for the new CRTC
672
 * @name: printf style format string for the CRTC name, or NULL for default name
660
 *
673
 *
661
 * Inits a new object created as base part of a driver crtc object.
674
 * Inits a new object created as base part of a driver crtc object.
662
 *
675
 *
663
 * Returns:
676
 * Returns:
664
 * Zero on success, error code on failure.
677
 * Zero on success, error code on failure.
665
 */
678
 */
666
int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
679
int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
667
			      struct drm_plane *primary,
680
			      struct drm_plane *primary,
-
 
681
			      struct drm_plane *cursor,
668
			      struct drm_plane *cursor,
682
			      const struct drm_crtc_funcs *funcs,
669
			      const struct drm_crtc_funcs *funcs)
683
			      const char *name, ...)
670
{
684
{
Line 671... Line 685...
671
	struct drm_mode_config *config = &dev->mode_config;
685
	struct drm_mode_config *config = &dev->mode_config;
Line 680... Line 694...
680
	drm_modeset_lock_init(&crtc->mutex);
694
	drm_modeset_lock_init(&crtc->mutex);
681
	ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC);
695
	ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC);
682
	if (ret)
696
	if (ret)
683
		return ret;
697
		return ret;
Line -... Line 698...
-
 
698
 
-
 
699
	if (name) {
-
 
700
		va_list ap;
-
 
701
 
-
 
702
		va_start(ap, name);
-
 
703
		crtc->name = kvasprintf(GFP_KERNEL, name, ap);
-
 
704
		va_end(ap);
-
 
705
	} else {
-
 
706
		crtc->name = kasprintf(GFP_KERNEL, "crtc-%d",
-
 
707
				       drm_num_crtcs(dev));
-
 
708
	}
-
 
709
	if (!crtc->name) {
-
 
710
		drm_mode_object_put(dev, &crtc->base);
-
 
711
		return -ENOMEM;
-
 
712
	}
684
 
713
 
Line 685... Line 714...
685
	crtc->base.properties = &crtc->properties;
714
	crtc->base.properties = &crtc->properties;
686
 
715
 
Line 726... Line 755...
726
 
755
 
727
	WARN_ON(crtc->state && !crtc->funcs->atomic_destroy_state);
756
	WARN_ON(crtc->state && !crtc->funcs->atomic_destroy_state);
728
	if (crtc->state && crtc->funcs->atomic_destroy_state)
757
	if (crtc->state && crtc->funcs->atomic_destroy_state)
Line -... Line 758...
-
 
758
		crtc->funcs->atomic_destroy_state(crtc, crtc->state);
-
 
759
 
729
		crtc->funcs->atomic_destroy_state(crtc, crtc->state);
760
	kfree(crtc->name);
730
 
761
 
731
	memset(crtc, 0, sizeof(*crtc));
762
	memset(crtc, 0, sizeof(*crtc));
Line 732... Line 763...
732
}
763
}
Line 885... Line 916...
885
		goto out_unlock;
916
		goto out_unlock;
Line 886... Line 917...
886
 
917
 
887
	connector->base.properties = &connector->properties;
918
	connector->base.properties = &connector->properties;
888
	connector->dev = dev;
919
	connector->dev = dev;
-
 
920
	connector->funcs = funcs;
-
 
921
 
-
 
922
	connector->connector_id = ida_simple_get(&config->connector_ida, 0, 0, GFP_KERNEL);
-
 
923
	if (connector->connector_id < 0) {
-
 
924
		ret = connector->connector_id;
-
 
925
		goto out_put;
-
 
926
	}
889
	connector->funcs = funcs;
927
 
890
	connector->connector_type = connector_type;
928
	connector->connector_type = connector_type;
891
	connector->connector_type_id =
929
	connector->connector_type_id =
892
		ida_simple_get(connector_ida, 1, 0, GFP_KERNEL);
930
		ida_simple_get(connector_ida, 1, 0, GFP_KERNEL);
893
	if (connector->connector_type_id < 0) {
931
	if (connector->connector_type_id < 0) {
894
		ret = connector->connector_type_id;
932
		ret = connector->connector_type_id;
895
		goto out_put;
933
		goto out_put_id;
896
	}
934
	}
897
	connector->name =
935
	connector->name =
898
		kasprintf(GFP_KERNEL, "%s-%d",
936
		kasprintf(GFP_KERNEL, "%s-%d",
899
			  drm_connector_enum_list[connector_type].name,
937
			  drm_connector_enum_list[connector_type].name,
900
			  connector->connector_type_id);
938
			  connector->connector_type_id);
901
	if (!connector->name) {
939
	if (!connector->name) {
902
		ret = -ENOMEM;
940
		ret = -ENOMEM;
903
		goto out_put;
941
		goto out_put_type_id;
Line 904... Line 942...
904
	}
942
	}
905
 
943
 
906
	INIT_LIST_HEAD(&connector->probed_modes);
944
	INIT_LIST_HEAD(&connector->probed_modes);
Line 926... Line 964...
926
	if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
964
	if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
927
		drm_object_attach_property(&connector->base, config->prop_crtc_id, 0);
965
		drm_object_attach_property(&connector->base, config->prop_crtc_id, 0);
928
	}
966
	}
Line 929... Line 967...
929
 
967
 
-
 
968
	connector->debugfs_entry = NULL;
-
 
969
out_put_type_id:
-
 
970
	if (ret)
-
 
971
		ida_remove(connector_ida, connector->connector_type_id);
930
	connector->debugfs_entry = NULL;
972
out_put_id:
-
 
973
	if (ret)
931
 
974
		ida_remove(&config->connector_ida, connector->connector_id);
932
out_put:
975
out_put:
933
	if (ret)
976
	if (ret)
Line 934... Line 977...
934
		drm_mode_object_put(dev, &connector->base);
977
		drm_mode_object_put(dev, &connector->base);
Line 963... Line 1006...
963
		drm_mode_remove(connector, mode);
1006
		drm_mode_remove(connector, mode);
Line 964... Line 1007...
964
 
1007
 
965
	ida_remove(&drm_connector_enum_list[connector->connector_type].ida,
1008
	ida_remove(&drm_connector_enum_list[connector->connector_type].ida,
Line -... Line 1009...
-
 
1009
		   connector->connector_type_id);
-
 
1010
 
-
 
1011
	ida_remove(&dev->mode_config.connector_ida,
966
		   connector->connector_type_id);
1012
		   connector->connector_id);
967
 
1013
 
968
	kfree(connector->display_info.bus_formats);
1014
	kfree(connector->display_info.bus_formats);
969
	drm_mode_object_put(dev, &connector->base);
1015
	drm_mode_object_put(dev, &connector->base);
970
	kfree(connector->name);
1016
	kfree(connector->name);
Line 980... Line 1026...
980
	memset(connector, 0, sizeof(*connector));
1026
	memset(connector, 0, sizeof(*connector));
981
}
1027
}
982
EXPORT_SYMBOL(drm_connector_cleanup);
1028
EXPORT_SYMBOL(drm_connector_cleanup);
Line 983... Line 1029...
983
 
1029
 
984
/**
-
 
985
 * drm_connector_index - find the index of a registered connector
-
 
986
 * @connector: connector to find index for
-
 
987
 *
-
 
988
 * Given a registered connector, return the index of that connector within a DRM
-
 
989
 * device's list of connectors.
-
 
990
 */
-
 
991
unsigned int drm_connector_index(struct drm_connector *connector)
-
 
992
{
-
 
993
	unsigned int index = 0;
-
 
994
	struct drm_connector *tmp;
-
 
995
	struct drm_mode_config *config = &connector->dev->mode_config;
-
 
996
 
-
 
997
	WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
-
 
998
 
-
 
999
	drm_for_each_connector(tmp, connector->dev) {
-
 
1000
		if (tmp == connector)
-
 
1001
			return index;
-
 
1002
 
-
 
1003
		index++;
-
 
1004
	}
-
 
1005
 
-
 
1006
	BUG();
-
 
1007
}
-
 
1008
EXPORT_SYMBOL(drm_connector_index);
-
 
1009
 
-
 
1010
/**
1030
/**
1011
 * drm_connector_register - register a connector
1031
 * drm_connector_register - register a connector
1012
 * @connector: the connector to register
1032
 * @connector: the connector to register
1013
 *
1033
 *
1014
 * Register userspace interfaces for a connector
1034
 * Register userspace interfaces for a connector
Line 1073... Line 1093...
1073
 * drm_encoder_init - Init a preallocated encoder
1093
 * drm_encoder_init - Init a preallocated encoder
1074
 * @dev: drm device
1094
 * @dev: drm device
1075
 * @encoder: the encoder to init
1095
 * @encoder: the encoder to init
1076
 * @funcs: callbacks for this encoder
1096
 * @funcs: callbacks for this encoder
1077
 * @encoder_type: user visible type of the encoder
1097
 * @encoder_type: user visible type of the encoder
-
 
1098
 * @name: printf style format string for the encoder name, or NULL for default name
1078
 *
1099
 *
1079
 * Initialises a preallocated encoder. Encoder should be
1100
 * Initialises a preallocated encoder. Encoder should be
1080
 * subclassed as part of driver encoder objects.
1101
 * subclassed as part of driver encoder objects.
1081
 *
1102
 *
1082
 * Returns:
1103
 * Returns:
1083
 * Zero on success, error code on failure.
1104
 * Zero on success, error code on failure.
1084
 */
1105
 */
1085
int drm_encoder_init(struct drm_device *dev,
1106
int drm_encoder_init(struct drm_device *dev,
1086
		      struct drm_encoder *encoder,
1107
		      struct drm_encoder *encoder,
1087
		      const struct drm_encoder_funcs *funcs,
1108
		      const struct drm_encoder_funcs *funcs,
1088
		      int encoder_type)
1109
		      int encoder_type, const char *name, ...)
1089
{
1110
{
1090
	int ret;
1111
	int ret;
Line 1091... Line 1112...
1091
 
1112
 
Line 1096... Line 1117...
1096
		goto out_unlock;
1117
		goto out_unlock;
Line 1097... Line 1118...
1097
 
1118
 
1098
	encoder->dev = dev;
1119
	encoder->dev = dev;
1099
	encoder->encoder_type = encoder_type;
1120
	encoder->encoder_type = encoder_type;
-
 
1121
	encoder->funcs = funcs;
-
 
1122
	if (name) {
-
 
1123
		va_list ap;
-
 
1124
 
-
 
1125
		va_start(ap, name);
-
 
1126
		encoder->name = kvasprintf(GFP_KERNEL, name, ap);
-
 
1127
		va_end(ap);
1100
	encoder->funcs = funcs;
1128
	} else {
1101
	encoder->name = kasprintf(GFP_KERNEL, "%s-%d",
1129
	encoder->name = kasprintf(GFP_KERNEL, "%s-%d",
1102
				  drm_encoder_enum_list[encoder_type].name,
1130
				  drm_encoder_enum_list[encoder_type].name,
-
 
1131
				  encoder->base.id);
1103
				  encoder->base.id);
1132
	}
1104
	if (!encoder->name) {
1133
	if (!encoder->name) {
1105
		ret = -ENOMEM;
1134
		ret = -ENOMEM;
1106
		goto out_put;
1135
		goto out_put;
Line 1139... Line 1168...
1139
 
1168
 
1140
	memset(encoder, 0, sizeof(*encoder));
1169
	memset(encoder, 0, sizeof(*encoder));
1141
}
1170
}
Line -... Line 1171...
-
 
1171
EXPORT_SYMBOL(drm_encoder_cleanup);
-
 
1172
 
-
 
1173
static unsigned int drm_num_planes(struct drm_device *dev)
-
 
1174
{
-
 
1175
	unsigned int num = 0;
-
 
1176
	struct drm_plane *tmp;
-
 
1177
 
-
 
1178
	drm_for_each_plane(tmp, dev) {
-
 
1179
		num++;
-
 
1180
	}
-
 
1181
 
-
 
1182
	return num;
1142
EXPORT_SYMBOL(drm_encoder_cleanup);
1183
}
1143
 
1184
 
1144
/**
1185
/**
1145
 * drm_universal_plane_init - Initialize a new universal plane object
1186
 * drm_universal_plane_init - Initialize a new universal plane object
1146
 * @dev: DRM device
1187
 * @dev: DRM device
1147
 * @plane: plane object to init
1188
 * @plane: plane object to init
1148
 * @possible_crtcs: bitmask of possible CRTCs
1189
 * @possible_crtcs: bitmask of possible CRTCs
1149
 * @funcs: callbacks for the new plane
1190
 * @funcs: callbacks for the new plane
1150
 * @formats: array of supported formats (%DRM_FORMAT_*)
1191
 * @formats: array of supported formats (%DRM_FORMAT_*)
-
 
1192
 * @format_count: number of elements in @formats
1151
 * @format_count: number of elements in @formats
1193
 * @type: type of plane (overlay, primary, cursor)
1152
 * @type: type of plane (overlay, primary, cursor)
1194
 * @name: printf style format string for the plane name, or NULL for default name
1153
 *
1195
 *
1154
 * Initializes a plane object of type @type.
1196
 * Initializes a plane object of type @type.
1155
 *
1197
 *
1156
 * Returns:
1198
 * Returns:
1157
 * Zero on success, error code on failure.
1199
 * Zero on success, error code on failure.
1158
 */
1200
 */
1159
int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
1201
int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
1160
			     unsigned long possible_crtcs,
1202
			     unsigned long possible_crtcs,
1161
			     const struct drm_plane_funcs *funcs,
1203
			     const struct drm_plane_funcs *funcs,
-
 
1204
			     const uint32_t *formats, unsigned int format_count,
1162
			     const uint32_t *formats, unsigned int format_count,
1205
			     enum drm_plane_type type,
1163
			     enum drm_plane_type type)
1206
			     const char *name, ...)
1164
{
1207
{
Line 1165... Line 1208...
1165
	struct drm_mode_config *config = &dev->mode_config;
1208
	struct drm_mode_config *config = &dev->mode_config;
Line 1180... Line 1223...
1180
		DRM_DEBUG_KMS("out of memory when allocating plane\n");
1223
		DRM_DEBUG_KMS("out of memory when allocating plane\n");
1181
		drm_mode_object_put(dev, &plane->base);
1224
		drm_mode_object_put(dev, &plane->base);
1182
		return -ENOMEM;
1225
		return -ENOMEM;
1183
	}
1226
	}
Line -... Line 1227...
-
 
1227
 
-
 
1228
	if (name) {
-
 
1229
		va_list ap;
-
 
1230
 
-
 
1231
		va_start(ap, name);
-
 
1232
		plane->name = kvasprintf(GFP_KERNEL, name, ap);
-
 
1233
		va_end(ap);
-
 
1234
	} else {
-
 
1235
		plane->name = kasprintf(GFP_KERNEL, "plane-%d",
-
 
1236
					drm_num_planes(dev));
-
 
1237
	}
-
 
1238
	if (!plane->name) {
-
 
1239
		kfree(plane->format_types);
-
 
1240
		drm_mode_object_put(dev, &plane->base);
-
 
1241
		return -ENOMEM;
-
 
1242
	}
1184
 
1243
 
1185
	memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
1244
	memcpy(plane->format_types, formats, format_count * sizeof(uint32_t));
1186
	plane->format_count = format_count;
1245
	plane->format_count = format_count;
1187
	plane->possible_crtcs = possible_crtcs;
1246
	plane->possible_crtcs = possible_crtcs;
Line 1238... Line 1297...
1238
{
1297
{
1239
	enum drm_plane_type type;
1298
	enum drm_plane_type type;
Line 1240... Line 1299...
1240
 
1299
 
1241
	type = is_primary ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
1300
	type = is_primary ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
1242
	return drm_universal_plane_init(dev, plane, possible_crtcs, funcs,
1301
	return drm_universal_plane_init(dev, plane, possible_crtcs, funcs,
1243
					formats, format_count, type);
1302
					formats, format_count, type, NULL);
1244
}
1303
}
Line 1245... Line 1304...
1245
EXPORT_SYMBOL(drm_plane_init);
1304
EXPORT_SYMBOL(drm_plane_init);
1246
 
1305
 
Line 1270... Line 1329...
1270
 
1329
 
1271
	WARN_ON(plane->state && !plane->funcs->atomic_destroy_state);
1330
	WARN_ON(plane->state && !plane->funcs->atomic_destroy_state);
1272
	if (plane->state && plane->funcs->atomic_destroy_state)
1331
	if (plane->state && plane->funcs->atomic_destroy_state)
Line -... Line 1332...
-
 
1332
		plane->funcs->atomic_destroy_state(plane, plane->state);
-
 
1333
 
1273
		plane->funcs->atomic_destroy_state(plane, plane->state);
1334
	kfree(plane->name);
1274
 
1335
 
1275
	memset(plane, 0, sizeof(*plane));
1336
	memset(plane, 0, sizeof(*plane));
Line 1276... Line 1337...
1276
}
1337
}
Line 1800... Line 1861...
1800
	/* CRTCs */
1861
	/* CRTCs */
1801
	if (card_res->count_crtcs >= crtc_count) {
1862
	if (card_res->count_crtcs >= crtc_count) {
1802
		copied = 0;
1863
		copied = 0;
1803
		crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr;
1864
		crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr;
1804
		drm_for_each_crtc(crtc, dev) {
1865
		drm_for_each_crtc(crtc, dev) {
1805
			DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
1866
			DRM_DEBUG_KMS("[CRTC:%d:%s]\n",
-
 
1867
				      crtc->base.id, crtc->name);
1806
			if (put_user(crtc->base.id, crtc_id + copied)) {
1868
			if (put_user(crtc->base.id, crtc_id + copied)) {
1807
				ret = -EFAULT;
1869
				ret = -EFAULT;
1808
				goto out;
1870
				goto out;
1809
			}
1871
			}
1810
			copied++;
1872
			copied++;
Line 2647... Line 2709...
2647
	if (!crtc) {
2709
	if (!crtc) {
2648
		DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id);
2710
		DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id);
2649
		ret = -ENOENT;
2711
		ret = -ENOENT;
2650
		goto out;
2712
		goto out;
2651
	}
2713
	}
2652
	DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
2714
	DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
Line 2653... Line 2715...
2653
 
2715
 
2654
	if (crtc_req->mode_valid) {
2716
	if (crtc_req->mode_valid) {
2655
		/* If we have a mode we need a framebuffer. */
2717
		/* If we have a mode we need a framebuffer. */
2656
		/* If we pass -1, set the mode with the currently bound fb */
2718
		/* If we pass -1, set the mode with the currently bound fb */
Line 2683... Line 2745...
2683
		if (ret) {
2745
		if (ret) {
2684
			DRM_DEBUG_KMS("Invalid mode\n");
2746
			DRM_DEBUG_KMS("Invalid mode\n");
2685
			goto out;
2747
			goto out;
2686
		}
2748
		}
Line -... Line 2749...
-
 
2749
 
-
 
2750
		drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
2687
 
2751
 
2688
		/*
2752
		/*
2689
		 * Check whether the primary plane supports the fb pixel format.
2753
		 * Check whether the primary plane supports the fb pixel format.
2690
		 * Drivers not implementing the universal planes API use a
2754
		 * Drivers not implementing the universal planes API use a
2691
		 * default formats list provided by the DRM core which doesn't
2755
		 * default formats list provided by the DRM core which doesn't
Line 3142... Line 3206...
3142
	return 0;
3206
	return 0;
3143
}
3207
}
Line 3144... Line 3208...
3144
 
3208
 
3145
static struct drm_framebuffer *
3209
static struct drm_framebuffer *
3146
internal_framebuffer_create(struct drm_device *dev,
3210
internal_framebuffer_create(struct drm_device *dev,
3147
			    struct drm_mode_fb_cmd2 *r,
3211
			    const struct drm_mode_fb_cmd2 *r,
3148
			    struct drm_file *file_priv)
3212
			    struct drm_file *file_priv)
3149
{
3213
{
3150
	struct drm_mode_config *config = &dev->mode_config;
3214
	struct drm_mode_config *config = &dev->mode_config;
3151
	struct drm_framebuffer *fb;
3215
	struct drm_framebuffer *fb;
Line 3416... Line 3480...
3416
	drm_framebuffer_unreference(fb);
3480
	drm_framebuffer_unreference(fb);
Line 3417... Line 3481...
3417
 
3481
 
3418
	return ret;
3482
	return ret;
Line -... Line 3483...
-
 
3483
}
3419
}
3484
 
3420
 
3485
 
3421
/**
3486
/**
3422
 * drm_fb_release - remove and free the FBs on this file
3487
 * drm_fb_release - remove and free the FBs on this file
3423
 * @priv: drm file for the ioctl
3488
 * @priv: drm file for the ioctl
Line 4563... Line 4628...
4563
	int ret = -EINVAL;
4628
	int ret = -EINVAL;
4564
	struct drm_connector *connector = obj_to_connector(obj);
4629
	struct drm_connector *connector = obj_to_connector(obj);
Line 4565... Line 4630...
4565
 
4630
 
4566
	/* Do DPMS ourselves */
4631
	/* Do DPMS ourselves */
4567
	if (property == connector->dev->mode_config.dpms_property) {
-
 
4568
		ret = 0;
-
 
4569
		if (connector->funcs->dpms)
4632
	if (property == connector->dev->mode_config.dpms_property) {
4570
			ret = (*connector->funcs->dpms)(connector, (int)value);
4633
			ret = (*connector->funcs->dpms)(connector, (int)value);
4571
	} else if (connector->funcs->set_property)
4634
	} else if (connector->funcs->set_property)
Line 4572... Line 4635...
4572
		ret = connector->funcs->set_property(connector, property, value);
4635
		ret = connector->funcs->set_property(connector, property, value);
Line 4763... Line 4826...
4763
int drm_mode_connector_attach_encoder(struct drm_connector *connector,
4826
int drm_mode_connector_attach_encoder(struct drm_connector *connector,
4764
				      struct drm_encoder *encoder)
4827
				      struct drm_encoder *encoder)
4765
{
4828
{
4766
	int i;
4829
	int i;
Line -... Line 4830...
-
 
4830
 
-
 
4831
	/*
-
 
4832
	 * In the past, drivers have attempted to model the static association
-
 
4833
	 * of connector to encoder in simple connector/encoder devices using a
-
 
4834
	 * direct assignment of connector->encoder = encoder. This connection
-
 
4835
	 * is a logical one and the responsibility of the core, so drivers are
-
 
4836
	 * expected not to mess with this.
-
 
4837
	 *
-
 
4838
	 * Note that the error return should've been enough here, but a large
-
 
4839
	 * majority of drivers ignores the return value, so add in a big WARN
-
 
4840
	 * to get people's attention.
-
 
4841
	 */
-
 
4842
	if (WARN_ON(connector->encoder))
-
 
4843
		return -EINVAL;
4767
 
4844
 
4768
	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
4845
	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
4769
		if (connector->encoder_ids[i] == 0) {
4846
		if (connector->encoder_ids[i] == 0) {
4770
			connector->encoder_ids[i] = encoder->base.id;
4847
			connector->encoder_ids[i] = encoder->base.id;
4771
			return 0;
4848
			return 0;
Line 5243... Line 5320...
5243
	INIT_LIST_HEAD(&dev->mode_config.property_list);
5320
	INIT_LIST_HEAD(&dev->mode_config.property_list);
5244
	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
5321
	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
5245
	INIT_LIST_HEAD(&dev->mode_config.plane_list);
5322
	INIT_LIST_HEAD(&dev->mode_config.plane_list);
5246
	idr_init(&dev->mode_config.crtc_idr);
5323
	idr_init(&dev->mode_config.crtc_idr);
5247
	idr_init(&dev->mode_config.tile_idr);
5324
	idr_init(&dev->mode_config.tile_idr);
-
 
5325
	ida_init(&dev->mode_config.connector_ida);
Line 5248... Line 5326...
5248
 
5326
 
5249
	drm_modeset_lock_all(dev);
5327
	drm_modeset_lock_all(dev);
5250
	drm_mode_create_standard_properties(dev);
5328
	drm_mode_create_standard_properties(dev);
Line 5323... Line 5401...
5323
 
5401
 
5324
	list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) {
5402
	list_for_each_entry_safe(crtc, ct, &dev->mode_config.crtc_list, head) {
5325
		crtc->funcs->destroy(crtc);
5403
		crtc->funcs->destroy(crtc);
Line -... Line 5404...
-
 
5404
	}
5326
	}
5405
 
5327
 
5406
	ida_destroy(&dev->mode_config.connector_ida);
5328
	idr_destroy(&dev->mode_config.tile_idr);
5407
	idr_destroy(&dev->mode_config.tile_idr);
5329
	idr_destroy(&dev->mode_config.crtc_idr);
5408
	idr_destroy(&dev->mode_config.crtc_idr);
5330
	drm_modeset_lock_fini(&dev->mode_config.connection_mutex);
5409
	drm_modeset_lock_fini(&dev->mode_config.connection_mutex);