diff options
Diffstat (limited to 'drivers/gpu/drm/drm_modes.c')
-rw-r--r-- | drivers/gpu/drm/drm_modes.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 213b11ea69b5..cd74a0953f42 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c | |||
@@ -1405,3 +1405,90 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev, | |||
1405 | return mode; | 1405 | return mode; |
1406 | } | 1406 | } |
1407 | EXPORT_SYMBOL(drm_mode_create_from_cmdline_mode); | 1407 | EXPORT_SYMBOL(drm_mode_create_from_cmdline_mode); |
1408 | |||
1409 | /** | ||
1410 | * drm_crtc_convert_to_umode - convert a drm_display_mode into a modeinfo | ||
1411 | * @out: drm_mode_modeinfo struct to return to the user | ||
1412 | * @in: drm_display_mode to use | ||
1413 | * | ||
1414 | * Convert a drm_display_mode into a drm_mode_modeinfo structure to return to | ||
1415 | * the user. | ||
1416 | */ | ||
1417 | void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out, | ||
1418 | const struct drm_display_mode *in) | ||
1419 | { | ||
1420 | WARN(in->hdisplay > USHRT_MAX || in->hsync_start > USHRT_MAX || | ||
1421 | in->hsync_end > USHRT_MAX || in->htotal > USHRT_MAX || | ||
1422 | in->hskew > USHRT_MAX || in->vdisplay > USHRT_MAX || | ||
1423 | in->vsync_start > USHRT_MAX || in->vsync_end > USHRT_MAX || | ||
1424 | in->vtotal > USHRT_MAX || in->vscan > USHRT_MAX, | ||
1425 | "timing values too large for mode info\n"); | ||
1426 | |||
1427 | out->clock = in->clock; | ||
1428 | out->hdisplay = in->hdisplay; | ||
1429 | out->hsync_start = in->hsync_start; | ||
1430 | out->hsync_end = in->hsync_end; | ||
1431 | out->htotal = in->htotal; | ||
1432 | out->hskew = in->hskew; | ||
1433 | out->vdisplay = in->vdisplay; | ||
1434 | out->vsync_start = in->vsync_start; | ||
1435 | out->vsync_end = in->vsync_end; | ||
1436 | out->vtotal = in->vtotal; | ||
1437 | out->vscan = in->vscan; | ||
1438 | out->vrefresh = in->vrefresh; | ||
1439 | out->flags = in->flags; | ||
1440 | out->type = in->type; | ||
1441 | strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); | ||
1442 | out->name[DRM_DISPLAY_MODE_LEN-1] = 0; | ||
1443 | } | ||
1444 | |||
1445 | /** | ||
1446 | * drm_crtc_convert_umode - convert a modeinfo into a drm_display_mode | ||
1447 | * @out: drm_display_mode to return to the user | ||
1448 | * @in: drm_mode_modeinfo to use | ||
1449 | * | ||
1450 | * Convert a drm_mode_modeinfo into a drm_display_mode structure to return to | ||
1451 | * the caller. | ||
1452 | * | ||
1453 | * Returns: | ||
1454 | * Zero on success, negative errno on failure. | ||
1455 | */ | ||
1456 | int drm_mode_convert_umode(struct drm_display_mode *out, | ||
1457 | const struct drm_mode_modeinfo *in) | ||
1458 | { | ||
1459 | int ret = -EINVAL; | ||
1460 | |||
1461 | if (in->clock > INT_MAX || in->vrefresh > INT_MAX) { | ||
1462 | ret = -ERANGE; | ||
1463 | goto out; | ||
1464 | } | ||
1465 | |||
1466 | if ((in->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX) | ||
1467 | goto out; | ||
1468 | |||
1469 | out->clock = in->clock; | ||
1470 | out->hdisplay = in->hdisplay; | ||
1471 | out->hsync_start = in->hsync_start; | ||
1472 | out->hsync_end = in->hsync_end; | ||
1473 | out->htotal = in->htotal; | ||
1474 | out->hskew = in->hskew; | ||
1475 | out->vdisplay = in->vdisplay; | ||
1476 | out->vsync_start = in->vsync_start; | ||
1477 | out->vsync_end = in->vsync_end; | ||
1478 | out->vtotal = in->vtotal; | ||
1479 | out->vscan = in->vscan; | ||
1480 | out->vrefresh = in->vrefresh; | ||
1481 | out->flags = in->flags; | ||
1482 | out->type = in->type; | ||
1483 | strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); | ||
1484 | out->name[DRM_DISPLAY_MODE_LEN-1] = 0; | ||
1485 | |||
1486 | out->status = drm_mode_validate_basic(out); | ||
1487 | if (out->status != MODE_OK) | ||
1488 | goto out; | ||
1489 | |||
1490 | ret = 0; | ||
1491 | |||
1492 | out: | ||
1493 | return ret; | ||
1494 | } \ No newline at end of file | ||