lib/igt_aux: update encoder and type names
PATCH 1/2 lib/igt_aux: update encoder and type names
Virtual, DSI, DP MST.
--- lib/igt_aux.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/igt_aux.c +5 -0
@@ -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)
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 lib/igt_aux: define actual functions for kmstest_*_str
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.
--- lib/igt_aux.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-)
lib/igt_aux.c +26 -15
@@ -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:
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str
Quoted 46 lines · 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()andkmstest_connector_type_str(). While at it, make the arrays static const.Signed-off-by Jani Nikula <[email protected]>--- lib/igt_aux.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-)lib/igt_aux.c +9
-9@@ -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" },
lib/igt_aux.c struct type_name encoder_type_names[] = { · line 969
Quoted 10 lines
lib/igt_aux.c +5
-1{ 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
Quoted 43 lines
lib/igt_aux.c +12
-5-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: Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str
Quoted 52 lines · Daniel Vetter
Quoted 51 lines · 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()andkmstest_connector_type_str(). While at it, make the arrays static const.Signed-off-by Jani Nikula <[email protected]>--- lib/igt_aux.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-)lib/igt_aux.c +10
-9@@ -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" }, + {} };
Quoted 8 lines
lib/igt_aux.c struct type_name encoder_type_names[] = { · line 969
Quoted 5 lines
lib/igt_aux.c +4
-1-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.
Quoted 45 lines
-Daniel
Quoted 43 lines
lib/igt_aux.c +12
-5-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: Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t 2/2] lib/igt_aux: define actual functions for kmstest_*_str
Quoted 11 lines · Jani Nikula
Quoted 9 lines · Daniel Vetter
lib/igt_aux.c struct type_name encoder_type_names[] = { · line 969
Quoted 5 lines · Jani Nikula
lib/igt_aux.c +4
-1-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?
Quoted 2 lines
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
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 lib/igt_kms: move gtk-doc comments next to the definition
Now that we have actual functions for kms_test_*_str since
commit 2d432fc5773df17f04283f4780dab161dd2e1c85
Author: Jani Nikula <[email protected]> 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.
--- lib/igt_aux.c | 18 ++++++++++++++++++ lib/igt_kms.h | 20 -------------------- 2 files changed, 18 insertions(+), 20 deletions(-)
lib/igt_aux.c +18 -0
@@ -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);
lib/igt_kms.h +0 -20
@@ -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);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Pushed. Thanks!
Quoted 37 lines · Jani Nikula
Virtual, DSI, DP MST.
Signed-off-by Jani Nikula <[email protected]>--- lib/igt_aux.c | 5 +++++ 1 file changed, 5 insertions(+)lib/igt_aux.c +5
-0@@ -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)Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx