Subversion Repositories Kolibri OS

Rev

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

Rev 1126 Rev 1179
Line 27... Line 27...
27
 *      Keith Packard
27
 *      Keith Packard
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 "drm.h"
33
#include "drm.h"
34
#include "drmP.h"
34
#include "drmP.h"
35
#include "drm_crtc.h"
35
#include "drm_crtc.h"
Line 36... Line 36...
36
 
36
 
Line 66... Line 66...
66
/*
66
/*
67
 * Optional properties
67
 * Optional properties
68
 */
68
 */
69
static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
69
static struct drm_prop_enum_list drm_scaling_mode_enum_list[] =
70
{
70
{
71
	{ DRM_MODE_SCALE_NON_GPU, "Non-GPU" },
71
	{ DRM_MODE_SCALE_NONE, "None" },
72
	{ DRM_MODE_SCALE_FULLSCREEN, "Fullscreen" },
72
	{ DRM_MODE_SCALE_FULLSCREEN, "Full" },
73
	{ DRM_MODE_SCALE_NO_SCALE, "No scale" },
73
	{ DRM_MODE_SCALE_CENTER, "Center" },
74
	{ DRM_MODE_SCALE_ASPECT, "Aspect" },
74
	{ DRM_MODE_SCALE_ASPECT, "Full aspect" },
75
};
75
};
Line 76... Line 76...
76
 
76
 
77
static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
77
static struct drm_prop_enum_list drm_dithering_mode_enum_list[] =
78
{
78
{
Line 106... Line 106...
106
{
106
{
107
	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
107
	{ DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */
108
	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
108
	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
109
	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
109
	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
110
	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
110
	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
-
 
111
	{ DRM_MODE_SUBCONNECTOR_SCART,     "SCART"     }, /* TV-out */
111
};
112
};
Line 112... Line 113...
112
 
113
 
Line 113... Line 114...
113
DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
114
DRM_ENUM_NAME_FN(drm_get_tv_select_name, drm_tv_select_enum_list)
114
 
115
 
115
static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
116
static struct drm_prop_enum_list drm_tv_subconnector_enum_list[] =
116
{
117
{
117
	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
118
	{ DRM_MODE_SUBCONNECTOR_Unknown,   "Unknown"   }, /* DVI-I and TV-out */
118
	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
119
	{ DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */
-
 
120
	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
119
	{ DRM_MODE_SUBCONNECTOR_SVIDEO,    "SVIDEO"    }, /* TV-out */
121
	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
Line 120... Line 122...
120
	{ DRM_MODE_SUBCONNECTOR_Component, "Component" }, /* TV-out */
122
	{ DRM_MODE_SUBCONNECTOR_SCART,     "SCART"     }, /* TV-out */
121
};
123
};
Line 144... Line 146...
144
	{ DRM_MODE_CONNECTOR_Component, "Component", 0 },
146
	{ DRM_MODE_CONNECTOR_Component, "Component", 0 },
145
	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN", 0 },
147
	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN", 0 },
146
	{ DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort", 0 },
148
	{ DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort", 0 },
147
	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI Type A", 0 },
149
	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI Type A", 0 },
148
	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI Type B", 0 },
150
	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI Type B", 0 },
-
 
151
	{ DRM_MODE_CONNECTOR_TV, "TV", 0 },
149
};
152
};
Line 150... Line 153...
150
 
153
 
151
static struct drm_prop_enum_list drm_encoder_enum_list[] =
154
static struct drm_prop_enum_list drm_encoder_enum_list[] =
152
{	{ DRM_MODE_ENCODER_NONE, "None" },
155
{	{ DRM_MODE_ENCODER_NONE, "None" },
Line 163... Line 166...
163
	snprintf(buf, 32, "%s-%d",
166
	snprintf(buf, 32, "%s-%d",
164
		 drm_encoder_enum_list[encoder->encoder_type].name,
167
		 drm_encoder_enum_list[encoder->encoder_type].name,
165
		 encoder->base.id);
168
		 encoder->base.id);
166
	return buf;
169
	return buf;
167
}
170
}
-
 
171
EXPORT_SYMBOL(drm_get_encoder_name);
Line 168... Line 172...
168
 
172
 
169
char *drm_get_connector_name(struct drm_connector *connector)
173
char *drm_get_connector_name(struct drm_connector *connector)
170
{
174
{
Line 212... Line 216...
212
	if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) {
216
	if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) {
213
		DRM_ERROR("Ran out memory getting a mode number\n");
217
		DRM_ERROR("Ran out memory getting a mode number\n");
214
		return -EINVAL;
218
		return -EINVAL;
215
	}
219
	}
Line 216... Line 220...
216
 
220
 
217
//   mutex_lock(&dev->mode_config.idr_mutex);
221
	mutex_lock(&dev->mode_config.idr_mutex);
218
	ret = idr_get_new_above(&dev->mode_config.crtc_idr, obj, 1, &new_id);
222
	ret = idr_get_new_above(&dev->mode_config.crtc_idr, obj, 1, &new_id);
219
//   mutex_unlock(&dev->mode_config.idr_mutex);
223
	mutex_unlock(&dev->mode_config.idr_mutex);
220
	if (ret == -EAGAIN)
224
	if (ret == -EAGAIN)
Line 221... Line 225...
221
		goto again;
225
        goto again;
222
 
226
 
223
	obj->id = new_id;
-
 
224
	obj->type = obj_type;
227
	obj->id = new_id;
225
 
228
	obj->type = obj_type;
Line 226... Line 229...
226
	return 0;
229
    return 0;
227
}
230
}
Line 237... Line 240...
237
 * Free @id from @dev's unique identifier pool.
240
 * Free @id from @dev's unique identifier pool.
238
 */
241
 */
239
static void drm_mode_object_put(struct drm_device *dev,
242
static void drm_mode_object_put(struct drm_device *dev,
240
				struct drm_mode_object *object)
243
				struct drm_mode_object *object)
241
{
244
{
242
//   mutex_lock(&dev->mode_config.idr_mutex);
245
	mutex_lock(&dev->mode_config.idr_mutex);
243
	idr_remove(&dev->mode_config.crtc_idr, object->id);
246
	idr_remove(&dev->mode_config.crtc_idr, object->id);
244
//   mutex_unlock(&dev->mode_config.idr_mutex);
247
	mutex_unlock(&dev->mode_config.idr_mutex);
245
}
248
}
Line 246... Line 249...
246
 
249
 
247
void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type)
250
void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type)
248
{
251
{
Line 249... Line 252...
249
	struct drm_mode_object *obj = NULL;
252
	struct drm_mode_object *obj = NULL;
250
 
253
 
251
//   mutex_lock(&dev->mode_config.idr_mutex);
254
	mutex_lock(&dev->mode_config.idr_mutex);
252
	obj = idr_find(&dev->mode_config.crtc_idr, id);
255
	obj = idr_find(&dev->mode_config.crtc_idr, id);
253
	if (!obj || (obj->type != type) || (obj->id != id))
256
	if (!obj || (obj->type != type) || (obj->id != id))
Line 254... Line 257...
254
		obj = NULL;
257
		obj = NULL;
255
//   mutex_unlock(&dev->mode_config.idr_mutex);
258
	mutex_unlock(&dev->mode_config.idr_mutex);
256
 
259
 
Line 257... Line -...
257
	return obj;
-
 
258
}
-
 
259
EXPORT_SYMBOL(drm_mode_object_find);
-
 
260
 
-
 
261
 
-
 
262
/**
-
 
263
 * drm_crtc_from_fb - find the CRTC structure associated with an fb
-
 
264
 * @dev: DRM device
-
 
265
 * @fb: framebuffer in question
-
 
266
 *
-
 
267
 * LOCKING:
-
 
268
 * Caller must hold mode_config lock.
-
 
269
 *
-
 
270
 * Find CRTC in the mode_config structure that matches @fb.
-
 
271
 *
-
 
272
 * RETURNS:
-
 
273
 * Pointer to the CRTC or NULL if it wasn't found.
-
 
274
 */
-
 
275
struct drm_crtc *drm_crtc_from_fb(struct drm_device *dev,
-
 
276
				  struct drm_framebuffer *fb)
-
 
277
{
-
 
278
	struct drm_crtc *crtc;
-
 
279
 
-
 
280
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
 
281
		if (crtc->fb == fb)
-
 
282
			return crtc;
-
 
283
	}
260
	return obj;
284
	return NULL;
261
}
285
}
262
EXPORT_SYMBOL(drm_mode_object_find);
286
 
263
 
287
/**
264
/**
Line 328... Line 305...
328
 */
305
 */
329
void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
306
void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
330
{
307
{
331
	struct drm_device *dev = fb->dev;
308
	struct drm_device *dev = fb->dev;
332
	struct drm_crtc *crtc;
309
	struct drm_crtc *crtc;
-
 
310
	struct drm_mode_set set;
-
 
311
	int ret;
Line 333... Line 312...
333
 
312
 
334
	/* remove from any CRTC */
313
	/* remove from any CRTC */
335
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
314
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-
 
315
		if (crtc->fb == fb) {
-
 
316
			/* should turn off the crtc */
-
 
317
			memset(&set, 0, sizeof(struct drm_mode_set));
336
		if (crtc->fb == fb)
318
			set.crtc = crtc;
-
 
319
			set.fb = NULL;
-
 
320
			ret = crtc->funcs->set_config(&set);
-
 
321
			if (ret)
-
 
322
				DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
337
			crtc->fb = NULL;
323
	   }
Line 338... Line 324...
338
	}
324
	}
339
 
325
 
340
	drm_mode_object_put(dev, &fb->base);
326
	drm_mode_object_put(dev, &fb->base);
341
	list_del(&fb->head);
327
	list_del(&fb->head);
342
	dev->mode_config.num_fb--;
328
	dev->mode_config.num_fb--;
Line 343... Line -...
343
}
-
 
344
EXPORT_SYMBOL(drm_framebuffer_cleanup);
329
}
345
 
330
EXPORT_SYMBOL(drm_framebuffer_cleanup);
346
 
331
 
347
/**
332
/**
348
 * drm_crtc_init - Initialise a new CRTC object
333
 * drm_crtc_init - Initialise a new CRTC object
Line 356... Line 341...
356
 * Inits a new object created as base part of an driver crtc object.
341
 * Inits a new object created as base part of an driver crtc object.
357
 */
