All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kieran.bingham@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
Subject: Re: [kms-test] [PATCH 04/10] kmstest: Move props value formatting to AtomicRequest
Date: Wed, 29 Jun 2022 21:13:32 +0300	[thread overview]
Message-ID: <YryWTNohK7ejgh6K@pendragon.ideasonboard.com> (raw)
In-Reply-To: <165651700917.2049236.8177612268777322664@Monstersaurus>

On Wed, Jun 29, 2022 at 04:36:49PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2022-06-10 00:40:25)
> > Centralize props value formatting in the AtomicRequest.add() function to
> > avoid having to call it manually through the code base.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  tests/kmstest.py | 18 ++++++++++--------
> >  1 file changed, 10 insertions(+), 8 deletions(-)
> > 
> > diff --git a/tests/kmstest.py b/tests/kmstest.py
> > index 14e28cd47fbd..2afaa513aa4d 100755
> > --- a/tests/kmstest.py
> > +++ b/tests/kmstest.py
> > @@ -258,15 +258,20 @@ class AtomicRequest(pykms.AtomicReq):
> >          self.__test = test
> >          self.__props = {}
> >  
> > +    def __format_props(self, props):
> 
> This is only validating the value arguements right, to ensure they are
> limited to 64 bit...

That's right, and it's mostly for negative values, that Python would
otherwise handle incorrectly (if I recall correctly that's due to the
bindings for the add() method mapping to the uint64_t, without automatic
conversion for negative values).

> > +        return {k: v & ((1 << 64) - 1) for k, v in props.items()}
> > +
> 
> Not this patch, but seems like 'add()' would benefit from some
> documentation here to show how to use it, what to pass etc.

Good point.

> It's complex to read from just this context, but I can just about see
> that this patch is cleaning things up.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> >      def add(self, obj, *kwargs):
> >          if obj.id not in self.__props:
> >              self.__props[obj.id] = {}
> > -        props = self.__props[obj.id]
> > +        obj_props = self.__props[obj.id]
> >  
> >          if len(kwargs) == 1 and isinstance(kwargs[0], collections.abc.Mapping):
> > -            props.update(kwargs[0])
> > +            props = self.__format_props(kwargs[0])
> >          elif len(kwargs) == 2:
> > -            props[kwargs[0]] = kwargs[1]
> > +            props = self.__format_props({ kwargs[0]: = kwargs[1] })
> > +
> > +        obj_props.update(props)
> >  
> >          super().add(obj, *kwargs)
> >  
> > @@ -309,9 +314,6 @@ class KMSTest(object):
> >      def __del__(self):
> >          self.logger.close()
> >  
> > -    def __format_props(self, props):
> > -        return {k: v & ((1 << 64) - 1) for k, v in props.items()}
> > -
> >      def atomic_crtc_disable(self, crtc, sync=True):
> >          req = AtomicRequest(self)
> >          req.add(crtc, {'ACTIVE': 0, 'MODE_ID': 0})
> > @@ -368,7 +370,7 @@ class KMSTest(object):
> >  
> >      def atomic_plane_set(self, plane, crtc, source, destination, fb, sync=False):
> >          req = AtomicRequest(self)
> > -        req.add(plane, self.__format_props({
> > +        req.add(plane, {
> >                      'FB_ID': fb.id,
> >                      'CRTC_ID': crtc.id,
> >                      'SRC_X': int(source.left * 65536),
> > @@ -379,7 +381,7 @@ class KMSTest(object):
> >                      'CRTC_Y': destination.top,
> >                      'CRTC_W': destination.width,
> >                      'CRTC_H': destination.height,
> > -        }))
> > +        })
> >          if sync:
> >              return req.commit_sync()
> >          else:

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-06-29 18:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 23:40 [kms-test] [PATCH 00/10] Test plane alpha and zpos control Laurent Pinchart
2022-06-09 23:40 ` [kms-test] [PATCH 01/10] tests: Replace double quotes with single quotes Laurent Pinchart
2022-06-29 13:22   ` Kieran Bingham
2022-06-09 23:40 ` [kms-test] [PATCH 02/10] tests: Convert to formatted string literals Laurent Pinchart
2022-06-29 15:28   ` Kieran Bingham
2022-06-09 23:40 ` [kms-test] [PATCH 03/10] tests: allplanes: Log the plane IDs Laurent Pinchart
2022-06-29 15:30   ` Kieran Bingham
2022-06-29 18:06     ` Laurent Pinchart
2022-06-09 23:40 ` [kms-test] [PATCH 04/10] kmstest: Move props value formatting to AtomicRequest Laurent Pinchart
2022-06-29 15:36   ` Kieran Bingham
2022-06-29 18:13     ` Laurent Pinchart [this message]
2022-06-09 23:40 ` [kms-test] [PATCH 05/10] kmstest: Support specifying property values in percents Laurent Pinchart
2022-06-29 15:39   ` Kieran Bingham
2022-06-09 23:40 ` [kms-test] [PATCH 06/10] kmstest: Support specifying alpha value for planes Laurent Pinchart
2022-06-29 15:45   ` Kieran Bingham
2022-06-09 23:40 ` [kms-test] [PATCH 07/10] tests: Add plane alpha test Laurent Pinchart
2022-06-29 15:48   ` Kieran Bingham
2022-06-09 23:40 ` [kms-test] [PATCH 08/10] kmstest: Support specifying zpos value for planes Laurent Pinchart
2022-06-29 15:48   ` Kieran Bingham
2022-06-09 23:40 ` [kms-test] [PATCH 09/10] tests: Add plane zpos test Laurent Pinchart
2022-06-29 15:52   ` Kieran Bingham
2022-06-29 18:08     ` Laurent Pinchart
2022-06-09 23:40 ` [kms-test] [PATCH 10/10] tests: Rename kms-test-planeposition.py to kms-test-plane-position.py Laurent Pinchart
2022-06-29 15:44   ` Kieran Bingham

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=YryWTNohK7ejgh6K@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.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 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.