* [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names @ 2016-05-11 9:42 Jani Nikula 2016-05-11 9:42 ` [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str Jani Nikula 2016-05-11 15:24 ` [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names Marius Vlad 0 siblings, 2 replies; 7+ messages in thread From: Jani Nikula @ 2016-05-11 9:42 UTC (permalink / raw) To: intel-gfx; +Cc: jani.nikula Virtual, DSI, DP MST. Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- lib/igt_aux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 68c9fba1628b..5dbbe4dd4a85 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -957,6 +957,9 @@ struct type_name encoder_type_names[] = { { DRM_MODE_ENCODER_TMDS, "TMDS" }, { DRM_MODE_ENCODER_LVDS, "LVDS" }, { DRM_MODE_ENCODER_TVDAC, "TVDAC" }, + { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, + { DRM_MODE_ENCODER_DSI, "DSI" }, + { DRM_MODE_ENCODER_DPMST, "DP MST" }, }; type_name_fn(encoder_type) @@ -985,6 +988,8 @@ struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, { DRM_MODE_CONNECTOR_TV, "TV" }, { DRM_MODE_CONNECTOR_eDP, "eDP" }, + { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, + { DRM_MODE_CONNECTOR_DSI, "DSI" }, }; type_name_fn(connector_type) -- 2.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str 2016-05-11 9:42 [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names Jani Nikula @ 2016-05-11 9:42 ` Jani Nikula 2016-05-17 9:56 ` Daniel Vetter 2016-05-11 15:24 ` [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names Marius Vlad 1 sibling, 1 reply; 7+ messages in thread From: Jani Nikula @ 2016-05-11 9:42 UTC (permalink / raw) To: intel-gfx; +Cc: jani.nikula Macro generated function definitions considered harmful. You can't find them with code search tools or grep. There may be places where such things might be useful, but this is not it. Define actual functions for kmstest_encoder_type_str(), kmstest_connector_status_str() and kmstest_connector_type_str(). While at it, make the arrays static const. Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- lib/igt_aux.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 5dbbe4dd4a85..22962dcf2be4 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -941,17 +941,17 @@ struct type_name { const char *name; }; -#define type_name_fn(res) \ -const char * kmstest_##res##_str(int type) { \ - unsigned int i; \ - for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ - if (res##_names[i].type == type) \ - return res##_names[i].name; \ - } \ - return "(invalid)"; \ +static const char *find_type_name(const struct type_name *names, int type) +{ + for (; names->name; names++) { + if (names->type == type) + return names->name; + } + + return "(invalid)"; } -struct type_name encoder_type_names[] = { +static const struct type_name encoder_type_names[] = { { DRM_MODE_ENCODER_NONE, "none" }, { DRM_MODE_ENCODER_DAC, "DAC" }, { DRM_MODE_ENCODER_TMDS, "TMDS" }, @@ -960,19 +960,27 @@ struct type_name encoder_type_names[] = { { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, { DRM_MODE_ENCODER_DSI, "DSI" }, { DRM_MODE_ENCODER_DPMST, "DP MST" }, + {} }; -type_name_fn(encoder_type) +const char *kmstest_encoder_type_str(int type) +{ + return find_type_name(encoder_type_names, type); +} -struct type_name connector_status_names[] = { +static const struct type_name connector_status_names[] = { { DRM_MODE_CONNECTED, "connected" }, { DRM_MODE_DISCONNECTED, "disconnected" }, { DRM_MODE_UNKNOWNCONNECTION, "unknown" }, + {} }; -type_name_fn(connector_status) +const char *kmstest_connector_status_str(int status) +{ + return find_type_name(connector_status_names, status); +} -struct type_name connector_type_names[] = { +static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_Unknown, "unknown" }, { DRM_MODE_CONNECTOR_VGA, "VGA" }, { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, @@ -990,10 +998,13 @@ struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_eDP, "eDP" }, { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, + {} }; -type_name_fn(connector_type) - +const char *kmstest_connector_type_str(int type) +{ + return find_type_name(connector_type_names, type); +} /** * igt_lock_mem: -- 2.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str 2016-05-11 9:42 ` [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str Jani Nikula @ 2016-05-17 9:56 ` Daniel Vetter 2016-05-17 10:05 ` Jani Nikula 0 siblings, 1 reply; 7+ messages in thread From: Daniel Vetter @ 2016-05-17 9:56 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx On Wed, May 11, 2016 at 12:42:06PM +0300, Jani Nikula wrote: > Macro generated function definitions considered harmful. You can't find > them with code search tools or grep. There may be places where such > things might be useful, but this is not it. > > Define actual functions for kmstest_encoder_type_str(), > kmstest_connector_status_str() and kmstest_connector_type_str(). While > at it, make the arrays static const. > > Signed-off-by: Jani Nikula <jani.nikula@intel.com> > --- > lib/igt_aux.c | 41 ++++++++++++++++++++++++++--------------- > 1 file changed, 26 insertions(+), 15 deletions(-) > > diff --git a/lib/igt_aux.c b/lib/igt_aux.c > index 5dbbe4dd4a85..22962dcf2be4 100644 > --- a/lib/igt_aux.c > +++ b/lib/igt_aux.c > @@ -941,17 +941,17 @@ struct type_name { > const char *name; > }; > > -#define type_name_fn(res) \ > -const char * kmstest_##res##_str(int type) { \ > - unsigned int i; \ > - for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ > - if (res##_names[i].type == type) \ > - return res##_names[i].name; \ > - } \ > - return "(invalid)"; \ > +static const char *find_type_name(const struct type_name *names, int type) > +{ > + for (; names->name; names++) { > + if (names->type == type) > + return names->name; > + } > + > + return "(invalid)"; > } > > -struct type_name encoder_type_names[] = { > +static const struct type_name encoder_type_names[] = { > { DRM_MODE_ENCODER_NONE, "none" }, > { DRM_MODE_ENCODER_DAC, "DAC" }, > { DRM_MODE_ENCODER_TMDS, "TMDS" }, > @@ -960,19 +960,27 @@ struct type_name encoder_type_names[] = { > { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, > { DRM_MODE_ENCODER_DSI, "DSI" }, > { DRM_MODE_ENCODER_DPMST, "DP MST" }, > + {} > }; > > -type_name_fn(encoder_type) > +const char *kmstest_encoder_type_str(int type) > +{ > + return find_type_name(encoder_type_names, type); > +} We should have gtkdoc for these now too, or maybe we had but somewhere else? -Daniel > > -struct type_name connector_status_names[] = { > +static const struct type_name connector_status_names[] = { > { DRM_MODE_CONNECTED, "connected" }, > { DRM_MODE_DISCONNECTED, "disconnected" }, > { DRM_MODE_UNKNOWNCONNECTION, "unknown" }, > + {} > }; > > -type_name_fn(connector_status) > +const char *kmstest_connector_status_str(int status) > +{ > + return find_type_name(connector_status_names, status); > +} > > -struct type_name connector_type_names[] = { > +static const struct type_name connector_type_names[] = { > { DRM_MODE_CONNECTOR_Unknown, "unknown" }, > { DRM_MODE_CONNECTOR_VGA, "VGA" }, > { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, > @@ -990,10 +998,13 @@ struct type_name connector_type_names[] = { > { DRM_MODE_CONNECTOR_eDP, "eDP" }, > { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, > { DRM_MODE_CONNECTOR_DSI, "DSI" }, > + {} > }; > > -type_name_fn(connector_type) > - > +const char *kmstest_connector_type_str(int type) > +{ > + return find_type_name(connector_type_names, type); > +} > > /** > * igt_lock_mem: > -- > 2.1.4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str 2016-05-17 9:56 ` Daniel Vetter @ 2016-05-17 10:05 ` Jani Nikula 2016-05-17 11:11 ` Daniel Vetter 0 siblings, 1 reply; 7+ messages in thread From: Jani Nikula @ 2016-05-17 10:05 UTC (permalink / raw) To: Daniel Vetter; +Cc: intel-gfx On Tue, 17 May 2016, Daniel Vetter <daniel@ffwll.ch> wrote: > On Wed, May 11, 2016 at 12:42:06PM +0300, Jani Nikula wrote: >> Macro generated function definitions considered harmful. You can't find >> them with code search tools or grep. There may be places where such >> things might be useful, but this is not it. >> >> Define actual functions for kmstest_encoder_type_str(), >> kmstest_connector_status_str() and kmstest_connector_type_str(). While >> at it, make the arrays static const. >> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com> >> --- >> lib/igt_aux.c | 41 ++++++++++++++++++++++++++--------------- >> 1 file changed, 26 insertions(+), 15 deletions(-) >> >> diff --git a/lib/igt_aux.c b/lib/igt_aux.c >> index 5dbbe4dd4a85..22962dcf2be4 100644 >> --- a/lib/igt_aux.c >> +++ b/lib/igt_aux.c >> @@ -941,17 +941,17 @@ struct type_name { >> const char *name; >> }; >> >> -#define type_name_fn(res) \ >> -const char * kmstest_##res##_str(int type) { \ >> - unsigned int i; \ >> - for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ >> - if (res##_names[i].type == type) \ >> - return res##_names[i].name; \ >> - } \ >> - return "(invalid)"; \ >> +static const char *find_type_name(const struct type_name *names, int type) >> +{ >> + for (; names->name; names++) { >> + if (names->type == type) >> + return names->name; >> + } >> + >> + return "(invalid)"; >> } >> >> -struct type_name encoder_type_names[] = { >> +static const struct type_name encoder_type_names[] = { >> { DRM_MODE_ENCODER_NONE, "none" }, >> { DRM_MODE_ENCODER_DAC, "DAC" }, >> { DRM_MODE_ENCODER_TMDS, "TMDS" }, >> @@ -960,19 +960,27 @@ struct type_name encoder_type_names[] = { >> { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, >> { DRM_MODE_ENCODER_DSI, "DSI" }, >> { DRM_MODE_ENCODER_DPMST, "DP MST" }, >> + {} >> }; >> >> -type_name_fn(encoder_type) >> +const char *kmstest_encoder_type_str(int type) >> +{ >> + return find_type_name(encoder_type_names, type); >> +} > > We should have gtkdoc for these now too, or maybe we had but somewhere > else? We still do, in igt_kms.h, where they didn't help me in the least finding the definitions... BR, Jani. > -Daniel > >> >> -struct type_name connector_status_names[] = { >> +static const struct type_name connector_status_names[] = { >> { DRM_MODE_CONNECTED, "connected" }, >> { DRM_MODE_DISCONNECTED, "disconnected" }, >> { DRM_MODE_UNKNOWNCONNECTION, "unknown" }, >> + {} >> }; >> >> -type_name_fn(connector_status) >> +const char *kmstest_connector_status_str(int status) >> +{ >> + return find_type_name(connector_status_names, status); >> +} >> >> -struct type_name connector_type_names[] = { >> +static const struct type_name connector_type_names[] = { >> { DRM_MODE_CONNECTOR_Unknown, "unknown" }, >> { DRM_MODE_CONNECTOR_VGA, "VGA" }, >> { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, >> @@ -990,10 +998,13 @@ struct type_name connector_type_names[] = { >> { DRM_MODE_CONNECTOR_eDP, "eDP" }, >> { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, >> { DRM_MODE_CONNECTOR_DSI, "DSI" }, >> + {} >> }; >> >> -type_name_fn(connector_type) >> - >> +const char *kmstest_connector_type_str(int type) >> +{ >> + return find_type_name(connector_type_names, type); >> +} >> >> /** >> * igt_lock_mem: >> -- >> 2.1.4 >> >> _______________________________________________ >> Intel-gfx mailing list >> Intel-gfx@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str 2016-05-17 10:05 ` Jani Nikula @ 2016-05-17 11:11 ` Daniel Vetter 2016-05-17 11:44 ` [PATCH] lib/igt_kms: move gtk-doc comments next to the definition Jani Nikula 0 siblings, 1 reply; 7+ messages in thread From: Daniel Vetter @ 2016-05-17 11:11 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx On Tue, May 17, 2016 at 01:05:13PM +0300, Jani Nikula wrote: > On Tue, 17 May 2016, Daniel Vetter <daniel@ffwll.ch> wrote: > > On Wed, May 11, 2016 at 12:42:06PM +0300, Jani Nikula wrote: > >> -type_name_fn(encoder_type) > >> +const char *kmstest_encoder_type_str(int type) > >> +{ > >> + return find_type_name(encoder_type_names, type); > >> +} > > > > We should have gtkdoc for these now too, or maybe we had but somewhere > > else? > > We still do, in igt_kms.h, where they didn't help me in the least > finding the definitions... Can you please move the to the .c file then in a quick follow-up? We tend to only have gtkdoc in headers for #defines and static inlines. For consistency and OCD, and because that way the gtkdoc is always next to the code it documents (like in the kernel). Ack from me and just push the patch right way. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] lib/igt_kms: move gtk-doc comments next to the definition 2016-05-17 11:11 ` Daniel Vetter @ 2016-05-17 11:44 ` Jani Nikula 0 siblings, 0 replies; 7+ messages in thread From: Jani Nikula @ 2016-05-17 11:44 UTC (permalink / raw) To: Daniel Vetter, Jani Nikula; +Cc: intel-gfx Now that we have actual functions for kms_test_*_str since commit 2d432fc5773df17f04283f4780dab161dd2e1c85 Author: Jani Nikula <jani.nikula@intel.com> Date: Wed May 11 12:42:06 2016 +0300 lib/igt_aux: define actual functions for kmstest_*_str move also the gtk-doc comments next to the definitions, for consistency. Acked-by: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- lib/igt_aux.c | 18 ++++++++++++++++++ lib/igt_kms.h | 20 -------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 6c3eb1f42fab..27b74aec8461 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -942,6 +942,12 @@ static const struct type_name encoder_type_names[] = { {} }; +/** + * kmstest_encoder_type_str: + * @type: DRM_MODE_ENCODER_* enumeration value + * + * Returns: A string representing the drm encoder @type. + */ const char *kmstest_encoder_type_str(int type) { return find_type_name(encoder_type_names, type); @@ -954,6 +960,12 @@ static const struct type_name connector_status_names[] = { {} }; +/** + * kmstest_connector_status_str: + * @status: DRM_MODE_* connector status value + * + * Returns: A string representing the drm connector status @status. + */ const char *kmstest_connector_status_str(int status) { return find_type_name(connector_status_names, status); @@ -980,6 +992,12 @@ static const struct type_name connector_type_names[] = { {} }; +/** + * kmstest_connector_type_str: + * @type: DRM_MODE_CONNECTOR_* enumeration value + * + * Returns: A string representing the drm connector @type. + */ const char *kmstest_connector_type_str(int type) { return find_type_name(connector_type_names, type); diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 5c8340171ab6..7aad8c8c2153 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -77,28 +77,8 @@ enum port { */ #define kmstest_port_name(port) ((port) + 'A') -/** - * kmstest_encoder_type_str: - * @type: DRM_MODE_ENCODER_* enumeration value - * - * Returns: A string representing the drm encoder @type. - */ const char *kmstest_encoder_type_str(int type); - -/** - * kmstest_connector_status_str: - * @status: DRM_MODE_* connector status value - * - * Returns: A string representing the drm connector status @status. - */ const char *kmstest_connector_status_str(int status); - -/** - * kmstest_connector_type_str: - * @type: DRM_MODE_CONNECTOR_* enumeration value - * - * Returns: A string representing the drm connector @type. - */ const char *kmstest_connector_type_str(int type); void kmstest_dump_mode(drmModeModeInfo *mode); -- 2.1.4 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names 2016-05-11 9:42 [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names Jani Nikula 2016-05-11 9:42 ` [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str Jani Nikula @ 2016-05-11 15:24 ` Marius Vlad 1 sibling, 0 replies; 7+ messages in thread From: Marius Vlad @ 2016-05-11 15:24 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx [-- Attachment #1.1: Type: text/plain, Size: 1244 bytes --] Pushed. Thanks! On Wed, May 11, 2016 at 12:42:05PM +0300, Jani Nikula wrote: > Virtual, DSI, DP MST. > > Signed-off-by: Jani Nikula <jani.nikula@intel.com> > --- > lib/igt_aux.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/lib/igt_aux.c b/lib/igt_aux.c > index 68c9fba1628b..5dbbe4dd4a85 100644 > --- a/lib/igt_aux.c > +++ b/lib/igt_aux.c > @@ -957,6 +957,9 @@ struct type_name encoder_type_names[] = { > { DRM_MODE_ENCODER_TMDS, "TMDS" }, > { DRM_MODE_ENCODER_LVDS, "LVDS" }, > { DRM_MODE_ENCODER_TVDAC, "TVDAC" }, > + { DRM_MODE_ENCODER_VIRTUAL, "Virtual" }, > + { DRM_MODE_ENCODER_DSI, "DSI" }, > + { DRM_MODE_ENCODER_DPMST, "DP MST" }, > }; > > type_name_fn(encoder_type) > @@ -985,6 +988,8 @@ struct type_name connector_type_names[] = { > { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, > { DRM_MODE_CONNECTOR_TV, "TV" }, > { DRM_MODE_CONNECTOR_eDP, "eDP" }, > + { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, > + { DRM_MODE_CONNECTOR_DSI, "DSI" }, > }; > > type_name_fn(connector_type) > -- > 2.1.4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx [-- Attachment #1.2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] [-- Attachment #2: Type: text/plain, Size: 160 bytes --] _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-05-17 11:44 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-11 9:42 [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names Jani Nikula 2016-05-11 9:42 ` [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str Jani Nikula 2016-05-17 9:56 ` Daniel Vetter 2016-05-17 10:05 ` Jani Nikula 2016-05-17 11:11 ` Daniel Vetter 2016-05-17 11:44 ` [PATCH] lib/igt_kms: move gtk-doc comments next to the definition Jani Nikula 2016-05-11 15:24 ` [PATCH i-g-t 1/2] lib/igt_aux: update encoder and type names Marius Vlad
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox