diff mbox

[v3,1/3] modetest: introduce get_prop_info() for getting property id and type

Message ID 1442976314-5792-1-git-send-email-human.hwang@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hyungwon Hwang Sept. 23, 2015, 2:45 a.m. UTC
Modetest gets the property name from user to set it. So the name must be
converted to its id. Until now, this is done in the set_property(). But to
support atomic modeset in modetest, this logic should be separated from the
fuction, because atomic modeset and legacy modeset use different IOCTLs.

Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
---
 tests/modetest/modetest.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

--
2.4.3

Comments

Emil Velikov Nov. 26, 2015, 4:42 p.m. UTC | #1
Hi Hyungwon

I completely missed out that you've sent an updated version of the
series. I will take a look at them later on tonight. Meanwhile have
you looked at the atomic tests/helpers work from Thierry [1] ? It
creates nice simple helpers (as opposed to a single massive C file
like modetest) and I'm leaning that there is quite a lot of code that
can be reused from there.

Speaking of which Thierry,
What is happening with these patches ? Last time you've respun them
I've pinged you to send them over for inclusion. There was a trivial
fix needed here or there but they were in pretty good shape.

Thanks
Emil

[1] http://cgit.freedesktop.org/~tagr/drm/
Hyungwon Hwang Nov. 27, 2015, 2:37 a.m. UTC | #2
Hello all,

+To Thierry Reding

On Thu, 26 Nov 2015 16:42:01 +0000
Emil Velikov <emil.l.velikov@gmail.com> wrote:

> Hi Hyungwon
> 
> I completely missed out that you've sent an updated version of the
> series. I will take a look at them later on tonight. Meanwhile have
> you looked at the atomic tests/helpers work from Thierry [1] ? It
> creates nice simple helpers (as opposed to a single massive C file
> like modetest) and I'm leaning that there is quite a lot of code that
> can be reused from there.
> 
> Speaking of which Thierry,
> What is happening with these patches ? Last time you've respun them
> I've pinged you to send them over for inclusion. There was a trivial
> fix needed here or there but they were in pretty good shape.

Yes. I checked it now. It would be more clear concise, if they comes.
Would it be better to wait Thierry for sending them again? Can you
afford to do that, Thierry?

BRs,
Hyungwon Hwang


> 
> Thanks
> Emil
> 
> [1] http://cgit.freedesktop.org/~tagr/drm/
>
Thierry Reding Dec. 7, 2015, 4:37 p.m. UTC | #3
On Fri, Nov 27, 2015 at 11:37:33AM +0900, Hyungwon Hwang wrote:
> Hello all,
> 
> +To Thierry Reding
> 
> On Thu, 26 Nov 2015 16:42:01 +0000
> Emil Velikov <emil.l.velikov@gmail.com> wrote:
> 
> > Hi Hyungwon
> > 
> > I completely missed out that you've sent an updated version of the
> > series. I will take a look at them later on tonight. Meanwhile have
> > you looked at the atomic tests/helpers work from Thierry [1] ? It
> > creates nice simple helpers (as opposed to a single massive C file
> > like modetest) and I'm leaning that there is quite a lot of code that
> > can be reused from there.
> > 
> > Speaking of which Thierry,
> > What is happening with these patches ? Last time you've respun them
> > I've pinged you to send them over for inclusion. There was a trivial
> > fix needed here or there but they were in pretty good shape.
> 
> Yes. I checked it now. It would be more clear concise, if they comes.
> Would it be better to wait Thierry for sending them again? Can you
> afford to do that, Thierry?

Yeah, I think I can do that. It'll probably take until tomorrow for me
to find a free slot to rebase and send out again.

Thierry
diff mbox

Patch

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 3b01918..08ecf58 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -894,12 +894,11 @@  struct property_arg {
 	uint64_t value;
 };

-static void set_property(struct device *dev, struct property_arg *p)
+static int get_prop_info(struct resources *resources, struct property_arg *p,
+							const char *obj_type)
 {
 	drmModeObjectProperties *props = NULL;
 	drmModePropertyRes **props_info = NULL;
-	const char *obj_type;
-	int ret;
 	int i;

 	p->obj_type = 0;
@@ -918,21 +917,21 @@  static void set_property(struct device *dev, struct property_arg *p)
 		}								\
 	} while(0)								\

-	find_object(dev->resources, res, crtc, CRTC);
+	find_object(resources, res, crtc, CRTC);
 	if (p->obj_type == 0)
-		find_object(dev->resources, res, connector, CONNECTOR);
+		find_object(resources, res, connector, CONNECTOR);
 	if (p->obj_type == 0)
-		find_object(dev->resources, plane_res, plane, PLANE);
+		find_object(resources, plane_res, plane, PLANE);
 	if (p->obj_type == 0) {
 		fprintf(stderr, "Object %i not found, can't set property\n",
 			p->obj_id);
-			return;
+			return -1;
 	}

 	if (!props) {
 		fprintf(stderr, "%s %i has no properties\n",
 			obj_type, p->obj_id);
-		return;
+		return -1;
 	}

 	for (i = 0; i < (int)props->count_props; ++i) {
@@ -945,11 +944,23 @@  static void set_property(struct device *dev, struct property_arg *p)
 	if (i == (int)props->count_props) {
 		fprintf(stderr, "%s %i has no %s property\n",
 			obj_type, p->obj_id, p->name);
-		return;
+		return -1;
 	}

 	p->prop_id = props->props[i];

+	return 0;
+}
+
+static void set_property(struct device *dev, struct property_arg *p)
+{
+	int ret;
+	const char *obj_type = NULL;
+
+	ret = get_prop_info(dev->resources, p, obj_type);
+	if (ret < 0)
+		return;
+
 	ret = drmModeObjectSetProperty(dev->fd, p->obj_id, p->obj_type,
 				       p->prop_id, p->value);
 	if (ret < 0)