Subversion Repositories Kolibri OS

Rev

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

Rev 4075 Rev 4104
Line 119... Line 119...
119
	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
119
	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
120
	{ DRM_MODE_SCALE_CENTER, "Center" },
120
	{ DRM_MODE_SCALE_CENTER, "Center" },
121
	{ DRM_MODE_SCALE_ASPECT, "Full aspect" },
121
	{ DRM_MODE_SCALE_ASPECT, "Full aspect" },
122
};
122
};
Line 123... Line -...
123
 
-
 
124
static const struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
-
 
125
{
-
 
126
	{ DRM_MODE_DITHERING_OFF, "Off" },
-
 
127
	{ DRM_MODE_DITHERING_ON, "On" },
-
 
128
	{ DRM_MODE_DITHERING_AUTO, "Automatic" },
-
 
129
};
-
 
130
 
123
 
131
/*
124
/*
132
 * Non-global properties, but "required" for certain connectors.
125
 * Non-global properties, but "required" for certain connectors.
133
 */
126
 */
134
static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
127
static const struct drm_prop_enum_list drm_dvi_i_select_enum_list[] =
Line 180... Line 173...
180
};
173
};
Line 181... Line 174...
181
 
174
 
182
struct drm_conn_prop_enum_list {
175
struct drm_conn_prop_enum_list {
183
	int type;
176
	int type;
184
	const char *name;
177
	const char *name;
185
	int count;
178
	struct ida ida;
Line 186... Line 179...
186
};
179
};
187
 
180
 
188
/*
181
/*
189
 * Connector and encoder types.
182
 * Connector and encoder types.
190
 */
183
 */
191
static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
184
static struct drm_conn_prop_enum_list drm_connector_enum_list[] =
192
{	{ DRM_MODE_CONNECTOR_Unknown, "Unknown", 0 },
185
{	{ DRM_MODE_CONNECTOR_Unknown, "Unknown" },
193
	{ DRM_MODE_CONNECTOR_VGA, "VGA", 0 },
186
	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
194
	{ DRM_MODE_CONNECTOR_DVII, "DVI-I", 0 },
187
	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
195
	{ DRM_MODE_CONNECTOR_DVID, "DVI-D", 0 },
188
	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
196
	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A", 0 },
189
	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
197
	{ DRM_MODE_CONNECTOR_Composite, "Composite", 0 },
190
	{ DRM_MODE_CONNECTOR_Composite, "Composite" },
198
	{ DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO", 0 },
191
	{ DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO" },
199
	{ DRM_MODE_CONNECTOR_LVDS, "LVDS", 0 },
192
	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
200
	{ DRM_MODE_CONNECTOR_Component, "Component", 0 },
193
	{ DRM_MODE_CONNECTOR_Component, "Component" },
201
	{ DRM_MODE_CONNECTOR_9PinDIN, "DIN", 0 },
194
	{ DRM_MODE_CONNECTOR_9PinDIN, "DIN" },
202
	{ DRM_MODE_CONNECTOR_DisplayPort, "DP", 0 },
195
	{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
203
	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A", 0 },
196
	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
204
	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B", 0 },
197
	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
205
	{ DRM_MODE_CONNECTOR_TV, "TV", 0 },
198
	{ DRM_MODE_CONNECTOR_TV, "TV" },
206
	{ DRM_MODE_CONNECTOR_eDP, "eDP", 0 },
199
	{ DRM_MODE_CONNECTOR_eDP, "eDP" },
Line 207... Line 200...
207
	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual", 0},
200
	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
208
};
201
};
209
 
202
 
Line 214... Line 207...
214
	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
207
	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
215
	{ DRM_MODE_ENCODER_TVDAC, "TV" },
208
	{ DRM_MODE_ENCODER_TVDAC, "TV" },
216
	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
209
	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
217
};
210
};
Line -... Line 211...
-
 
211
 
-
 
212
void drm_connector_ida_init(void)
-
 
213
{
-
 
214
	int i;
-
 
215
 
-
 
216
	for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++)
-
 
217
		ida_init(&drm_connector_enum_list[i].ida);
-
 
218
}
-
 
219
 
-
 
220
void drm_connector_ida_destroy(void)
-
 
221
{
-
 
222
	int i;
-
 
223
 
-
 
224
	for (i = 0; i < ARRAY_SIZE(drm_connector_enum_list); i++)
-
 
225
		ida_destroy(&drm_connector_enum_list[i].ida);
-
 
226
}
218
 
227
 
219
const char *drm_get_encoder_name(const struct drm_encoder *encoder)
228
const char *drm_get_encoder_name(const struct drm_encoder *encoder)
220
{
229
{
Line 221... Line 230...
221
	static char buf[32];
230
	static char buf[32];
Line 671... Line 680...
671
{
680
{
672
	list_add_tail(&mode->head, &connector->probed_modes);
681
	list_add_tail(&mode->head, &connector->probed_modes);
673
}
682
}
674
EXPORT_SYMBOL(drm_mode_probed_add);
683
EXPORT_SYMBOL(drm_mode_probed_add);
Line 675... Line 684...
675
 
684
 
676
/**
685
/*
677
 * drm_mode_remove - remove and free a mode
686
 * drm_mode_remove - remove and free a mode
678
 * @connector: connector list to modify
687
 * @connector: connector list to modify
679
 * @mode: mode to remove
688
 * @mode: mode to remove
680
 *
689
 *
681
 * Remove @mode from @connector's mode list, then free it.
690
 * Remove @mode from @connector's mode list, then free it.
682
 */
691
 */
683
void drm_mode_remove(struct drm_connector *connector,
692
static void drm_mode_remove(struct drm_connector *connector,
684
		     struct drm_display_mode *mode)
693
		     struct drm_display_mode *mode)
685
{
694
{
686
	list_del(&mode->head);
695
	list_del(&mode->head);
687
	drm_mode_destroy(connector->dev, mode);
696
	drm_mode_destroy(connector->dev, mode);
688
}
-
 
Line 689... Line 697...
689
EXPORT_SYMBOL(drm_mode_remove);
697
}
690
 
698
 
691
/**
699
/**
692
 * drm_connector_init - Init a preallocated connector
700
 * drm_connector_init - Init a preallocated connector
Line 705... Line 713...
705
		     struct drm_connector *connector,
713
		     struct drm_connector *connector,
706
		     const struct drm_connector_funcs *funcs,
714
		     const struct drm_connector_funcs *funcs,
707
		     int connector_type)
715
		     int connector_type)
708
{
716
{
709
	int ret;
717
	int ret;
-
 
718
	struct ida *connector_ida =
-
 
719
		&drm_connector_enum_list[connector_type].ida;
Line 710... Line 720...
710
 
720
 
Line 711... Line 721...
711
	drm_modeset_lock_all(dev);
721
	drm_modeset_lock_all(dev);
712
 
722
 
Line 717... Line 727...
717
	connector->base.properties = &connector->properties;
727
	connector->base.properties = &connector->properties;
718
	connector->dev = dev;
728
	connector->dev = dev;
719
	connector->funcs = funcs;
729
	connector->funcs = funcs;
720
	connector->connector_type = connector_type;
730
	connector->connector_type = connector_type;
721
	connector->connector_type_id =
731
	connector->connector_type_id =
-
 
732
		ida_simple_get(connector_ida, 1, 0, GFP_KERNEL);
722
		++drm_connector_enum_list[connector_type].count; /* TODO */
733
	if (connector->connector_type_id < 0) {
-
 
734
		ret = connector->connector_type_id;
-
 
735
		drm_mode_object_put(dev, &connector->base);
-
 
736
		goto out;
-
 
737
	}
723
	INIT_LIST_HEAD(&connector->probed_modes);
738
	INIT_LIST_HEAD(&connector->probed_modes);
724
	INIT_LIST_HEAD(&connector->modes);
739
	INIT_LIST_HEAD(&connector->modes);
725
	connector->edid_blob_ptr = NULL;
740
	connector->edid_blob_ptr = NULL;
726
	connector->status = connector_status_unknown;
741
	connector->status = connector_status_unknown;
Line 758... Line 773...
758
		drm_mode_remove(connector, mode);
773
		drm_mode_remove(connector, mode);
Line 759... Line 774...
759
 
774
 
760
	list_for_each_entry_safe(mode, t, &connector->modes, head)
775
	list_for_each_entry_safe(mode, t, &connector->modes, head)
Line -... Line 776...
-
 
776
		drm_mode_remove(connector, mode);
-
 
777
 
-
 
778
	ida_remove(&drm_connector_enum_list[connector->connector_type].ida,
761
		drm_mode_remove(connector, mode);
779
		   connector->connector_type_id);
762
 
780
 
763
	drm_mode_object_put(dev, &connector->base);
781
	drm_mode_object_put(dev, &connector->base);
764
	list_del(&connector->head);
782
	list_del(&connector->head);
765
	dev->mode_config.num_connector--;
783
	dev->mode_config.num_connector--;
Line 775... Line 793...
775
//       drm_sysfs_connector_remove(connector);
793
//       drm_sysfs_connector_remove(connector);
Line 776... Line 794...
776
 
794
 
777
}
795
}
Line -... Line 796...
-
 
796
EXPORT_SYMBOL(drm_connector_unplug_all);
-
 
797
 
-
 
798
int drm_bridge_init(struct drm_device *dev, struct drm_bridge *bridge,
-
 
799
		const struct drm_bridge_funcs *funcs)
-
 
800
{
-
 
801
	int ret;
-
 
802
 
-
 
803
	drm_modeset_lock_all(dev);
-
 
804
 
-
 
805
	ret = drm_mode_object_get(dev, &bridge->base, DRM_MODE_OBJECT_BRIDGE);
-
 
806
	if (ret)
-
 
807
		goto out;
-
 
808
 
-
 
809
	bridge->dev = dev;
-
 
810
	bridge->funcs = funcs;
-
 
811
 
-
 
812
	list_add_tail(&bridge->head, &dev->mode_config.bridge_list);
-
 
813
	dev->mode_config.num_bridge++;
-
 
814
 
-
 
815
 out:
-
 
816
	drm_modeset_unlock_all(dev);
-
 
817
	return ret;
-
 
818
}
-
 
819
EXPORT_SYMBOL(drm_bridge_init);
-
 
820
 
-
 
821
void drm_bridge_cleanup(struct drm_bridge *bridge)
-
 
822
{
-
 
823
	struct drm_device *dev = bridge->dev;
-
 
824
 
-
 
825
	drm_modeset_lock_all(dev);
-
 
826
	drm_mode_object_put(dev, &bridge->base);
-
 
827
	list_del(&bridge->head);
-
 
828
	dev->mode_config.num_bridge--;
-
 
829
	drm_modeset_unlock_all(dev);
-
 
830
}
778
EXPORT_SYMBOL(drm_connector_unplug_all);
831
EXPORT_SYMBOL(drm_bridge_cleanup);
779
 
832
 
780
int drm_encoder_init(struct drm_device *dev,
833
int drm_encoder_init(struct drm_device *dev,
781
		      struct drm_encoder *encoder,
834
		      struct drm_encoder *encoder,
782
		      const struct drm_encoder_funcs *funcs,
835
		      const struct drm_encoder_funcs *funcs,
Line 1129... Line 1182...
1129
	return 0;
1182
	return 0;
1130
}
1183
}
1131
EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
1184
EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
Line 1132... Line 1185...
1132
 
1185
 
1133
/**
-
 
1134
 * drm_mode_create_dithering_property - create dithering property
-
 
1135
 * @dev: DRM device
-
 
1136
 *
-
 
1137
 * Called by a driver the first time it's needed, must be attached to desired
-
 
1138
 * connectors.
-
 
1139
 */
-
 
1140
int drm_mode_create_dithering_property(struct drm_device *dev)
-
 
1141
{
-
 
1142
	struct drm_property *dithering_mode;
-
 
1143
 
-
 
1144
	if (dev->mode_config.dithering_mode_property)
-
 
1145
		return 0;
-
 
1146
 
-
 
1147
	dithering_mode =
-
 
1148
		drm_property_create_enum(dev, 0, "dithering",
-
 
1149
				drm_dithering_mode_enum_list,
-
 
1150
				    ARRAY_SIZE(drm_dithering_mode_enum_list));
-
 
1151
	dev->mode_config.dithering_mode_property = dithering_mode;
-
 
1152
 
-
 
1153
	return 0;
-
 
1154
}
-
 
1155
EXPORT_SYMBOL(drm_mode_create_dithering_property);
-
 
1156
 
-
 