342
 */
358
void drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
343
void drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
359
		   const struct drm_crtc_funcs *funcs)
344
		   const struct drm_crtc_funcs *funcs)
360
{
345
{
361
    ENTRY();
-
 
362
 
-
 
363
	crtc->dev = dev;
346
	crtc->dev = dev;
364
	crtc->funcs = funcs;
347
	crtc->funcs = funcs;
Line 365... Line 348...
365
 
348
 
366
//   mutex_lock(&dev->mode_config.mutex);
349
	mutex_lock(&dev->mode_config.mutex);
Line 367... Line 350...
367
	drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC);
350
	drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC);
368
 
351
 
369
	list_add_tail(&crtc->head, &dev->mode_config.crtc_list);
-
 
370
	dev->mode_config.num_crtc++;
352
	list_add_tail(&crtc->head, &dev->mode_config.crtc_list);
371
 
-
 
372
//   mutex_unlock(&dev->mode_config.mutex);
-
 
373
 
353
	dev->mode_config.num_crtc++;
374
    LEAVE();
354
	mutex_unlock(&dev->mode_config.mutex);
Line 375... Line 355...
375
}
355
}
376
EXPORT_SYMBOL(drm_crtc_init);
356
EXPORT_SYMBOL(drm_crtc_init);
Line 451... Line 431...
451
void drm_connector_init(struct drm_device *dev,
431
void drm_connector_init(struct drm_device *dev,
452
		     struct drm_connector *connector,
432
		     struct drm_connector *connector,
453
		     const struct drm_connector_funcs *funcs,
433
		     const struct drm_connector_funcs *funcs,
454
		     int connector_type)
434
		     int connector_type)
455
{
435
{
456
//   mutex_lock(&dev->mode_config.mutex);
436
	mutex_lock(&dev->mode_config.mutex);
Line 457... Line 437...
457
 
437
 
458
	connector->dev = dev;
438
	connector->dev = dev;
459
	connector->funcs = funcs;
439
	connector->funcs = funcs;
460
	drm_mode_object_get(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR);
440
	drm_mode_object_get(dev, &connector->base, DRM_MODE_OBJECT_CONNECTOR);
Line 473... Line 453...
473
				      dev->mode_config.edid_property, 0);
453
				      dev->mode_config.edid_property, 0);
Line 474... Line 454...
474
 
454
 
475
	drm_connector_attach_property(connector,
455
	drm_connector_attach_property(connector,
Line 476... Line 456...
476
				      dev->mode_config.dpms_property, 0);
456
				      dev->mode_config.dpms_property, 0);
477
 
457
 
478
//   mutex_unlock(&dev->mode_config.mutex);
458
	mutex_unlock(&dev->mode_config.mutex);
Line 479... Line 459...
479
}
459
}
480
EXPORT_SYMBOL(drm_connector_init);
460
EXPORT_SYMBOL(drm_connector_init);
Line 500... Line 480...
500
		drm_mode_remove(connector, mode);
480
		drm_mode_remove(connector, mode);
Line 501... Line 481...
501
 
481
 
502
	list_for_each_entry_safe(mode, t, &connector->user_modes, head)
482
	list_for_each_entry_safe(mode, t, &connector->user_modes, head)
Line 503... Line 483...
503
		drm_mode_remove(connector, mode);
483
		drm_mode_remove(connector, mode);
504
 
484
 
505
//   mutex_lock(&dev->mode_config.mutex);
485
	mutex_lock(&dev->mode_config.mutex);
506
	drm_mode_object_put(dev, &connector->base);
486
	drm_mode_object_put(dev, &connector->base);
507
	list_del(&connector->head);
487
	list_del(&connector->head);
508
//   mutex_unlock(&dev->mode_config.mutex);
488
	mutex_unlock(&dev->mode_config.mutex);
Line 509... Line 489...
509
}
489
}
510
EXPORT_SYMBOL(drm_connector_cleanup);
490
EXPORT_SYMBOL(drm_connector_cleanup);
511
 
491
 
512
void drm_encoder_init(struct drm_device *dev,
492
void drm_encoder_init(struct drm_device *dev,
513
		      struct drm_encoder *encoder,
493
		      struct drm_encoder *encoder,
514
		      const struct drm_encoder_funcs *funcs,
494
		      const struct drm_encoder_funcs *funcs,
Line 515... Line 495...
515
		      int encoder_type)
495
		      int encoder_type)
Line 516... Line 496...
516
{
496
{
517
//   mutex_lock(&dev->mode_config.mutex);
497
	mutex_lock(&dev->mode_config.mutex);
518
 
498
 
Line 519... Line 499...
519
	encoder->dev = dev;
499
	encoder->dev = dev;
520
 
500
 
Line 521... Line 501...
521
	drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER);
501
	drm_mode_object_get(dev, &encoder->base, DRM_MODE_OBJECT_ENCODER);
522
	encoder->encoder_type = encoder_type;
502
	encoder->encoder_type = encoder_type;
523
	encoder->funcs = funcs;
503
	encoder->funcs = funcs;
Line 524... Line 504...
524
 
504
 
525
	list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
505
	list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
526
	dev->mode_config.num_encoder++;
506
	dev->mode_config.num_encoder++;
527
 
507
 
528
//   mutex_unlock(&dev->mode_config.mutex);
508
	mutex_unlock(&dev->mode_config.mutex);
529
}
509
}
530
EXPORT_SYMBOL(drm_encoder_init);
510
EXPORT_SYMBOL(drm_encoder_init);
531
 
511
 
532
void drm_encoder_cleanup(struct drm_encoder *encoder)
512
void drm_encoder_cleanup(struct drm_encoder *encoder)
Line 533... Line 513...
533
{
513
{
534
	struct drm_device *dev = encoder->dev;
514
	struct drm_device *dev = encoder->dev;
Line 586... Line 566...
586
{
566
{
587
	struct drm_property *edid;
567
	struct drm_property *edid;
588
	struct drm_property *dpms;
568
	struct drm_property *dpms;
589
	int i;
569
	int i;
Line 590... Line -...
590
 
-
 
591
    ENTRY();
570
 
592
	/*
571
	/*
593
	 * Standard properties (apply to all connectors)
572
	 * Standard properties (apply to all connectors)
594
	 */
573
	 */
595
	edid = drm_property_create(dev, DRM_MODE_PROP_BLOB |
574
	edid = drm_property_create(dev, DRM_MODE_PROP_BLOB |
Line 602... Line 581...
602
	for (i = 0; i < ARRAY_SIZE(drm_dpms_enum_list); i++)
581
	for (i = 0; i < ARRAY_SIZE(drm_dpms_enum_list); i++)
603
		drm_property_add_enum(dpms, i, drm_dpms_enum_list[i].type,
582
		drm_property_add_enum(dpms, i, drm_dpms_enum_list[i].type,
604
				      drm_dpms_enum_list[i].name);
583
				      drm_dpms_enum_list[i].name);
605
	dev->mode_config.dpms_property = dpms;
584
	dev->mode_config.dpms_property = dpms;
Line 606... Line -...
606
 
-
 
607
    LEAVE();
585
 
608
	return 0;
586
	return 0;
Line 609... Line 587...
609
}
587
}
610
 
588
 
Line 723... Line 701...
723
				    "mode", num_modes);
701
				    "mode", num_modes);
724
	for (i = 0; i < num_modes; i++)
702
	for (i = 0; i < num_modes; i++)
725
		drm_property_add_enum(dev->mode_config.tv_mode_property, i,
703
		drm_property_add_enum(dev->mode_config.tv_mode_property, i,
726
				      i, modes[i]);
704
				      i, modes[i]);
Line -... Line 705...
-
 
705
 
-
 
706
	dev->mode_config.tv_brightness_property =
-
 
707
		drm_property_create(dev, DRM_MODE_PROP_RANGE,
-
 
708
				    "brightness", 2);
-
 
709
	dev->mode_config.tv_brightness_property->values[0] = 0;
-
 
710
	dev->mode_config.tv_brightness_property->values[1] = 100;
-
 
711
 
-
 
712
	dev->mode_config.tv_contrast_property =
-
 
713
		drm_property_create(dev, DRM_MODE_PROP_RANGE,
-
 
714
				    "contrast", 2);
-
 
715
	dev->mode_config.tv_contrast_property->values[0] = 0;
-
 
716
	dev->mode_config.tv_contrast_property->values[1] = 100;
-
 
717
 
-
 
718
	dev->mode_config.tv_flicker_reduction_property =
-
 
719
		drm_property_create(dev, DRM_MODE_PROP_RANGE,
-
 
720
				    "flicker reduction", 2);
-
 
721
	dev->mode_config.tv_flicker_reduction_property->values[0] = 0;
-
 
722
	dev->mode_config.tv_flicker_reduction_property->values[1] = 100;
-
 
723
 
-
 
724
	dev->mode_config.tv_overscan_property =
-
 
725
		drm_property_create(dev, DRM_MODE_PROP_RANGE,
-
 
726
				    "overscan", 2);
-
 
727
	dev->mode_config.tv_overscan_property->values[0] = 0;
-
 
728
	dev->mode_config.tv_overscan_property->values[1] = 100;
-
 
729
 
-
 
730
	dev->mode_config.tv_saturation_property =
-
 
731
		drm_property_create(dev, DRM_MODE_PROP_RANGE,
-
 
732
				    "saturation", 2);
-
 
733
	dev->mode_config.tv_saturation_property->values[0] = 0;
-
 
734
	dev->mode_config.tv_saturation_property->values[1] = 100;
-
 
735
 
-
 
736
	dev->mode_config.tv_hue_property =
-
 
737
		drm_property_create(dev, DRM_MODE_PROP_RANGE,
-
 
738
				    "hue", 2);
-
 
739
	dev->mode_config.tv_hue_property->values[0] = 0;
-
 
740
	dev->mode_config.tv_hue_property->values[1] = 100;
727
 
741
 
728
	return 0;
742
	return 0;
729
}
743
}
Line 730... Line 744...
730
EXPORT_SYMBOL(drm_mode_create_tv_properties);
744
EXPORT_SYMBOL(drm_mode_create_tv_properties);
Line 796... Line 810...
796
 * Initialize @dev's mode_config structure, used for tracking the graphics
810
 * Initialize @dev's mode_config structure, used for tracking the graphics
797
 * configuration of @dev.
811
 * configuration of @dev.
798
 */
812
 */
799
void drm_mode_config_init(struct drm_device *dev)
813
void drm_mode_config_init(struct drm_device *dev)
800
{
814
{
801
    ENTRY();
-
 
802
 
-
 
803
//   mutex_init(&dev->mode_config.mutex);
815
//   mutex_init(&dev->mode_config.mutex);
804
//   mutex_init(&dev->mode_config.idr_mutex);
816
//   mutex_init(&dev->mode_config.idr_mutex);
805
	INIT_LIST_HEAD(&dev->mode_config.fb_list);
817
	INIT_LIST_HEAD(&dev->mode_config.fb_list);
806
	INIT_LIST_HEAD(&dev->mode_config.fb_kernel_list);
818
	INIT_LIST_HEAD(&dev->mode_config.fb_kernel_list);
807
	INIT_LIST_HEAD(&dev->mode_config.crtc_list);
819
	INIT_LIST_HEAD(&dev->mode_config.crtc_list);
808
	INIT_LIST_HEAD(&dev->mode_config.connector_list);
820
	INIT_LIST_HEAD(&dev->mode_config.connector_list);
809
	INIT_LIST_HEAD(&dev->mode_config.encoder_list);
821
	INIT_LIST_HEAD(&dev->mode_config.encoder_list);
810
	INIT_LIST_HEAD(&dev->mode_config.property_list);
822
	INIT_LIST_HEAD(&dev->mode_config.property_list);
811
	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
823
	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
812
 
-
 
813
	idr_init(&dev->mode_config.crtc_idr);
824
	idr_init(&dev->mode_config.crtc_idr);
Line 814... Line 825...
814
 
825
 
815
//   mutex_lock(&dev->mode_config.mutex);
826
	mutex_lock(&dev->mode_config.mutex);
816
	drm_mode_create_standard_connector_properties(dev);
827
	drm_mode_create_standard_connector_properties(dev);
Line 817... Line 828...
817
//   mutex_unlock(&dev->mode_config.mutex);
828
	mutex_unlock(&dev->mode_config.mutex);
818
 
829
 
819
	/* Just to be sure */
830
	/* Just to be sure */
820
	dev->mode_config.num_fb = 0;
831
	dev->mode_config.num_fb = 0;
821
	dev->mode_config.num_connector = 0;
832
	dev->mode_config.num_connector = 0;
822
	dev->mode_config.num_crtc = 0;
-
 
823
	dev->mode_config.num_encoder = 0;
-
 
824
 
-
 
825
    LEAVE();
833
	dev->mode_config.num_crtc = 0;
826
 
834
	dev->mode_config.num_encoder = 0;
Line 827... Line 835...
827
}
835
}
828
EXPORT_SYMBOL(drm_mode_config_init);
836
EXPORT_SYMBOL(drm_mode_config_init);
Line 1076... Line 1084...
1076
		copied = 0;
1084
		copied = 0;
1077
		crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr;
1085
		crtc_id = (uint32_t __user *)(unsigned long)card_res->crtc_id_ptr;
1078
		if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
1086
		if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
1079
			list_for_each_entry(crtc, &dev->mode_config.crtc_list,
1087
			list_for_each_entry(crtc, &dev->mode_config.crtc_list,
1080
					    head) {
1088
					    head) {
1081
				DRM_DEBUG("CRTC ID is %d\n", crtc->base.id);
1089
				DRM_DEBUG_KMS("CRTC ID is %d\n", crtc->base.id);
1082
				if (put_user(crtc->base.id, crtc_id + copied)) {
1090
				if (put_user(crtc->base.id, crtc_id + copied)) {
1083
					ret = -EFAULT;
1091
					ret = -EFAULT;
1084
					goto out;
1092
					goto out;
1085
				}
1093
				}
1086
				copied++;
1094
				copied++;
Line 1104... Line 1112...
1104
		encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr;
1112
		encoder_id = (uint32_t __user *)(unsigned long)card_res->encoder_id_ptr;
1105
		if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
1113
		if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
1106
			list_for_each_entry(encoder,
1114
			list_for_each_entry(encoder,
1107
					    &dev->mode_config.encoder_list,
1115
					    &dev->mode_config.encoder_list,
1108
					    head) {
1116
					    head) {
1109
				DRM_DEBUG("ENCODER ID is %d\n",
1117
				DRM_DEBUG_KMS("ENCODER ID is %d\n",
1110
					  encoder->base.id);
1118
					  encoder->base.id);
1111
				if (put_user(encoder->base.id, encoder_id +
1119
				if (put_user(encoder->base.id, encoder_id +
1112
					     copied)) {
1120
					     copied)) {
1113
					ret = -EFAULT;
1121
					ret = -EFAULT;
1114
					goto out;
1122
					goto out;
Line 1135... Line 1143...
1135
		connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr;
1143
		connector_id = (uint32_t __user *)(unsigned long)card_res->connector_id_ptr;
1136
		if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
1144
		if (file_priv->master->minor->type == DRM_MINOR_CONTROL) {
1137
			list_for_each_entry(connector,
1145
			list_for_each_entry(connector,
1138
					    &dev->mode_config.connector_list,
1146
					    &dev->mode_config.connector_list,
1139
					    head) {
1147
					    head) {
1140
				DRM_DEBUG("CONNECTOR ID is %d\n",
1148
				DRM_DEBUG_KMS("CONNECTOR ID is %d\n",
1141
					  connector->base.id);
1149
					  connector->base.id);
1142
				if (put_user(connector->base.id,
1150
				if (put_user(connector->base.id,
1143
					     connector_id + copied)) {
1151
					     connector_id + copied)) {
1144
					ret = -EFAULT;
1152
					ret = -EFAULT;
1145
					goto out;
1153
					goto out;
Line 1159... Line 1167...
1159
			}
1167
			}
1160
		}
1168
		}
1161
	}
1169
	}
1162
	card_res->count_connectors = connector_count;
1170
	card_res->count_connectors = connector_count;
Line 1163... Line 1171...
1163
 
1171
 
1164
	DRM_DEBUG("Counted %d %d %d\n", card_res->count_crtcs,
1172
	DRM_DEBUG_KMS("Counted %d %d %d\n", card_res->count_crtcs,
Line 1165... Line 1173...
1165
		  card_res->count_connectors, card_res->count_encoders);
1173
		  card_res->count_connectors, card_res->count_encoders);
1166
 
1174
 
1167
out:
1175
out:
Line 1263... Line 1271...
1263
	uint64_t __user *prop_values;
1271
	uint64_t __user *prop_values;
1264
	uint32_t __user *encoder_ptr;
1272
	uint32_t __user *encoder_ptr;
Line 1265... Line 1273...
1265
 
1273
 
Line 1266... Line 1274...
1266
	memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
1274
	memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
Line 1267... Line 1275...
1267
 
1275
 
Line 1268... Line 1276...
1268
	DRM_DEBUG("connector id %d:\n", out_resp->connector_id);
1276
	DRM_DEBUG_KMS("connector id %d:\n", out_resp->connector_id);
1269
 
1277
 
Line 1439... Line 1447...
1439
 
1447
 
1440
	mutex_lock(&dev->mode_config.mutex);
1448
	mutex_lock(&dev->mode_config.mutex);
1441
	obj = drm_mode_object_find(dev, crtc_req->crtc_id,
1449
	obj = drm_mode_object_find(dev, crtc_req->crtc_id,
1442
				   DRM_MODE_OBJECT_CRTC);
1450
				   DRM_MODE_OBJECT_CRTC);
1443
	if (!obj) {
1451
	if (!obj) {
1444
		DRM_DEBUG("Unknown CRTC ID %d\n", crtc_req->crtc_id);
1452
		DRM_DEBUG_KMS("Unknown CRTC ID %d\n", crtc_req->crtc_id);
1445
		ret = -EINVAL;
1453
		ret = -EINVAL;
1446
		goto out;
1454
		goto out;
1447
	}
1455
	}
Line 1452... Line 1460...
1452
		/* If we pass -1, set the mode with the currently bound fb */
1460
		/* If we pass -1, set the mode with the currently bound fb */
1453
		if (crtc_req->fb_id == -1) {
1461
		if (crtc_req->fb_id == -1) {
1454
			list_for_each_entry(crtcfb,
1462
			list_for_each_entry(crtcfb,
1455
					    &dev->mode_config.crtc_list, head) {
1463
					    &dev->mode_config.crtc_list, head) {
1456
				if (crtcfb == crtc) {
1464
				if (crtcfb == crtc) {
1457
					DRM_DEBUG("Using current fb for setmode\n");
1465
					DRM_DEBUG_KMS("Using current fb for "
-
 
1466
							"setmode\n");
1458
					fb = crtc->fb;
1467
					fb = crtc->fb;
1459
				}
1468
				}
1460
			}
1469
			}
1461
		} else {
1470
		} else {
1462
			obj = drm_mode_object_find(dev, crtc_req->fb_id,
1471
			obj = drm_mode_object_find(dev, crtc_req->fb_id,
1463
						   DRM_MODE_OBJECT_FB);
1472
						   DRM_MODE_OBJECT_FB);
1464
			if (!obj) {
1473
			if (!obj) {
1465
				DRM_DEBUG("Unknown FB ID%d\n", crtc_req->fb_id);
1474
				DRM_DEBUG_KMS("Unknown FB ID%d\n",
-
 
1475
						crtc_req->fb_id);
1466
				ret = -EINVAL;
1476
				ret = -EINVAL;
1467
				goto out;
1477
				goto out;
1468
			}
1478
			}
1469
			fb = obj_to_fb(obj);
1479
			fb = obj_to_fb(obj);
1470
		}
1480
		}
Line 1473... Line 1483...
1473
		drm_crtc_convert_umode(mode, &crtc_req->mode);
1483
		drm_crtc_convert_umode(mode, &crtc_req->mode);
1474
		drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
1484
		drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
1475
	}
1485
	}
Line 1476... Line 1486...
1476
 
1486
 
1477
	if (crtc_req->count_connectors == 0 && mode) {
1487
	if (crtc_req->count_connectors == 0 && mode) {
1478
		DRM_DEBUG("Count connectors is 0 but mode set\n");
1488
		DRM_DEBUG_KMS("Count connectors is 0 but mode set\n");
1479
		ret = -EINVAL;
1489
		ret = -EINVAL;
1480
		goto out;
1490
		goto out;
Line 1481... Line 1491...
1481
	}
1491
	}
1482
 
1492
 
1483
	if (crtc_req->count_connectors > 0 && !mode && !fb) {
1493
	if (crtc_req->count_connectors > 0 && (!mode || !fb)) {
1484
		DRM_DEBUG("Count connectors is %d but no mode or fb set\n",
1494
		DRM_DEBUG_KMS("Count connectors is %d but no mode or fb set\n",
1485
			  crtc_req->count_connectors);
1495
			  crtc_req->count_connectors);
1486
		ret = -EINVAL;
1496
		ret = -EINVAL;
Line 1512... Line 1522...
1512
			}
1522
			}
Line 1513... Line 1523...
1513
 
1523
 
1514
			obj = drm_mode_object_find(dev, out_id,
1524
			obj = drm_mode_object_find(dev, out_id,
1515
						   DRM_MODE_OBJECT_CONNECTOR);
1525
						   DRM_MODE_OBJECT_CONNECTOR);
1516
			if (!obj) {
1526
			if (!obj) {
-
 
1527
				DRM_DEBUG_KMS("Connector id %d unknown\n",
1517
				DRM_DEBUG("Connector id %d unknown\n", out_id);
1528
						out_id);
1518
				ret = -EINVAL;
1529
				ret = -EINVAL;
1519
				goto out;
1530
				goto out;
1520
			}
1531
			}
Line 1545... Line 1556...
1545
	struct drm_mode_cursor *req = data;
1556
	struct drm_mode_cursor *req = data;
1546
	struct drm_mode_object *obj;
1557
	struct drm_mode_object *obj;
1547
	struct drm_crtc *crtc;
1558
	struct drm_crtc *crtc;
1548
	int ret = 0;
1559
	int ret = 0;
Line 1549... Line 1560...
1549
 
1560
 
Line 1550... Line 1561...
1550
	DRM_DEBUG("\n");
1561
	DRM_DEBUG_KMS("\n");
1551
 
1562
 
1552
	if (!req->flags) {
1563
	if (!req->flags) {
1553
		DRM_ERROR("no operation set\n");
1564
		DRM_ERROR("no operation set\n");
Line 1554... Line 1565...
1554
		return -EINVAL;
1565
		return -EINVAL;
1555
	}
1566
	}
1556
 
1567
 
1557
	mutex_lock(&dev->mode_config.mutex);
1568
	mutex_lock(&dev->mode_config.mutex);
1558
	obj = drm_mode_object_find(dev, req->crtc_id, DRM_MODE_OBJECT_CRTC);
1569
	obj = drm_mode_object_find(dev, req->crtc_id, DRM_MODE_OBJECT_CRTC);
1559
	if (!obj) {
1570
	if (!obj) {
1560
		DRM_DEBUG("Unknown CRTC ID %d\n", req->crtc_id);
1571
		DRM_DEBUG_KMS("Unknown CRTC ID %d\n", req->crtc_id);
1561
		ret = -EINVAL;
1572
		ret = -EINVAL;
Line 1772... Line 1783...
1772
	}
1783
	}
1773
	mutex_unlock(&dev->mode_config.mutex);
1784
	mutex_unlock(&dev->mode_config.mutex);
1774
}
1785
}
1775
#endif
1786
#endif
Line 1776... Line -...
1776
 
-
 
1777
 
1787
 
1778
/**
1788
/**
1779
 * drm_mode_attachmode - add a mode to the user mode list
1789
 * drm_mode_attachmode - add a mode to the user mode list
1780
 * @dev: DRM device
1790
 * @dev: DRM device
1781
 * @connector: connector to add the mode to
1791
 * @connector: connector to add the mode to
Line 1954... Line 1964...
1954
		if (!property->values)
1964
		if (!property->values)
1955
			goto fail;
1965
			goto fail;
1956
	}
1966
	}
Line 1957... Line 1967...
1957
 
1967
 
1958
	drm_mode_object_get(dev, &property->base, DRM_MODE_OBJECT_PROPERTY);
-
 
1959
 
1968
	drm_mode_object_get(dev, &property->base, DRM_MODE_OBJECT_PROPERTY);
1960
	property->flags = flags;
1969
	property->flags = flags;
1961
	property->num_values = num_values;
1970
	property->num_values = num_values;
Line 1962... Line 1971...
1962
	INIT_LIST_HEAD(&property->enum_blob_list);
1971
	INIT_LIST_HEAD(&property->enum_blob_list);
1963
 
1972
 
Line 1964... Line -...
1964
	if (name)
-
 
1965
		strncpy(property->name, name, DRM_PROP_NAME_LEN);
1973
	if (name)
Line 1966... Line 1974...
1966
 
1974
		strncpy(property->name, name, DRM_PROP_NAME_LEN);
Line 1967... Line 1975...
1967
 
1975
 
Line 2097... Line 2105...
2097
	struct drm_property_blob *prop_blob;
2105
	struct drm_property_blob *prop_blob;
2098
	uint32_t *blob_id_ptr;
2106
	uint32_t *blob_id_ptr;
2099
	uint64_t __user *values_ptr;
2107
	uint64_t __user *values_ptr;
2100
	uint32_t __user *blob_length_ptr;
2108
	uint32_t __user *blob_length_ptr;
Line 2101... Line 2109...
2101
 
2109
 
2102
//   mutex_lock(&dev->mode_config.mutex);
2110
	mutex_lock(&dev->mode_config.mutex);
2103
	obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY);
2111
	obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY);
2104
	if (!obj) {
2112
	if (!obj) {
2105
		ret = -EINVAL;
2113
		ret = -EINVAL;
2106
		goto done;
2114
		goto done;
Line 2175... Line 2183...
2175
			}
2183
			}
2176
		}
2184
		}
2177
		out_resp->count_enum_blobs = blob_count;
2185
		out_resp->count_enum_blobs = blob_count;
2178
	}
2186
	}
2179
done:
2187
done:
2180
//   mutex_unlock(&dev->mode_config.mutex);
2188
	mutex_unlock(&dev->mode_config.mutex);
2181
	return ret;
2189
	return ret;
2182
}
2190
}
2183
#endif
2191
#endif
Line 2184... Line 2192...
2184
 
2192
 
Line 2281... Line 2289...
2281
	struct drm_property *property;
2289
	struct drm_property *property;
2282
	struct drm_connector *connector;
2290
	struct drm_connector *connector;
2283
	int ret = -EINVAL;
2291
	int ret = -EINVAL;
2284
	int i;
2292
	int i;
Line 2285... Line 2293...
2285
 
2293
 
Line 2286... Line 2294...
2286
//   mutex_lock(&dev->mode_config.mutex);
2294
	mutex_lock(&dev->mode_config.mutex);
2287
 
2295
 
2288
	obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR);
2296
	obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR);
2289
	if (!obj) {
2297
	if (!obj) {
Line 2338... Line 2346...
2338
 
2346
 
2339
	/* store the property value if succesful */
2347
	/* store the property value if succesful */
2340
	if (!ret)
2348
	if (!ret)
2341
		drm_connector_property_set_value(connector, property, out_resp->value);
2349
		drm_connector_property_set_value(connector, property, out_resp->value);
2342
out:
2350
out:
2343
//   mutex_unlock(&dev->mode_config.mutex);
2351
	mutex_unlock(&dev->mode_config.mutex);
2344
	return ret;
2352
	return ret;
2345
}
2353
}
Line 2346... Line 2354...
2346
#endif
2354
#endif
Line 2399... Line 2407...
2399
	struct drm_crtc *crtc;
2407
	struct drm_crtc *crtc;
2400
	void *r_base, *g_base, *b_base;
2408
	void *r_base, *g_base, *b_base;
2401
	int size;
2409
	int size;
2402
	int ret = 0;
2410
	int ret = 0;
Line 2403... Line 2411...
2403
 
2411
 
2404
//   mutex_lock(&dev->mode_config.mutex);
2412
	mutex_lock(&dev->mode_config.mutex);
2405
	obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC);
2413
	obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC);
2406
	if (!obj) {
2414
	if (!obj) {
2407
		ret = -EINVAL;
2415
		ret = -EINVAL;
2408
		goto out;
2416
		goto out;
Line 2435... Line 2443...
2435
	}
2443
	}
Line 2436... Line 2444...
2436
 
2444
 
Line 2437... Line 2445...
2437
	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
2445
	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
2438
 
2446
 
2439
out:
2447
out:
Line 2440... Line 2448...
2440
//   mutex_unlock(&dev->mode_config.mutex);
2448
	mutex_unlock(&dev->mode_config.mutex);
Line 2441... Line 2449...
2441
	return ret;
2449
	return ret;
Line 2450... Line 2458...
2450
	struct drm_crtc *crtc;
2458
	struct drm_crtc *crtc;
2451
	void *r_base, *g_base, *b_base;
2459
	void *r_base, *g_base, *b_base;
2452
	int size;
2460
	int size;
2453
	int ret = 0;
2461
	int ret = 0;
Line 2454... Line 2462...
2454
 
2462
 
2455
//   mutex_lock(&dev->mode_config.mutex);
2463
	mutex_lock(&dev->mode_config.mutex);
2456
	obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC);
2464
	obj = drm_mode_object_find(dev, crtc_lut->crtc_id, DRM_MODE_OBJECT_CRTC);
2457
	if (!obj) {
2465
	if (!obj) {
2458
		ret = -EINVAL;
2466
		ret = -EINVAL;
2459
		goto out;
2467
		goto out;
Line 2483... Line 2491...
2483
	if (copy_to_user((void __user *)(unsigned long)crtc_lut->blue, b_base, size)) {
2491
	if (copy_to_user((void __user *)(unsigned long)crtc_lut->blue, b_base, size)) {
2484
		ret = -EFAULT;
2492
		ret = -EFAULT;
2485
		goto out;
2493
		goto out;
2486
	}
2494
	}
2487
out:
2495
out:
2488
//   mutex_unlock(&dev->mode_config.mutex);
2496
	mutex_unlock(&dev->mode_config.mutex);
2489
	return ret;
2497
	return ret;
2490
}
2498
}
Line 2491... Line 2499...
2491
 
2499
 
-
 
2500
#endif
-
 
2501