Subversion Repositories Kolibri OS

Rev

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

Rev 6084 Rev 6088
Line 1196... Line 1196...
1196
			list_move_tail(&pmode->head, &connector->modes);
1196
			list_move_tail(&pmode->head, &connector->modes);
1197
		}
1197
		}
1198
	}
1198
	}
1199
}
1199
}
1200
EXPORT_SYMBOL(drm_mode_connector_list_update);
1200
EXPORT_SYMBOL(drm_mode_connector_list_update);
-
 
1201
 
-
 
1202
/**
-
 
1203
 * drm_mode_parse_command_line_for_connector - parse command line modeline for connector
-
 
1204
 * @mode_option: optional per connector mode option
-
 
1205
 * @connector: connector to parse modeline for
-
 
1206
 * @mode: preallocated drm_cmdline_mode structure to fill out
-
 
1207
 *
-
 
1208
 * This parses @mode_option command line modeline for modes and options to
-
 
1209
 * configure the connector. If @mode_option is NULL the default command line
-
 
1210
 * modeline in fb_mode_option will be parsed instead.
-
 
1211
 *
-
 
1212
 * This uses the same parameters as the fb modedb.c, except for an extra
-
 
1213
 * force-enable, force-enable-digital and force-disable bit at the end:
-
 
1214
 *
-
 
1215
 *	x[M][R][-][@][i][m][eDd]
-
 
1216
 *
-
 
1217
 * The intermediate drm_cmdline_mode structure is required to store additional
-
 
1218
 * options from the command line modline like the force-enable/disable flag.
-
 
1219
 *
-
 
1220
 * Returns:
-
 
1221
 * True if a valid modeline has been parsed, false otherwise.
-
 
1222
 */
-
 
1223
bool drm_mode_parse_command_line_for_connector(const char *mode_option,
-
 
1224
					       struct drm_connector *connector,
-
 
1225
					       struct drm_cmdline_mode *mode)
-
 
1226
{
-
 
1227
	const char *name;
-
 
1228
	unsigned int namelen;
-
 
1229
	bool res_specified = false, bpp_specified = false, refresh_specified = false;
-
 
1230
	unsigned int xres = 0, yres = 0, bpp = 32, refresh = 0;
-
 
1231
	bool yres_specified = false, cvt = false, rb = false;
-
 
1232
	bool interlace = false, margins = false, was_digit = false;
-
 
1233
	int i;
-
 
1234
	enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
-
 
1235
 
-
 
1236
#ifdef CONFIG_FB
-
 
1237
	if (!mode_option)
-
 
1238
		mode_option = fb_mode_option;
-
 
1239
#endif
-
 
1240
 
-
 
1241
	if (!mode_option) {
-
 
1242
		mode->specified = false;
-
 
1243
		return false;
-
 
1244
	}
-
 
1245
 
-
 
1246
	name = mode_option;
-
 
1247
	namelen = strlen(name);
-
 
1248
	for (i = namelen-1; i >= 0; i--) {
-
 
1249
		switch (name[i]) {
-
 
1250
		case '@':
-
 
1251
			if (!refresh_specified && !bpp_specified &&
-
 
1252
			    !yres_specified && !cvt && !rb && was_digit) {
-
 
1253
				refresh = simple_strtol(&name[i+1], NULL, 10);
-
 
1254
				refresh_specified = true;
-
 
1255
				was_digit = false;
-
 
1256
			} else
-
 
1257
				goto done;
-
 
1258
			break;
-
 
1259
		case '-':
-
 
1260
			if (!bpp_specified && !yres_specified && !cvt &&
-
 
1261
			    !rb && was_digit) {
-
 
1262
				bpp = simple_strtol(&name[i+1], NULL, 10);
-
 
1263
				bpp_specified = true;
-
 
1264
				was_digit = false;
-
 
1265
			} else
-
 
1266
				goto done;
-
 
1267
			break;
-
 
1268
		case 'x':
-
 
1269
			if (!yres_specified && was_digit) {
-
 
1270
				yres = simple_strtol(&name[i+1], NULL, 10);
-
 
1271
				yres_specified = true;
-
 
1272
				was_digit = false;
-
 
1273
			} else
-
 
1274
				goto done;
-
 
1275
			break;
-
 
1276
		case '0' ... '9':
-
 
1277
			was_digit = true;
-
 
1278
			break;
-
 
1279
		case 'M':
-
 
1280
			if (yres_specified || cvt || was_digit)
-
 
1281
				goto done;
-
 
1282
			cvt = true;
-
 
1283
			break;
-
 
1284
		case 'R':
-
 
1285
			if (yres_specified || cvt || rb || was_digit)
-
 
1286
				goto done;
-
 
1287
			rb = true;
-
 
1288
			break;
-
 
1289
		case 'm':
-
 
1290
			if (cvt || yres_specified || was_digit)
-
 
1291
				goto done;
-
 
1292
			margins = true;
-
 
1293
			break;
-
 
1294
		case 'i':
-
 
1295
			if (cvt || yres_specified || was_digit)
-
 
1296
				goto done;
-
 
1297
			interlace = true;
-
 
1298
			break;
-
 
1299
		case 'e':
-
 
1300
			if (yres_specified || bpp_specified || refresh_specified ||
-
 
1301
			    was_digit || (force != DRM_FORCE_UNSPECIFIED))
-
 
1302
				goto done;
-
 
1303
 
-
 
1304
			force = DRM_FORCE_ON;
-
 
1305
			break;
-
 
1306
		case 'D':
-
 
1307
			if (yres_specified || bpp_specified || refresh_specified ||
-
 
1308
			    was_digit || (force != DRM_FORCE_UNSPECIFIED))
-
 
1309
				goto done;
-
 
1310
 
-
 
1311
			if ((connector->connector_type != DRM_MODE_CONNECTOR_DVII) &&
-
 
1312
			    (connector->connector_type != DRM_MODE_CONNECTOR_HDMIB))
-
 
1313
				force = DRM_FORCE_ON;
-
 
1314
			else
-
 
1315
				force = DRM_FORCE_ON_DIGITAL;
-
 
1316
			break;
-
 
1317
		case 'd':
-
 
1318
			if (yres_specified || bpp_specified || refresh_specified ||
-
 
1319
			    was_digit || (force != DRM_FORCE_UNSPECIFIED))
-
 
1320
				goto done;
-
 
1321
 
-
 
1322
			force = DRM_FORCE_OFF;
-
 
1323
			break;
-
 
1324
		default:
-
 
1325
			goto done;
-
 
1326
		}
-
 
1327
	}
-
 
1328
 
-
 
1329
	if (i < 0 && yres_specified) {
-
 
1330
		char *ch;
-
 
1331
		xres = simple_strtol(name, &ch, 10);
-
 
1332
		if ((ch != NULL) && (*ch == 'x'))
-
 
1333
			res_specified = true;
-
 
1334
		else
-
 
1335
			i = ch - name;
-
 
1336
	} else if (!yres_specified && was_digit) {
-
 
1337
		/* catch mode that begins with digits but has no 'x' */
-
 
1338
		i = 0;
-
 
1339
	}
-
 
1340
done:
-
 
1341
	if (i >= 0) {
-
 
1342
		printk(KERN_WARNING
-
 
1343
			"parse error at position %i in video mode '%s'\n",
-
 
1344
			i, name);
-
 
1345
		mode->specified = false;
-
 
1346
		return false;
-
 
1347
	}
-
 
1348
 
-
 
1349
	if (res_specified) {
-
 
1350
		mode->specified = true;
-
 
1351
		mode->xres = xres;
-
 
1352
		mode->yres = yres;
-
 
1353
	}
-
 
1354
 
-
 
1355
	if (refresh_specified) {
-
 
1356
		mode->refresh_specified = true;
-
 
1357
		mode->refresh = refresh;
-
 
1358
	}
-
 
1359
 
-
 
1360
	if (bpp_specified) {
-
 
1361
		mode->bpp_specified = true;
-
 
1362
		mode->bpp = bpp;
-
 
1363
	}
-
 
1364
	mode->rb = rb;
-
 
1365
	mode->cvt = cvt;
-
 
1366
	mode->interlace = interlace;
-
 
1367
	mode->margins = margins;
-
 
1368
	mode->force = force;
-
 
1369
 
-
 
1370
	return true;
-
 
1371
}
-
 
1372
EXPORT_SYMBOL(drm_mode_parse_command_line_for_connector);
-
 
1373
 
-
 
1374
/**
-
 
1375
 * drm_mode_create_from_cmdline_mode - convert a command line modeline into a DRM display mode
-
 
1376
 * @dev: DRM device to create the new mode for
-
 
1377
 * @cmd: input command line modeline
-
 
1378
 *
-
 
1379
 * Returns:
-
 
1380
 * Pointer to converted mode on success, NULL on error.
-
 
1381
 */
-
 
1382
struct drm_display_mode *
-
 
1383
drm_mode_create_from_cmdline_mode(struct drm_device *dev,
-
 
1384
				  struct drm_cmdline_mode *cmd)
-
 
1385
{
-
 
1386
	struct drm_display_mode *mode;
-
 
1387
 
-
 
1388
	if (cmd->cvt)
-
 
1389
		mode = drm_cvt_mode(dev,
-
 
1390
				    cmd->xres, cmd->yres,
-
 
1391
				    cmd->refresh_specified ? cmd->refresh : 60,
-
 
1392
				    cmd->rb, cmd->interlace,
-
 
1393
				    cmd->margins);
-
 
1394
	else
-
 
1395
		mode = drm_gtf_mode(dev,
-
 
1396
				    cmd->xres, cmd->yres,
-
 
1397
				    cmd->refresh_specified ? cmd->refresh : 60,
-
 
1398
				    cmd->interlace,
-
 
1399
				    cmd->margins);
-
 
1400
	if (!mode)
-
 
1401
		return NULL;
-
 
1402
 
-
 
1403
	mode->type |= DRM_MODE_TYPE_USERDEF;
-
 
1404
	drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
-
 
1405
	return mode;
-
 
1406
}
-
 
1407
EXPORT_SYMBOL(drm_mode_create_from_cmdline_mode);
-
 
1408
 
1201
/**
1409
/**
1202
 * drm_crtc_convert_to_umode - convert a drm_display_mode into a modeinfo
1410
 * drm_crtc_convert_to_umode - convert a drm_display_mode into a modeinfo
1203
 * @out: drm_mode_modeinfo struct to return to the user
1411
 * @out: drm_mode_modeinfo struct to return to the user
1204
 * @in: drm_display_mode to use
1412
 * @in: drm_display_mode to use
1205
 *
1413
 *