1157
/**
1186
/**
1158
 * drm_mode_create_dirty_property - create dirty property
1187
 * drm_mode_create_dirty_property - create dirty property
1159
 * @dev: DRM device
1188
 * @dev: DRM device
1160
 *
1189
 *
1161
 * Called by a driver the first time it's needed, must be attached to desired
1190
 * Called by a driver the first time it's needed, must be attached to desired
Line 1184... Line 1213...
1184
	uint32_t total_objects = 0;
1213
	uint32_t total_objects = 0;
Line 1185... Line 1214...
1185
 
1214
 
1186
	total_objects += dev->mode_config.num_crtc;
1215
	total_objects += dev->mode_config.num_crtc;
1187
	total_objects += dev->mode_config.num_connector;
1216
	total_objects += dev->mode_config.num_connector;
-
 
1217
	total_objects += dev->mode_config.num_encoder;
Line 1188... Line 1218...
1188
	total_objects += dev->mode_config.num_encoder;
1218
	total_objects += dev->mode_config.num_bridge;
1189
 
1219
 
1190
	group->id_list = kzalloc(total_objects * sizeof(uint32_t), GFP_KERNEL);
1220
	group->id_list = kzalloc(total_objects * sizeof(uint32_t), GFP_KERNEL);
Line 1191... Line 1221...
1191
	if (!group->id_list)
1221
	if (!group->id_list)
1192
		return -ENOMEM;
1222
		return -ENOMEM;
1193
 
1223
 
-
 
1224
	group->num_crtcs = 0;
1194
	group->num_crtcs = 0;
1225
	group->num_connectors = 0;
1195
	group->num_connectors = 0;
1226
	group->num_encoders = 0;
Line 1196... Line 1227...
1196
	group->num_encoders = 0;
1227
	group->num_bridges = 0;
1197
	return 0;
1228
	return 0;
1198
}
1229
}
1199
 
1230
 
1200
int drm_mode_group_init_legacy_group(struct drm_device *dev,
1231
int drm_mode_group_init_legacy_group(struct drm_device *dev,
1201
				     struct drm_mode_group *group)
1232
				     struct drm_mode_group *group)
-
 
1233
{
1202
{
1234
	struct drm_crtc *crtc;
Line 1203... Line 1235...
1203
	struct drm_crtc *crtc;
1235
	struct drm_encoder *encoder;
1204
	struct drm_encoder *encoder;
1236
	struct drm_connector *connector;
Line 1217... Line 1249...
1217
 
1249
 
1218
	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
1250
	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
1219
		group->id_list[group->num_crtcs + group->num_encoders +
1251
		group->id_list[group->num_crtcs + group->num_encoders +
Line -... Line 1252...
-
 
1252
			       group->num_connectors++] = connector->base.id;
-
 
1253
 
-
 
1254
	list_for_each_entry(bridge, &dev->mode_config.bridge_list, head)
-
 
1255
		group->id_list[group->num_crtcs + group->num_encoders +
-
 
1256
			       group->num_connectors + group->num_bridges++] =
1220
			       group->num_connectors++] = connector->base.id;
1257
					bridge->base.id;
1221
 
1258
 
1222
	return 0;
1259
	return 0;
Line 1223... Line 1260...
1223
}
1260
}
Line 2602... Line 2639...
2602
	r->height = fb->height;
2639
	r->height = fb->height;
2603
	r->width = fb->width;
2640
	r->width = fb->width;
2604
	r->depth = fb->depth;
2641
	r->depth = fb->depth;
2605
	r->bpp = fb->bits_per_pixel;
2642
	r->bpp = fb->bits_per_pixel;
2606
	r->pitch = fb->pitches[0];
2643
	r->pitch = fb->pitches[0];
2607
	if (fb->funcs->create_handle)
2644
	if (fb->funcs->create_handle) {
-
 
2645
		if (file_priv->is_master || capable(CAP_SYS_ADMIN)) {
2608
		ret = fb->funcs->create_handle(fb, file_priv, &r->handle);
2646
			ret = fb->funcs->create_handle(fb, file_priv,
-
 
2647
						       &r->handle);
-
 
2648
		} else {
-
 
2649
			/* GET_FB() is an unprivileged ioctl so we must not
-
 
2650
			 * return a buffer-handle to non-master processes! For
-
 
2651
			 * backwards-compatibility reasons, we cannot make
-
 
2652
			 * GET_FB() privileged, so just return an invalid handle
-
 
2653
			 * for non-masters. */
-
 
2654
			r->handle = 0;
-
 
2655
			ret = 0;
-
 
2656
		}
2609
	else
2657
	} else {
2610
		ret = -ENODEV;
2658
		ret = -ENODEV;
-
 
2659
	}
Line 2611... Line 2660...
2611
 
2660
 
Line 2612... Line 2661...
2612
	drm_framebuffer_unreference(fb);
2661
	drm_framebuffer_unreference(fb);
2613
 
2662
 
Line 3719... Line 3768...
3719
	mutex_init(&dev->mode_config.idr_mutex);
3768
	mutex_init(&dev->mode_config.idr_mutex);
3720
	mutex_init(&dev->mode_config.fb_lock);
3769
	mutex_init(&dev->mode_config.fb_lock);
3721
	INIT_LIST_HEAD(&dev->mode_config.fb_list);
3770
	INIT_LIST_HEAD(&dev->mode_config.fb_list);
3722
	INIT_LIST_HEAD(&dev->mode_config.crtc_list);
3771
	INIT_LIST_HEAD(&dev->mode_config.crtc_list);
3723
	INIT_LIST_HEAD(&dev->mode_config.connector_list);
3772
	INIT_LIST_HEAD(&dev->mode_config.connector_list);
-
 
3773
	INIT_LIST_HEAD(&dev->mode_config.bridge_list);
3724
	INIT_LIST_HEAD(&dev->mode_config.encoder_list);
3774
	INIT_LIST_HEAD(&dev->mode_config.encoder_list);
3725
	INIT_LIST_HEAD(&dev->mode_config.property_list);
3775
	INIT_LIST_HEAD(&dev->mode_config.property_list);
3726
	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
3776
	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
3727
	INIT_LIST_HEAD(&dev->mode_config.plane_list);
3777
	INIT_LIST_HEAD(&dev->mode_config.plane_list);
3728
	idr_init(&dev->mode_config.crtc_idr);
3778
	idr_init(&dev->mode_config.crtc_idr);