Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bccf5e3 authored by Marius Gröger's avatar Marius Gröger Committed by Dave Airlie
Browse files

drm/radeon: add properties to configure the width of the underscan borders



This allows for a more exact fitting on the physical
display. The new properties default to zero which corresponds to the
previous underscan border width[height] formula:
(display_width[display_width] >> 5) + 16.

Example to set a horizontal border width of 30 and a vertikal border
height of 22:

   xrandr --output HDMI-0 --set underscan on --set "underscan hborder" 30 --set "underscan vborder" 22

Signed-off-by: default avatarMarius Gröger <marius.groeger@googlemail.com>
Reviewed-by: default avatarAlex Deucher <alexdeucher@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent d0f8a854
Loading
Loading
Loading
Loading
+52 −3
Original line number Original line Diff line number Diff line
@@ -326,6 +326,34 @@ int radeon_connector_set_property(struct drm_connector *connector, struct drm_pr
		}
		}
	}
	}


	if (property == rdev->mode_info.underscan_hborder_property) {
		/* need to find digital encoder on connector */
		encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
		if (!encoder)
			return 0;

		radeon_encoder = to_radeon_encoder(encoder);

		if (radeon_encoder->underscan_hborder != val) {
			radeon_encoder->underscan_hborder = val;
			radeon_property_change_mode(&radeon_encoder->base);
		}
	}

	if (property == rdev->mode_info.underscan_vborder_property) {
		/* need to find digital encoder on connector */
		encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TMDS);
		if (!encoder)
			return 0;

		radeon_encoder = to_radeon_encoder(encoder);

		if (radeon_encoder->underscan_vborder != val) {
			radeon_encoder->underscan_vborder = val;
			radeon_property_change_mode(&radeon_encoder->base);
		}
	}

	if (property == rdev->mode_info.tv_std_property) {
	if (property == rdev->mode_info.tv_std_property) {
		encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC);
		encoder = radeon_find_encoder(connector, DRM_MODE_ENCODER_TVDAC);
		if (!encoder) {
		if (!encoder) {
@@ -1153,10 +1181,17 @@ radeon_add_atom_connector(struct drm_device *dev,
		drm_connector_attach_property(&radeon_connector->base,
		drm_connector_attach_property(&radeon_connector->base,
					      rdev->mode_info.coherent_mode_property,
					      rdev->mode_info.coherent_mode_property,
					      1);
					      1);
		if (ASIC_IS_AVIVO(rdev))
		if (ASIC_IS_AVIVO(rdev)) {
			drm_connector_attach_property(&radeon_connector->base,
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_property,
						      rdev->mode_info.underscan_property,
						      UNDERSCAN_AUTO);
						      UNDERSCAN_AUTO);
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_hborder_property,
						      0);
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_vborder_property,
						      0);
		}
		if (connector_type == DRM_MODE_CONNECTOR_DVII) {
		if (connector_type == DRM_MODE_CONNECTOR_DVII) {
			radeon_connector->dac_load_detect = true;
			radeon_connector->dac_load_detect = true;
			drm_connector_attach_property(&radeon_connector->base,
			drm_connector_attach_property(&radeon_connector->base,
@@ -1181,10 +1216,17 @@ radeon_add_atom_connector(struct drm_device *dev,
		drm_connector_attach_property(&radeon_connector->base,
		drm_connector_attach_property(&radeon_connector->base,
					      rdev->mode_info.coherent_mode_property,
					      rdev->mode_info.coherent_mode_property,
					      1);
					      1);
		if (ASIC_IS_AVIVO(rdev))
		if (ASIC_IS_AVIVO(rdev)) {
			drm_connector_attach_property(&radeon_connector->base,
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_property,
						      rdev->mode_info.underscan_property,
						      UNDERSCAN_AUTO);
						      UNDERSCAN_AUTO);
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_hborder_property,
						      0);
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_vborder_property,
						      0);
		}
		subpixel_order = SubPixelHorizontalRGB;
		subpixel_order = SubPixelHorizontalRGB;
		break;
		break;
	case DRM_MODE_CONNECTOR_DisplayPort:
	case DRM_MODE_CONNECTOR_DisplayPort:
@@ -1212,10 +1254,17 @@ radeon_add_atom_connector(struct drm_device *dev,
		drm_connector_attach_property(&radeon_connector->base,
		drm_connector_attach_property(&radeon_connector->base,
					      rdev->mode_info.coherent_mode_property,
					      rdev->mode_info.coherent_mode_property,
					      1);
					      1);
		if (ASIC_IS_AVIVO(rdev))
		if (ASIC_IS_AVIVO(rdev)) {
			drm_connector_attach_property(&radeon_connector->base,
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_property,
						      rdev->mode_info.underscan_property,
						      UNDERSCAN_AUTO);
						      UNDERSCAN_AUTO);
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_hborder_property,
						      0);
			drm_connector_attach_property(&radeon_connector->base,
						      rdev->mode_info.underscan_vborder_property,
						      0);
		}
		break;
		break;
	case DRM_MODE_CONNECTOR_SVIDEO:
	case DRM_MODE_CONNECTOR_SVIDEO:
	case DRM_MODE_CONNECTOR_Composite:
	case DRM_MODE_CONNECTOR_Composite:
+26 −2
Original line number Original line Diff line number Diff line
@@ -1002,6 +1002,24 @@ static int radeon_modeset_create_props(struct radeon_device *rdev)
				      radeon_underscan_enum_list[i].name);
				      radeon_underscan_enum_list[i].name);
	}
	}


	rdev->mode_info.underscan_hborder_property =
		drm_property_create(rdev->ddev,
					DRM_MODE_PROP_RANGE,
					"underscan hborder", 2);
	if (!rdev->mode_info.underscan_hborder_property)
		return -ENOMEM;
	rdev->mode_info.underscan_hborder_property->values[0] = 0;
	rdev->mode_info.underscan_hborder_property->values[1] = 128;

	rdev->mode_info.underscan_vborder_property =
		drm_property_create(rdev->ddev,
					DRM_MODE_PROP_RANGE,
					"underscan vborder", 2);
	if (!rdev->mode_info.underscan_vborder_property)
		return -ENOMEM;
	rdev->mode_info.underscan_vborder_property->values[0] = 0;
	rdev->mode_info.underscan_vborder_property->values[1] = 128;

	return 0;
	return 0;
}
}


