From: Paulo Zanoni <przanoni@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH RFC xf86-video-intel 2/2] Add underscan properties
Date: Thu, 29 Mar 2012 18:30:20 -0300 [thread overview]
Message-ID: <1333056620-3548-2-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <1333056620-3548-1-git-send-email-przanoni@gmail.com>
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
In the Kernel side, these are crtc properties (since in the hardware,
underscan use the panel fitters, which are attached to the pipes).
Ideally we should make these as crtc properties too, but since xrandr
doesn't have support for them, we expose the atoms as output
properties. This is not the best solution, but making the kernel
underscan properties be output properties instead of crtc properties
would be even more wrong.
We still need to change the sna/ code.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
src/intel_display.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 115 insertions(+), 1 deletions(-)
diff --git a/src/intel_display.c b/src/intel_display.c
index 0dd85b8..c669981 100644
--- a/src/intel_display.c
+++ b/src/intel_display.c
@@ -83,6 +83,8 @@ struct intel_crtc {
xf86CrtcPtr crtc;
struct list link;
drmModePropertyPtr rotation_prop;
+ drmModePropertyPtr underscan_h_prop;
+ drmModePropertyPtr underscan_v_prop;
};
struct intel_property {
@@ -111,6 +113,8 @@ struct intel_output {
int backlight_max;
xf86OutputPtr output;
struct list link;
+ Atom underscan_h_atom;
+ Atom underscan_v_atom;
};
static void
@@ -683,6 +687,10 @@ intel_crtc_destroy(xf86CrtcPtr crtc)
if (intel_crtc->rotation_prop)
drmModeFreeProperty(intel_crtc->rotation_prop);
+ if (intel_crtc->underscan_h_prop)
+ drmModeFreeProperty(intel_crtc->underscan_h_prop);
+ if (intel_crtc->underscan_v_prop)
+ drmModeFreeProperty(intel_crtc->underscan_v_prop);
list_del(&intel_crtc->link);
free(intel_crtc);
@@ -699,6 +707,8 @@ intel_crtc_load_properties(struct intel_mode *mode,
drmModePropertyPtr prop;
crtc->rotation_prop = NULL;
+ crtc->underscan_h_prop = NULL;
+ crtc->underscan_v_prop = NULL;
props = drmModeObjectGetProperties(mode->fd, crtc_id(crtc),
DRM_MODE_OBJECT_CRTC);
@@ -707,6 +717,10 @@ intel_crtc_load_properties(struct intel_mode *mode,
prop = drmModeGetProperty(mode->fd, props->props[i]);
if (!strcmp(prop->name, "rotation"))
crtc->rotation_prop = prop;
+ else if (!strcmp(prop->name, "underscan hborder"))
+ crtc->underscan_h_prop = prop;
+ else if (!strcmp(prop->name, "underscan vborder"))
+ crtc->underscan_v_prop = prop;
else
drmModeFreeProperty(prop);
}
@@ -1109,6 +1123,8 @@ intel_output_create_resources(xf86OutputPtr output)
struct intel_output *intel_output = output->driver_private;
drmModeConnectorPtr mode_output = intel_output->mode_output;
struct intel_mode *mode = intel_output->mode;
+ struct intel_crtc *crtc;
+ Bool has_underscan_props = FALSE;
int i, j, err;
intel_output->props = calloc(mode_output->count_props,
@@ -1201,6 +1217,33 @@ intel_output_create_resources(xf86OutputPtr output)
intel_output->backlight_active_level,
FALSE);
}
+
+ list_for_each_entry(crtc, &mode->crtcs, link) {
+ if (crtc->underscan_h_prop) {
+ has_underscan_props = TRUE;
+ break;
+ }
+ }
+
+ if (has_underscan_props) {
+ intel_output_create_ranged_atom(output,
+ &intel_output->underscan_h_atom,
+ "underscan hborder", 0, 100, 0,
+ FALSE);
+ intel_output_create_ranged_atom(output,
+ &intel_output->underscan_v_atom,
+ "underscan vborder", 0, 100, 0,
+ FALSE);
+ }
+}
+
+static struct intel_crtc *
+intel_output_get_crtc(xf86OutputPtr output)
+{
+ if (output->crtc)
+ return output->crtc->driver_private;
+ else
+ return 0;
}
static Bool
@@ -1230,6 +1273,37 @@ intel_output_set_property(xf86OutputPtr output, Atom property,
return TRUE;
}
+ if (property == intel_output->underscan_h_atom ||
+ property == intel_output->underscan_v_atom) {
+ uint32_t val;
+ struct intel_crtc *intel_crtc;
+ drmModePropertyPtr drm_prop;
+
+ val = *(uint32_t *)value->data;
+ if (value->type != XA_INTEGER || value->format != 32 ||
+ value->size != 1 || val > 100)
+ return FALSE;
+
+ intel_crtc = intel_output_get_crtc(output);
+ if (intel_crtc) {
+ if (property == intel_output->underscan_h_atom)
+ drm_prop = intel_crtc->underscan_h_prop;
+ else
+ drm_prop = intel_crtc->underscan_v_prop;
+
+ if (!drm_prop)
+ return FALSE;
+
+ drmModeObjectSetProperty(mode->fd,
+ intel_crtc->mode_crtc->crtc_id,
+ DRM_MODE_OBJECT_CRTC,
+ drm_prop->prop_id,
+ (uint64_t) val);
+
+ }
+ return TRUE;
+ }
+
for (i = 0; i < intel_output->num_props; i++) {
struct intel_property *p = &intel_output->props[i];
@@ -1280,10 +1354,11 @@ static Bool
intel_output_get_property(xf86OutputPtr output, Atom property)
{
struct intel_output *intel_output = output->driver_private;
+ struct intel_mode *mode = intel_output->mode;
int err;
+ INT32 val;
if (property == backlight_atom || property == backlight_deprecated_atom) {
- INT32 val;
if (! intel_output->backlight_iface)
return FALSE;
@@ -1304,6 +1379,45 @@ intel_output_get_property(xf86OutputPtr output, Atom property)
return TRUE;
}
+ if (property == intel_output->underscan_h_atom ||
+ property == intel_output->underscan_v_atom) {
+ struct intel_crtc *intel_crtc = NULL;
+ drmModeObjectPropertiesPtr props;
+ unsigned int i;
+
+ intel_crtc = intel_output_get_crtc(output);
+
+ if (!intel_crtc) {
+ val = 0;
+ } else {
+ props = drmModeObjectGetProperties(mode->fd,
+ intel_crtc->mode_crtc->crtc_id,
+ DRM_MODE_OBJECT_CRTC);
+ if (!props)
+ return FALSE;
+
+ for (i = 0; i < props->count_props; i++) {
+ if (props->props[i] == intel_crtc->underscan_h_prop->prop_id &&
+ property == intel_output->underscan_h_atom)
+ val = props->prop_values[i];
+ else if (props->props[i] == intel_crtc->underscan_v_prop->prop_id &&
+ property == intel_output->underscan_v_atom)
+ val = props->prop_values[i];
+ }
+ drmModeFreeObjectProperties(props);
+ }
+
+ err = RRChangeOutputProperty(output->randr_output, property,
+ XA_INTEGER, 32, PropModeReplace,
+ 1, &val, FALSE, TRUE);
+ if (err != 0) {
+ xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+ "RRChangeOutputProperty error, %d\n", err);
+ return FALSE;
+ }
+ return TRUE;
+ }
+
return FALSE;
}
--
1.7.9.1
next prev parent reply other threads:[~2012-03-29 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 21:30 [PATCH RFC xf86-video-intel 1/2] Update the rotation property whenever we change the rotation Paulo Zanoni
2012-03-29 21:30 ` Paulo Zanoni [this message]
2012-03-29 22:19 ` [PATCH RFC xf86-video-intel 2/2] Add underscan properties Chris Wilson
2012-03-30 11:32 ` Ville Syrjälä
2012-03-29 22:16 ` [PATCH RFC xf86-video-intel 1/2] Update the rotation property whenever we change the rotation Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1333056620-3548-2-git-send-email-przanoni@gmail.com \
--to=przanoni@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.