76 int saved_dpms = connector->
dpms;
88 connector->
dpms = saved_dpms;
93 static void radeon_property_change_mode(
struct drm_encoder *encoder)
99 crtc->
x, crtc->
y, crtc->
fb);
129 dig_connector = radeon_connector->
con_priv;
170 best_encoder = connector_funcs->
best_encoder(connector);
242 radeon_connector_analog_encoder_conflict_solve(
struct drm_connector *connector,
253 if (conflict == connector)
269 if (priority ==
true) {
283 return current_status;
296 native_mode->
clock != 0) {
301 DRM_DEBUG_KMS(
"Adding native panel mode %s\n", mode->
name);
302 }
else if (native_mode->
hdisplay != 0 &&
313 DRM_DEBUG_KMS(
"Adding cvt approximation of native panel mode %s\n", mode->
name);
328 } common_modes[17] = {
348 for (i = 0; i < 17; i++) {
350 if (common_modes[i].
w > 1024 ||
351 common_modes[i].
h > 768)
355 if (common_modes[i].
w > native_mode->
hdisplay ||
356 common_modes[i].h > native_mode->
vdisplay ||
357 (common_modes[i].w == native_mode->
hdisplay &&
358 common_modes[i].h == native_mode->
vdisplay))
361 if (common_modes[i].
w < 320 || common_modes[i].
h < 200)
364 mode =
drm_cvt_mode(dev, common_modes[i].
w, common_modes[i].
h, 60,
false,
false,
false);
375 struct radeon_encoder *radeon_encoder;
377 if (property == rdev->
mode_info.coherent_mode_property) {
379 bool new_coherent_mode;
392 new_coherent_mode = val ?
true :
false;
395 radeon_property_change_mode(&radeon_encoder->
base);
399 if (property == rdev->
mode_info.underscan_property) {
409 radeon_property_change_mode(&radeon_encoder->
base);
413 if (property == rdev->
mode_info.underscan_hborder_property) {
423 radeon_property_change_mode(&radeon_encoder->
base);
427 if (property == rdev->
mode_info.underscan_vborder_property) {
437 radeon_property_change_mode(&radeon_encoder->
base);
441 if (property == rdev->
mode_info.tv_std_property) {
462 radeon_property_change_mode(&radeon_encoder->
base);
465 if (property == rdev->
mode_info.load_detect_property) {
475 if (property == rdev->
mode_info.tmds_pll_property) {
495 if (val == 1 || ret ==
false) {
498 radeon_property_change_mode(&radeon_encoder->
base);
504 static void radeon_fixup_lvds_native_mode(
struct drm_encoder *encoder,
516 memcpy(native_mode, mode,
sizeof(*mode));
521 if (!native_mode->
clock) {
525 *native_mode = *
mode;
527 DRM_DEBUG_KMS(
"Determined LVDS native mode details from EDID\n");
533 if (!native_mode->
clock) {
534 DRM_DEBUG_KMS(
"No LVDS native mode details, disabling RMX\n");
539 static int radeon_lvds_get_modes(
struct drm_connector *connector)
546 if (radeon_connector->
ddc_bus) {
549 encoder = radeon_best_single_encoder(connector);
551 radeon_fixup_lvds_native_mode(encoder, connector);
553 radeon_add_common_modes(encoder, connector);
559 encoder = radeon_best_single_encoder(connector);
564 mode = radeon_fp_native_mode(encoder);
572 radeon_add_common_modes(encoder, connector);
578 static int radeon_lvds_mode_valid(
struct drm_connector *connector,
581 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
612 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
626 if (radeon_connector->
edid)
629 if (radeon_connector->
ddc_bus) {
631 &radeon_connector->
ddc_bus->adapter);
632 if (radeon_connector->
edid)
638 radeon_connector_update_scratch_regs(connector, ret);
642 static void radeon_connector_destroy(
struct drm_connector *connector)
646 if (radeon_connector->
edid)
654 static int radeon_lvds_set_property(
struct drm_connector *connector,
659 struct radeon_encoder *radeon_encoder;
663 if (property != dev->mode_config.scaling_mode_property)
680 if (radeon_encoder->
rmx_type == rmx_type)
683 radeon_encoder->
rmx_type = rmx_type;
685 radeon_property_change_mode(&radeon_encoder->
base);
691 .get_modes = radeon_lvds_get_modes,
692 .mode_valid = radeon_lvds_mode_valid,
693 .best_encoder = radeon_best_single_encoder,
698 .detect = radeon_lvds_detect,
700 .destroy = radeon_connector_destroy,
701 .set_property = radeon_lvds_set_property,
704 static int radeon_vga_get_modes(
struct drm_connector *connector)
714 static int radeon_vga_mode_valid(
struct drm_connector *connector,
722 if ((mode->
clock / 10) > rdev->
clock.max_pixel_clock)
729 radeon_vga_detect(
struct drm_connector *connector,
bool force)
739 encoder = radeon_best_single_encoder(connector);
747 if (radeon_connector->
edid) {
753 if (!radeon_connector->
edid) {
754 DRM_ERROR(
"%s: probed a monitor but no|invalid EDID\n",
785 ret = encoder_funcs->
detect(encoder, connector);
792 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret,
true);
800 rdev->
mode_info.bios_hardcoded_edid_size) {
804 radeon_connector_update_scratch_regs(connector, ret);
809 .get_modes = radeon_vga_get_modes,
810 .mode_valid = radeon_vga_mode_valid,
811 .best_encoder = radeon_best_single_encoder,
816 .detect = radeon_vga_detect,
818 .destroy = radeon_connector_destroy,
819 .set_property = radeon_connector_set_property,
822 static int radeon_tv_get_modes(
struct drm_connector *connector)
829 encoder = radeon_best_single_encoder(connector);
836 radeon_add_common_modes(encoder, connector);
839 tv_mode =
drm_cvt_mode(dev, 800, 600, 60,
false,
false,
false);
846 static int radeon_tv_mode_valid(
struct drm_connector *connector,
855 radeon_tv_detect(
struct drm_connector *connector,
bool force)
865 encoder = radeon_best_single_encoder(connector);
870 ret = encoder_funcs->
detect(encoder, connector);
873 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret,
false);
874 radeon_connector_update_scratch_regs(connector, ret);
879 .get_modes = radeon_tv_get_modes,
880 .mode_valid = radeon_tv_mode_valid,
881 .best_encoder = radeon_best_single_encoder,
886 .detect = radeon_tv_detect,
888 .destroy = radeon_connector_destroy,
889 .set_property = radeon_connector_set_property,
892 static int radeon_dvi_get_modes(
struct drm_connector *connector)
901 static bool radeon_check_hpd_status_unchanged(
struct drm_connector *connector)
915 if (connector->
status == status)
934 radeon_dvi_detect(
struct drm_connector *connector,
bool force)
944 bool dret =
false, broken_edid =
false;
946 if (!force && radeon_check_hpd_status_unchanged(connector))
953 if (radeon_connector->
edid) {
959 if (!radeon_connector->
edid) {
960 DRM_ERROR(
"%s: probed a monitor but no|invalid EDID\n",
966 DRM_ERROR(
"%s: detected RS690 floating bus bug, stopping ddc detect\n",
drm_get_connector_name(connector));
992 struct radeon_connector *list_radeon_connector;
994 if (connector == list_connector)
998 (list_radeon_connector->
ddc_bus->rec.i2c_id ==
999 radeon_connector->
ddc_bus->rec.i2c_id)) {
1052 if (encoder_funcs->
detect) {
1056 ret = encoder_funcs->
detect(encoder, connector);
1067 lret = encoder_funcs->
detect(encoder, connector);
1068 DRM_DEBUG_KMS(
"load_detect %x returned: %x\n",encoder->
encoder_type,lret);
1079 ret = radeon_connector_analog_encoder_conflict_solve(connector, encoder, ret,
true);
1091 rdev->
mode_info.bios_hardcoded_edid_size) {
1097 radeon_connector_update_scratch_regs(connector, ret);
1143 static void radeon_dvi_force(
struct drm_connector *connector)
1152 static int radeon_dvi_mode_valid(
struct drm_connector *connector,
1164 (mode->
clock > 135000))
1175 if (mode->
clock > 340000)
1186 if ((mode->
clock / 10) > rdev->
clock.max_pixel_clock)
1193 .get_modes = radeon_dvi_get_modes,
1194 .mode_valid = radeon_dvi_mode_valid,
1195 .best_encoder = radeon_dvi_encoder,
1200 .detect = radeon_dvi_detect,
1202 .set_property = radeon_connector_set_property,
1203 .destroy = radeon_connector_destroy,
1204 .force = radeon_dvi_force,
1207 static void radeon_dp_connector_destroy(
struct drm_connector *connector)
1212 if (radeon_connector->
edid)
1222 static int radeon_dp_get_modes(
struct drm_connector *connector)
1226 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1234 if (!radeon_dig_connector->
edp_on)
1238 if (!radeon_dig_connector->
edp_on)
1253 radeon_fixup_lvds_native_mode(encoder, connector);
1255 radeon_add_common_modes(encoder, connector);
1264 mode = radeon_fp_native_mode(encoder);
1272 radeon_add_common_modes(encoder, connector);
1291 struct radeon_encoder *radeon_encoder;
1321 struct radeon_encoder *radeon_encoder;
1348 (rdev->
clock.dp_extclk >= 53900) &&
1357 radeon_dp_detect(
struct drm_connector *connector,
bool force)
1364 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1366 if (!force && radeon_check_hpd_status_unchanged(connector))
1367 return connector->
status;
1369 if (radeon_connector->
edid) {
1386 if (!radeon_dig_connector->
edp_on)
1391 if (!radeon_dig_connector->
edp_on)
1408 ret = encoder_funcs->
detect(encoder, connector);
1428 radeon_connector_update_scratch_regs(connector, ret);
1432 static int radeon_dp_mode_valid(
struct drm_connector *connector,
1442 struct drm_encoder *encoder = radeon_best_single_encoder(connector);
1476 .get_modes = radeon_dp_get_modes,
1477 .mode_valid = radeon_dp_mode_valid,
1478 .best_encoder = radeon_dvi_encoder,
1483 .detect = radeon_dp_detect,
1485 .set_property = radeon_connector_set_property,
1486 .destroy = radeon_dp_connector_destroy,
1487 .force = radeon_dvi_force,
1503 struct radeon_connector *radeon_connector;
1506 struct radeon_encoder *radeon_encoder;
1508 bool shared_ddc =
false;
1509 bool is_dp_bridge =
false;
1525 radeon_connector->
devices |= supported_device;
1529 if (radeon_connector->
ddc_bus->rec.i2c_id == i2c_bus->
i2c_id) {
1544 if (radeon_encoder->
devices & supported_device) {
1548 is_dp_bridge =
true;
1556 radeon_connector = kzalloc(
sizeof(
struct radeon_connector),
GFP_KERNEL);
1557 if (!radeon_connector)
1560 connector = &radeon_connector->
base;
1563 radeon_connector->
devices = supported_device;
1566 radeon_connector->
hpd = *hpd;
1568 radeon_connector->
router = *router;
1572 DRM_ERROR(
"Failed to assign router i2c bus! Check dmesg for i2c errors.\n");
1577 if (!radeon_dig_connector)
1580 radeon_connector->
con_priv = radeon_dig_connector;
1582 drm_connector_helper_add(&radeon_connector->
base, &radeon_dp_connector_helper_funcs);
1583 if (i2c_bus->
valid) {
1590 DRM_ERROR(
"DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1592 if (!radeon_connector->
ddc_bus)
1593 DRM_ERROR(
"DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1595 switch (connector_type) {
1615 rdev->
mode_info.underscan_hborder_property,
1618 rdev->
mode_info.underscan_vborder_property,
1636 dev->mode_config.scaling_mode_property,
1644 switch (connector_type) {
1647 drm_connector_helper_add(&radeon_connector->
base, &radeon_vga_connector_helper_funcs);
1648 if (i2c_bus->
valid) {
1650 if (!radeon_connector->
ddc_bus)
1651 DRM_ERROR(
"VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1665 drm_connector_helper_add(&radeon_connector->
base, &radeon_vga_connector_helper_funcs);
1666 if (i2c_bus->
valid) {
1668 if (!radeon_connector->
ddc_bus)
1669 DRM_ERROR(
"DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1683 if (!radeon_dig_connector)
1686 radeon_connector->
con_priv = radeon_dig_connector;
1688 drm_connector_helper_add(&radeon_connector->
base, &radeon_dvi_connector_helper_funcs);
1689 if (i2c_bus->
valid) {
1691 if (!radeon_connector->
ddc_bus)
1692 DRM_ERROR(
"DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1703 rdev->
mode_info.underscan_hborder_property,
1706 rdev->
mode_info.underscan_vborder_property,
1724 if (!radeon_dig_connector)
1727 radeon_connector->
con_priv = radeon_dig_connector;
1729 drm_connector_helper_add(&radeon_connector->
base, &radeon_dvi_connector_helper_funcs);
1730 if (i2c_bus->
valid) {
1732 if (!radeon_connector->
ddc_bus)
1733 DRM_ERROR(
"HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1743 rdev->
mode_info.underscan_hborder_property,
1746 rdev->
mode_info.underscan_vborder_property,
1758 if (!radeon_dig_connector)
1761 radeon_connector->
con_priv = radeon_dig_connector;
1763 drm_connector_helper_add(&radeon_connector->
base, &radeon_dp_connector_helper_funcs);
1764 if (i2c_bus->
valid) {
1768 DRM_ERROR(
"DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1770 if (!radeon_connector->
ddc_bus)
1771 DRM_ERROR(
"DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1782 rdev->
mode_info.underscan_hborder_property,
1785 rdev->
mode_info.underscan_vborder_property,
1794 if (!radeon_dig_connector)
1797 radeon_connector->
con_priv = radeon_dig_connector;
1799 drm_connector_helper_add(&radeon_connector->
base, &radeon_dp_connector_helper_funcs);
1800 if (i2c_bus->
valid) {
1804 DRM_ERROR(
"DP: Failed to assign dp ddc bus! Check dmesg for i2c errors.\n");
1806 if (!radeon_connector->
ddc_bus)
1807 DRM_ERROR(
"DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1810 dev->mode_config.scaling_mode_property,
1820 drm_connector_helper_add(&radeon_connector->
base, &radeon_tv_connector_helper_funcs);
1835 if (!radeon_dig_connector)
1838 radeon_connector->
con_priv = radeon_dig_connector;
1840 drm_connector_helper_add(&radeon_connector->
base, &radeon_lvds_connector_helper_funcs);
1841 if (i2c_bus->
valid) {
1843 if (!radeon_connector->
ddc_bus)
1844 DRM_ERROR(
"LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1847 dev->mode_config.scaling_mode_property,
1882 struct radeon_connector *radeon_connector;
1899 radeon_connector->
devices |= supported_device;
1904 radeon_connector = kzalloc(
sizeof(
struct radeon_connector),
GFP_KERNEL);
1905 if (!radeon_connector)
1908 connector = &radeon_connector->
base;
1911 radeon_connector->
devices = supported_device;
1913 radeon_connector->
hpd = *
hpd;
1915 switch (connector_type) {
1918 drm_connector_helper_add(&radeon_connector->
base, &radeon_vga_connector_helper_funcs);
1919 if (i2c_bus->
valid) {
1921 if (!radeon_connector->
ddc_bus)
1922 DRM_ERROR(
"VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1936 drm_connector_helper_add(&radeon_connector->
base, &radeon_vga_connector_helper_funcs);
1937 if (i2c_bus->
valid) {
1939 if (!radeon_connector->
ddc_bus)
1940 DRM_ERROR(
"DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1954 drm_connector_helper_add(&radeon_connector->
base, &radeon_dvi_connector_helper_funcs);
1955 if (i2c_bus->
valid) {
1957 if (!radeon_connector->
ddc_bus)
1958 DRM_ERROR(
"DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
1977 drm_connector_helper_add(&radeon_connector->
base, &radeon_tv_connector_helper_funcs);
1999 drm_connector_helper_add(&radeon_connector->
base, &radeon_lvds_connector_helper_funcs);
2000 if (i2c_bus->
valid) {
2002 if (!radeon_connector->
ddc_bus)
2003 DRM_ERROR(
"LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
2006 dev->mode_config.scaling_mode_property,