@@ -1159,7 +1177,13 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
			     ((radeon_encoder->underscan_type == UNDERSCAN_AUTO) &&
			     ((radeon_encoder->underscan_type == UNDERSCAN_AUTO) &&
			      drm_detect_hdmi_monitor(radeon_connector->edid) &&
			      drm_detect_hdmi_monitor(radeon_connector->edid) &&
			      is_hdtv_mode(mode)))) {
			      is_hdtv_mode(mode)))) {
				if (radeon_encoder->underscan_hborder != 0)
					radeon_crtc->h_border = radeon_encoder->underscan_hborder;
				else
					radeon_crtc->h_border = (mode->hdisplay >> 5) + 16;
					radeon_crtc->h_border = (mode->hdisplay >> 5) + 16;
				if (radeon_encoder->underscan_vborder != 0)
					radeon_crtc->v_border = radeon_encoder->underscan_vborder;
				else
					radeon_crtc->v_border = (mode->vdisplay >> 5) + 16;
					radeon_crtc->v_border = (mode->vdisplay >> 5) + 16;
				radeon_crtc->rmx_type = RMX_FULL;
				radeon_crtc->rmx_type = RMX_FULL;
				src_v = crtc->mode.vdisplay;
				src_v = crtc->mode.vdisplay;
+4 −0
Original line number Original line Diff line number Diff line
@@ -241,6 +241,8 @@ struct radeon_mode_info {
	struct drm_property *tmds_pll_property;
	struct drm_property *tmds_pll_property;
	/* underscan */
	/* underscan */
	struct drm_property *underscan_property;
	struct drm_property *underscan_property;
	struct drm_property *underscan_hborder_property;
	struct drm_property *underscan_vborder_property;
	/* hardcoded DFP edid from BIOS */
	/* hardcoded DFP edid from BIOS */
	struct edid *bios_hardcoded_edid;
	struct edid *bios_hardcoded_edid;


@@ -370,6 +372,8 @@ struct radeon_encoder {
	uint32_t pixel_clock;
	uint32_t pixel_clock;
	enum radeon_rmx_type rmx_type;
	enum radeon_rmx_type rmx_type;
	enum radeon_underscan_type underscan_type;
	enum radeon_underscan_type underscan_type;
	uint32_t underscan_hborder;
	uint32_t underscan_vborder;
	struct drm_display_mode native_mode;
	struct drm_display_mode native_mode;
	void *enc_priv;
	void *enc_priv;
	int audio_polling_active;
	int audio_polling_active;