Subversion Repositories Kolibri OS

Rev

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

Rev 4539 Rev 4560
Line 37... Line 37...
37
#include 
37
#include 
38
#include 
38
#include 
39
#include 
39
#include 
40
#include 
40
#include 
Line 41... Line -...
41
 
-
 
42
MODULE_AUTHOR("David Airlie, Jesse Barnes");
-
 
43
MODULE_DESCRIPTION("DRM KMS helper");
-
 
44
MODULE_LICENSE("GPL and additional rights");
-
 
45
 
41
 
Line 46... Line 42...
46
static LIST_HEAD(kernel_fb_helper_list);
42
static LIST_HEAD(kernel_fb_helper_list);
47
 
43
 
48
/**
44
/**
Line 153... Line 149...
153
			bound++;
149
			bound++;
154
	}
150
	}
Line 155... Line 151...
155
 
151
 
156
	if (bound < crtcs_bound)
152
	if (bound < crtcs_bound)
-
 
153
		return false;
157
		return false;
154
 
158
	return true;
155
	return true;
Line -... Line 156...
-
 
156
}
-
 
157
 
-
 
158
#ifdef CONFIG_MAGIC_SYSRQ
-
 
159
static void drm_fb_helper_restore_work_fn(struct work_struct *ignored)
-
 
160
{
-
 
161
	bool ret;
-
 
162
	ret = drm_fb_helper_force_kernel_mode();
-
 
163
	if (ret == true)
-
 
164
		DRM_ERROR("Failed to restore crtc configuration\n");
-
 
165
}
-
 
166
static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn);
-
 
167
 
-
 
168
static void drm_fb_helper_sysrq(int dummy1)
-
 
169
{
-
 
170
	schedule_work(&drm_fb_helper_restore_work);
-
 
171
}
-
 
172
 
-
 
173
static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
-
 
174
	.handler = drm_fb_helper_sysrq,
-
 
175
	.help_msg = "force-fb(V)",
-
 
176
	.action_msg = "Restore framebuffer console",
-
 
177
};
-
 
178
#else
-
 
179
 
159
}
180
#endif
160
 
181
 
161
static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
182
static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
162
{
183
{
163
	struct drm_fb_helper *fb_helper = info->par;
184
	struct drm_fb_helper *fb_helper = info->par;
Line 582... Line 603...
582
			      struct fb_info *info)
603
			      struct fb_info *info)
583
{
604
{
584
	struct drm_fb_helper *fb_helper = info->par;
605
	struct drm_fb_helper *fb_helper = info->par;
585
	struct drm_device *dev = fb_helper->dev;
606
	struct drm_device *dev = fb_helper->dev;
586
	struct drm_mode_set *modeset;
607
	struct drm_mode_set *modeset;
587
	struct drm_crtc *crtc;
-
 
588
	int ret = 0;
608
	int ret = 0;
589
	int i;
609
	int i;
Line 590... Line 610...
590
 
610
 
591
	drm_modeset_lock_all(dev);
611
	drm_modeset_lock_all(dev);
592
	if (!drm_fb_helper_is_bound(fb_helper)) {
612
	if (!drm_fb_helper_is_bound(fb_helper)) {
593
		drm_modeset_unlock_all(dev);
613
		drm_modeset_unlock_all(dev);
594
		return -EBUSY;
614
		return -EBUSY;
Line 595... Line 615...
595
	}
615
	}
596
 
-
 
597
		for (i = 0; i < fb_helper->crtc_count; i++) {
-
 
598
		crtc = fb_helper->crtc_info[i].mode_set.crtc;
616
 
Line 599... Line 617...
599
 
617
		for (i = 0; i < fb_helper->crtc_count; i++) {
600
		modeset = &fb_helper->crtc_info[i].mode_set;
618
		modeset = &fb_helper->crtc_info[i].mode_set;
Line 1078... Line 1096...
1078
	int c, o;
1096
	int c, o;
1079
	struct drm_device *dev = fb_helper->dev;
1097
	struct drm_device *dev = fb_helper->dev;
1080
	struct drm_connector *connector;
1098
	struct drm_connector *connector;
1081
	struct drm_connector_helper_funcs *connector_funcs;
1099
	struct drm_connector_helper_funcs *connector_funcs;
1082
	struct drm_encoder *encoder;
1100
	struct drm_encoder *encoder;
1083
	struct drm_fb_helper_crtc *best_crtc;
-
 
1084
	int my_score, best_score, score;
1101
	int my_score, best_score, score;
1085
	struct drm_fb_helper_crtc **crtcs, *crtc;
1102
	struct drm_fb_helper_crtc **crtcs, *crtc;
1086
	struct drm_fb_helper_connector *fb_helper_conn;
1103
	struct drm_fb_helper_connector *fb_helper_conn;
Line 1087... Line 1104...
1087
 
1104
 
Line 1090... Line 1107...
1090
 
1107
 
1091
	fb_helper_conn = fb_helper->connector_info[n];
1108
	fb_helper_conn = fb_helper->connector_info[n];
Line 1092... Line 1109...
1092
	connector = fb_helper_conn->connector;
1109
	connector = fb_helper_conn->connector;
1093
 
-
 
1094
	best_crtcs[n] = NULL;
1110
 
1095
	best_crtc = NULL;
1111
	best_crtcs[n] = NULL;
1096
	best_score = drm_pick_crtcs(fb_helper, best_crtcs, modes, n+1, width, height);
1112
	best_score = drm_pick_crtcs(fb_helper, best_crtcs, modes, n+1, width, height);
Line 1097... Line 1113...
1097
	if (modes[n] == NULL)
1113
	if (modes[n] == NULL)
Line 1139... Line 1155...
1139
		crtcs[n] = crtc;
1155
		crtcs[n] = crtc;
1140
		memcpy(crtcs, best_crtcs, n * sizeof(struct drm_fb_helper_crtc *));
1156
		memcpy(crtcs, best_crtcs, n * sizeof(struct drm_fb_helper_crtc *));
1141
		score = my_score + drm_pick_crtcs(fb_helper, crtcs, modes, n + 1,
1157
		score = my_score + drm_pick_crtcs(fb_helper, crtcs, modes, n + 1,
1142
						  width, height);
1158
						  width, height);
1143
		if (score > best_score) {
1159
		if (score > best_score) {
1144
			best_crtc = crtc;
-
 
1145
			best_score = score;
1160
			best_score = score;
1146
			memcpy(best_crtcs, crtcs,
1161
			memcpy(best_crtcs, crtcs,
1147
			       dev->mode_config.num_connector *
1162
			       dev->mode_config.num_connector *
1148
			       sizeof(struct drm_fb_helper_crtc *));
1163
			       sizeof(struct drm_fb_helper_crtc *));
1149
		}
1164
		}
Line 1306... Line 1321...
1306
 * 0 on success and a non-zero error code otherwise.
1321
 * 0 on success and a non-zero error code otherwise.
1307
 */
1322
 */
1308
int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
1323
int drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper)
1309
{
1324
{
1310
	struct drm_device *dev = fb_helper->dev;
1325
	struct drm_device *dev = fb_helper->dev;
1311
	int count = 0;
-
 
1312
	u32 max_width, max_height, bpp_sel;
1326
	u32 max_width, max_height;
Line 1313... Line 1327...
1313
 
1327
 
1314
	if (!fb_helper->fb)
1328
	if (!fb_helper->fb)
Line 1315... Line 1329...
1315
		return 0;
1329
		return 0;
Line 1322... Line 1336...
1322
	}
1336
	}
1323
	DRM_DEBUG_KMS("\n");
1337
	DRM_DEBUG_KMS("\n");
Line 1324... Line 1338...
1324
 
1338
 
1325
	max_width = fb_helper->fb->width;
1339
	max_width = fb_helper->fb->width;
1326
	max_height = fb_helper->fb->height;
-
 
Line 1327... Line 1340...
1327
	bpp_sel = fb_helper->fb->bits_per_pixel;
1340
	max_height = fb_helper->fb->height;
1328
 
-
 
1329
	count = drm_fb_helper_probe_connector_modes(fb_helper, max_width,
1341
 
Line 1330... Line 1342...
1330
						    max_height);
1342
	drm_fb_helper_probe_connector_modes(fb_helper, max_width, max_height);
1331
	mutex_unlock(&fb_helper->dev->mode_config.mutex);
1343
	mutex_unlock(&fb_helper->dev->mode_config.mutex);
1332
 
1344
 
Line 1337... Line 1349...
1337
 
1349
 
1338
	return 0;
1350
	return 0;
1339
}
1351
}
Line -... Line 1352...
-
 
1352
EXPORT_SYMBOL(drm_fb_helper_hotplug_event);
-
 
1353
 
-
 
1354
/* The Kconfig DRM_KMS_HELPER selects FRAMEBUFFER_CONSOLE (if !EXPERT)
-
 
1355
 * but the module doesn't depend on any fb console symbols.  At least
-
 
1356
 * attempt to load fbcon to avoid leaving the system without a usable console.
-
 
1357
 */
-
 
1358
#if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE) && !defined(CONFIG_EXPERT)
-
 
1359
static int __init drm_fb_helper_modinit(void)
-
 
1360
{
-
 
1361
	const char *name = "fbcon";
-
 
1362
	struct module *fbcon;
-
 
1363
 
-
 
1364
	mutex_lock(&module_mutex);
Line -... Line 1365...
-
 
1365
	fbcon = find_module(name);
-
 
1366
	mutex_unlock(&module_mutex);
-
 
1367
 
-
 
1368
	if (!fbcon)
Line -... Line 1369...
-
 
1369
		request_module_nowait(name);
-
 
1370
	return 0;