[igt-dev] [PATCH i-g-t v2 7/9] lib/igt_chamelium: set EDID serial

Ser, Simon simon.ser at intel.com
Tue Jun 25 08:06:33 UTC 2019


On Mon, 2019-06-24 at 15:16 +0300, Arkadiusz Hiler wrote:
> On Wed, Jun 19, 2019 at 06:55:16PM +0300, Simon Ser wrote:
> > Set a different EDID serial string for each Chamelium port, so that we can
> > easily tell which DRM connector maps to a Chamelium port.
> > 
> > Signed-off-by: Simon Ser <simon.ser at intel.com>
> > ---
> >  lib/igt_chamelium.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> > index 467f1a458516..dcc59e9f0b04 100644
> > --- a/lib/igt_chamelium.c
> > +++ b/lib/igt_chamelium.c
> > @@ -587,6 +587,17 @@ struct chamelium_edid *chamelium_new_edid(struct chamelium *chamelium,
> >  const struct edid *chamelium_edid_get_raw(struct chamelium_edid *edid,
> >  					  struct chamelium_port *port)
> >  {
> > +	uint32_t *serial;
> > +
> > +	/* Product code: Chamelium */
> > +	edid->raw->prod_code[0] = 'C';
> > +	edid->raw->prod_code[1] = 'H';
> > +
> > +	/* Serial: Chamelium port ID */
> > +	serial = (uint32_t *) &edid->raw->serial;
> > +	*serial = port->id;
> > +
> > +	edid_update_checksum(edid->raw);
> >  	return edid->raw;
> >  }
> 
> Reusing the same memory and modifying it with each call is a pitfall for
> consumers of this API. Either store a copy for each connector, memcpy to
> a user provided pointer or return a copy and make the caller responsible
> for free()-ing it.
> 
> I vaugely remember fixing issues caused by abuse of similar functions
> that modifed a static memory and returning a pointer to it.

Fair enough. I think I'll go with storing a copy for each connector,
since it allows to keep the same simple API.


More information about the igt-dev mailing list