From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH xf86-video-intel 1/2] sna: Refactor property parsing
Date: Mon, 18 Feb 2019 21:50:51 +0200 [thread overview]
Message-ID: <20190218195052.1729-1-ville.syrjala@linux.intel.com> (raw)
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Generalize the code that parses the plane properties to be useable
for crtc (or any kms object) properties as well.
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
src/sna/sna_display.c | 67 +++++++++++++++++++++++++++++++------------
1 file changed, 48 insertions(+), 19 deletions(-)
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index fe67f85b62f1..916cc3c04e07 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -215,6 +215,7 @@ struct sna_crtc {
uint32_t rotation;
struct plane {
uint32_t id;
+ uint32_t type;
struct {
uint32_t prop;
uint32_t supported;
@@ -3391,33 +3392,40 @@ void sna_crtc_set_sprite_colorspace(xf86CrtcPtr crtc,
p->color_encoding.values[colorspace]);
}
-static int plane_details(struct sna *sna, struct plane *p)
+typedef void (*parse_prop_func)(struct sna *sna,
+ struct drm_mode_get_property *prop,
+ uint64_t value,
+ void *data);
+static void parse_props(struct sna *sna,
+ uint32_t obj_type, uint32_t obj_id,
+ parse_prop_func parse_prop,
+ void *data)
{
#define N_STACK_PROPS 32 /* must be a multiple of 2 */
struct local_mode_obj_get_properties arg;
uint64_t stack[N_STACK_PROPS + N_STACK_PROPS/2];
uint64_t *values = stack;
uint32_t *props = (uint32_t *)(values + N_STACK_PROPS);
- int i, type = DRM_PLANE_TYPE_OVERLAY;
+ int i;
memset(&arg, 0, sizeof(struct local_mode_obj_get_properties));
- arg.obj_id = p->id;
- arg.obj_type = LOCAL_MODE_OBJECT_PLANE;
+ arg.obj_id = obj_id;
+ arg.obj_type = obj_type;
arg.props_ptr = (uintptr_t)props;
arg.prop_values_ptr = (uintptr_t)values;
arg.count_props = N_STACK_PROPS;
if (drmIoctl(sna->kgem.fd, LOCAL_IOCTL_MODE_OBJ_GETPROPERTIES, &arg))
- return -1;
+ return;
DBG(("%s: object %d (type %x) has %d props\n", __FUNCTION__,
- p->id, LOCAL_MODE_OBJECT_PLANE, arg.count_props));
+ obj_id, obj_type, arg.count_props));
if (arg.count_props > N_STACK_PROPS) {
values = malloc(2*sizeof(uint64_t)*arg.count_props);
if (values == NULL)
- return -1;
+ return;
props = (uint32_t *)(values + arg.count_props);
@@ -3444,25 +3452,46 @@ static int plane_details(struct sna *sna, struct plane *p)
DBG(("%s: prop[%d] .id=%ld, .name=%s, .flags=%x, .value=%ld\n", __FUNCTION__, i,
(long)props[i], prop.name, (unsigned)prop.flags, (long)values[i]));
- if (strcmp(prop.name, "type") == 0) {
- type = values[i];
- } else if (prop_is_rotation(&prop)) {
- parse_rotation_prop(sna, p, &prop, values[i]);
- } else if (prop_is_color_encoding(&prop)) {
- parse_color_encoding_prop(sna, p, &prop, values[i]);
- }
+ parse_prop(sna, &prop, values[i], data);
}
+ if (values != stack)
+ free(values);
+
+#undef N_STACK_PROPS
+}
+
+static bool prop_is_type(const struct drm_mode_get_property *prop)
+{
+ return prop_has_type_and_name(prop, 1, "type");
+}
+
+static void plane_parse_prop(struct sna *sna,
+ struct drm_mode_get_property *prop,
+ uint64_t value, void *data)
+{
+ struct plane *p = data;
+
+ if (prop_is_type(prop))
+ p->type = value;
+ else if (prop_is_rotation(prop))
+ parse_rotation_prop(sna, p, prop, value);
+ else if (prop_is_color_encoding(prop))
+ parse_color_encoding_prop(sna, p, prop, value);
+}
+
+static int plane_details(struct sna *sna, struct plane *p)
+{
+ parse_props(sna, LOCAL_MODE_OBJECT_PLANE, p->id,
+ plane_parse_prop, p);
+
p->rotation.supported &= DBG_NATIVE_ROTATION;
if (!xf86ReturnOptValBool(sna->Options, OPTION_ROTATION, TRUE))
p->rotation.supported = RR_Rotate_0;
- if (values != stack)
- free(values);
+ DBG(("%s: plane=%d type=%d\n", __FUNCTION__, p->id, p->type));
- DBG(("%s: plane=%d type=%d\n", __FUNCTION__, p->id, type));
- return type;
-#undef N_STACK_PROPS
+ return p->type;
}
static void add_sprite_plane(struct sna_crtc *crtc,
--
2.19.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next reply other threads:[~2019-02-18 19:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 19:50 Ville Syrjala [this message]
2019-02-18 19:50 ` [PATCH xf86-video-intel 2/2] sna: Support 10bpc gamma via the GAMMA_LUT crtc property Ville Syrjala
2019-03-01 13:13 ` Chris Wilson
2019-04-26 16:32 ` [PATCH xf86-video-intel v2 " Ville Syrjala
2019-05-16 19:54 ` Mario Kleiner
2019-05-17 13:49 ` Ville Syrjälä
2019-05-17 13:51 ` [PATCH xf86-video-intel v3 " Ville Syrjala
2019-07-09 18:34 ` Mario Kleiner
2019-07-10 11:59 ` Chris Wilson
2019-04-26 16:32 ` [PATCH xf86-video-intel v2 1/2] sna: Refactor property parsing Ville Syrjala
2019-05-16 19:39 ` Mario Kleiner
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=20190218195052.1729-1-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox