modetest: introduce get_prop_info() for getting property id and type
PATCH 1/3 modetest: introduce get_prop_info() for getting property id and type
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.
--- tests/modetest/modetest.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
tests/modetest/modetest.c +21 -10
@@ -866,12 +866,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, +char *obj_type) {drmModeObjectProperties *props =NULL ;drmModePropertyRes **props_info =NULL ; -const char *obj_type; -int ret;int i; p->obj_type =0 ;
@@ -884,27 +883,27 @@ static void set_property(struct device *dev, struct property_arg *p) if (obj->type->type##_id != p->obj_id) \continue ; \ p->obj_type = DRM_MODE_OBJECT_##Type; \ - obj_type = #Type; \ + obj_type = (char *)#Type; \ props = obj->props; \ props_info = obj->props_info; \ } \ } 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) {
@@ -917,11 +916,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; +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 )
Signature · 6 lines
2.4.3 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/3 modetest: add atomic modeset support
This patch adds support for atomic modeset. Using -a option, user can make modeset to use DRM_IOCTL_MODE_ATOMIC instead of legacy IOCTLs. Also, by using -w option, user can set the property as before.
--- tests/modetest/modetest.c | 221 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 187 insertions(+), 34 deletions(-)
tests/modetest/modetest.c +187 -34
@@ -1444,25 +1444,32 @@ static int parse_property(struct property_arg *p, const char *arg)static void usage (char *name) { -fprintf (stderr,"usage: %s [-cDdefMPpsCvw]\n" , name); +fprintf (stderr,"usage: %s [-acDdefMPpsCvw]\n" , name); +fprintf (stderr,"\tA: supported in atomic modeset\n" ); +fprintf (stderr,"\tL: supported in legacy modeset\n" ); -fprintf (stderr,"\n Query options:\n\n" ); +fprintf (stderr,"\n Query options: [AL]\n\n" );fprintf (stderr,"\t-c\tlist connectors\n" );fprintf (stderr,"\t-e\tlist encoders\n" );fprintf (stderr,"\t-f\tlist framebuffers\n" );fprintf (stderr,"\t-p\tlist CRTCs and planes (pipes)\n" ); -fprintf (stderr,"\n Test options:\n\n" ); +fprintf (stderr,"\n Common Test options: [AL]\n\n" ); +fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property\n" ); + +fprintf (stderr,"\n Atomic Test options: [A]\n\n" ); +fprintf (stderr,"\t-a\tuse atomic modeset\n" ); + +fprintf (stderr,"\n Legacy test options: [L]\n\n" );fprintf (stderr,"\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n" );fprintf (stderr,"\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]\tset a mode\n" );fprintf (stderr,"\t-C\ttest hw cursor\n" );fprintf (stderr,"\t-v\ttest vsynced page flipping\n" ); -fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property\n" );fprintf (stderr,"\n Generic options:\n\n" ); -fprintf (stderr,"\t-d\tdrop master after mode set\n" ); -fprintf (stderr,"\t-M module\tuse the given driver\n" ); -fprintf (stderr,"\t-D device\tuse the given device\n" ); +fprintf (stderr,"\t-d\tdrop master after mode set [L]\n" ); +fprintf (stderr,"\t-M module\tuse the given driver [AL]\n" ); +fprintf (stderr,"\t-D device\tuse the given device [AL]\n" );fprintf (stderr,"\n\tDefault is to dump all info.\n" );exit (0 );
@@ -1495,7 +1502,132 @@ static int cursor_supported(void)return 1 ; } -static char optstr[] ="cdD:efM:P:ps:Cvw:" ; +static uint32_t is_obj_id_in_prop_args (struct property_arg *prop_args, +unsigned int prop_count,uint32_t obj_id) +{ +unsigned int i; + +for (i =0 ; i < prop_count; i++) +if (obj_id == prop_args[i].obj_id) +return true; + +return false; +} + +static int get_value_in_prop_args (struct property_arg *prop_args, +unsigned int prop_count,uint32_t obj_id, +const char *name) +{ +unsigned int i; + +for (i =0 ; i < prop_count; i++) +if (prop_args[i].obj_id == obj_id && + !strcmp (prop_args[i].name, name)) +return (int )prop_args[i].value; + +return -1 ; +} + +static uint32_t get_atomic_plane_prop_id (struct resources *res,uint32_t obj_id, +const char *name) +{ +drmModePropertyRes *props_info; +struct plane *plane; +unsigned int i, j; + +for (i =0 ; i < res->plane_res->count_planes; i++) { + plane = &res->planes[i]; +if (plane->plane->plane_id != obj_id) +continue ; + +for (j =0 ; j < plane->props->count_props; j++) { + props_info = plane->props_info[j]; +if (!strcmp (props_info->name, name)) +return props_info->prop_id; + } + } + +return 0 ; +} + +static int allocate_fb (struct device *dev,drmModeAtomicReqPtr req,struct resources *res, +uint32_t width,uint32_t height,uint32_t pixel_format, +int pattern,struct bo **bo,uint32_t *fb_id) +{ +uint32_t handles[4 ] = {0 }, pitches[4 ] = {0 }, offsets[4 ] = {0 }; +int ret; + + *bo =bo_create (dev->fd, pixel_format, width, height, + handles, pitches, offsets, pattern); +if (*bo ==NULL ) { +fprintf (stderr,"failed to create bo (%ux%u): %s\n" , + width, height,strerror (errno)); +return -1 ; + } + + ret =drmModeAddFB2 (dev->fd, width, height, pixel_format, + handles, pitches, offsets, fb_id,0 ); +if (ret) { +fprintf (stderr,"failed to add fb (%ux%u): %s\n" , + width, height,strerror (errno)); +bo_destroy (*bo); +return ret; + } + +return 0 ; +} + +static int allocate_fbs (struct device *dev,drmModeAtomicReqPtr req, +struct resources *res,struct property_arg *prop_args, +unsigned int prop_count) +{ +uint32_t plane_id, fb_obj_id, fb_id, i, width, height, pixel_format; +struct bo *bo; +int ret; + +for (i =0 ; i < res->plane_res->count_planes; i++) { + plane_id = res->planes[i].plane->plane_id; +if (!is_obj_id_in_prop_args (prop_args, prop_count, plane_id)) +continue ; + + width =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_W" ); + height =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_H" ); + pixel_format =DRM_FORMAT_XRGB8888 ; + + ret =allocate_fb (dev, req, res, width, height, pixel_format, +PATTERN_SMPTE , &bo, &fb_id); +if (ret <0 ) +return ret; + + dev->mode.bo = bo; + dev->mode.fb_id = fb_id; + + fb_obj_id =get_atomic_plane_prop_id (res, plane_id,"FB_ID" ); +if (!fb_obj_id) +return -1 ; + + ret =drmModeAtomicAddProperty (req, plane_id, fb_obj_id, fb_id); +if (ret <0 ) +return ret; + } + +return 0 ; +} + +static void atomic_modeset (struct device *dev,drmModeAtomicReqPtr req, +struct resources *res,struct property_arg *prop_args, +unsigned int prop_count) +{ +uint32_t flags =0 ; + +allocate_fbs (dev, req, res, prop_args, prop_count); + +drmModeAtomicCommit (dev->fd, req, flags,NULL ); +} + +static char optstr[] ="acdD:efM:P:ps:Cvw:" ;int main (int argc,char **argv) {
@@ -1515,6 +1647,8 @@ int main(int argc, char **argv)struct pipe_arg *pipe_args =NULL ;struct plane_arg *plane_args =NULL ;struct property_arg *prop_args =NULL ; +drmModeAtomicReqPtr req =NULL ; +char *obj_type =NULL ;unsigned int args =0 ;int ret;
@@ -1525,6 +1659,11 @@ int main(int argc, char **argv) args++;switch (c) { +case 'a' : +if (!req) + req =drmModeAtomicAlloc (); + args--; +break ;case 'c' : connectors =1 ;break ;
@@ -1646,6 +1785,9 @@ int main(int argc, char **argv)return -1 ; } +if (req) +drmSetClientCap (dev.fd,DRM_CLIENT_CAP_ATOMIC ,1 ); + dev.resources =get_resources (&dev);if (!dev.resources) {drmClose (dev.fd);
@@ -1660,46 +1802,57 @@ int main(int argc, char **argv)dump_resource (&dev, planes);dump_resource (&dev, framebuffers); -for (i =0 ; i < prop_count; ++i) -set_property (&dev, &prop_args[i]); +if (req) { +for (i =0 ; i < prop_count; ++i) { +get_prop_info (dev.resources, &prop_args[i], obj_type); +drmModeAtomicAddProperty (req, prop_args[i].obj_id, + prop_args[i].prop_id, prop_args[i].value); + } -if (count || plane_count) { -uint64_t cap =0 ; +atomic_modeset (&dev, req, dev.resources, prop_args, prop_count); - ret =drmGetCap (dev.fd,DRM_CAP_DUMB_BUFFER , &cap); -if (ret || cap ==0 ) { -fprintf (stderr,"driver doesn't support the dumb buffer API\n" ); -return 1 ; - } +getchar (); + }else { +for (i =0 ; i < prop_count; ++i) +set_property (&dev, &prop_args[i]); -if (count) -set_mode (&dev, pipe_args, count); +if (count || plane_count) { +uint64_t cap =0 ; -if (plane_count) -set_planes (&dev, plane_args, plane_count); + ret =drmGetCap (dev.fd,DRM_CAP_DUMB_BUFFER , &cap); +if (ret || cap ==0 ) { +fprintf (stderr,"driver doesn't support the dumb buffer API\n" ); +return 1 ; + } -if (test_cursor) -set_cursors (&dev, pipe_args, count); +if (count) +set_mode (&dev, pipe_args, count); -if (test_vsync) -test_page_flip (&dev, pipe_args, count); +if (plane_count) +set_planes (&dev, plane_args, plane_count); -if (drop_master) -drmDropMaster (dev.fd); +if (test_cursor) +set_cursors (&dev, pipe_args, count); -getchar (); +if (test_vsync) +test_page_flip (&dev, pipe_args, count); -if (test_cursor) -clear_cursors (&dev); +if (drop_master) +drmDropMaster (dev.fd); -if (plane_count) -clear_planes (&dev, plane_args, plane_count); +getchar (); -if (count) -clear_mode (&dev); +if (test_cursor) +clear_cursors (&dev); + +if (plane_count) +clear_planes (&dev, plane_args, plane_count); + } } +clear_mode (&dev);free_resources (dev.resources); +drmFree (req);return 0 ; }
Signature · 6 lines
2.4.3 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/3] modetest: add atomic modeset support
Hi Hyungwon Hwang
Quoted 41 lines · Hyungwon Hwang
This patch adds support for atomic modeset. Using -a option, user can make modeset to use
DRM_IOCTL_MODE_ATOMICinstead of legacy IOCTLs. Also, by using -w option, user can set the property as before.Signed-off-by Hyungwon Hwang <[email protected]>--- tests/modetest/modetest.c | 221 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 187 insertions(+), 34 deletions(-)tests/modetest/modetest.c +11
-3@@ -1444,25 +1444,32 @@ static int parse_property(struct property_arg *p, const char *arg)static void usage (char *name) { -fprintf (stderr,"usage: %s [-cDdefMPpsCvw]\n" , name); +fprintf (stderr,"usage: %s [-acDdefMPpsCvw]\n" , name); +fprintf (stderr,"\tA: supported in atomic modeset\n" ); +fprintf (stderr,"\tL: supported in legacy modeset\n" ); -fprintf (stderr,"\n Query options:\n\n" ); +fprintf (stderr,"\n Query options: [AL]\n\n" );fprintf (stderr,"\t-c\tlist connectors\n" );fprintf (stderr,"\t-e\tlist encoders\n" );fprintf (stderr,"\t-f\tlist framebuffers\n" );fprintf (stderr,"\t-p\tlist CRTCs and planes (pipes)\n" ); -fprintf (stderr,"\n Test options:\n\n" ); +fprintf (stderr,"\n Common Test options: [AL]\n\n" ); +fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property\n" ); + +fprintf (stderr,"\n Atomic Test options: [A]\n\n" ); +fprintf (stderr,"\t-a\tuse atomic modeset\n" ); + +fprintf (stderr,"\n Legacy test options: [L]\n\n" );fprintf (stderr,"\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n" );fprintf (stderr,"\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]\tset a mode\n" );fprintf (stderr,"\t-C\ttest hw cursor\n" );fprintf (stderr,"\t-v\ttest vsynced page flipping\n" );
tests/modetest/modetest.c static int parse_property(struct property_arg *p, const char *arg) · line 1473
Quoted 10 lines
tests/modetest/modetest.c +3
-4-fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property\n" );fprintf (stderr,"\n Generic options:\n\n" ); -fprintf (stderr,"\t-d\tdrop master after mode set\n" ); -fprintf (stderr,"\t-M module\tuse the given driver\n" ); -fprintf (stderr,"\t-D device\tuse the given device\n" ); +fprintf (stderr,"\t-d\tdrop master after mode set [L]\n" ); +fprintf (stderr,"\t-M module\tuse the given driver [AL]\n" ); +fprintf (stderr,"\t-D device\tuse the given device [AL]\n" );
Readability is greatly impaired with this approach. Can I suggest splitting these into two sections - legacy and atomic.
tests/modetest/modetest.c static int cursor_supported(void) · line 1506
Quoted 9 lines
tests/modetest/modetest.c +2
-1fprintf (stderr,"\n\tDefault is to dump all info.\n" );exit (0 );@@ -1495,7 +1502,132 @@ static int cursor_supported(void)return 1 ; } -static char optstr[] ="cdD:efM:P:ps:Cvw:" ; +static uint32_t is_obj_id_in_prop_args (struct property_arg *prop_args, +unsigned int prop_count,uint32_t obj_id)
Function name implies bool return value, as does the true/false below, yet you define it as "uint32_t" ?
Quoted 9 lines
tests/modetest/modetest.c +9
-0+{ +unsigned int i; + +for (i =0 ; i < prop_count; i++) +if (obj_id == prop_args[i].obj_id) +return true; + +return false; +}
tests/modetest/modetest.c static int cursor_supported(void) · line 1525
Quoted 10 lines
tests/modetest/modetest.c +10
-0+ +static int get_value_in_prop_args (struct property_arg *prop_args, +unsigned int prop_count,uint32_t obj_id, +const char *name) +{ +unsigned int i; + +for (i =0 ; i < prop_count; i++) +if (prop_args[i].obj_id == obj_id && + !strcmp (prop_args[i].name, name))
Indentation seems off. Align prop_args... with !strcmp...
Quoted 73 lines
tests/modetest/modetest.c +73
-0+return (int )prop_args[i].value; + +return -1 ; +} + +static uint32_t get_atomic_plane_prop_id (struct resources *res,uint32_t obj_id, +const char *name) +{ +drmModePropertyRes *props_info; +struct plane *plane; +unsigned int i, j; + +for (i =0 ; i < res->plane_res->count_planes; i++) { + plane = &res->planes[i]; +if (plane->plane->plane_id != obj_id) +continue ; + +for (j =0 ; j < plane->props->count_props; j++) { + props_info = plane->props_info[j]; +if (!strcmp (props_info->name, name)) +return props_info->prop_id; + } + } + +return 0 ; +} + +static int allocate_fb (struct device *dev,drmModeAtomicReqPtr req,struct resources *res, +uint32_t width,uint32_t height,uint32_t pixel_format, +int pattern,struct bo **bo,uint32_t *fb_id) +{ +uint32_t handles[4 ] = {0 }, pitches[4 ] = {0 }, offsets[4 ] = {0 }; +int ret; + + *bo =bo_create (dev->fd, pixel_format, width, height, + handles, pitches, offsets, pattern); +if (*bo ==NULL ) { +fprintf (stderr,"failed to create bo (%ux%u): %s\n" , + width, height,strerror (errno)); +return -1 ; + } + + ret =drmModeAddFB2 (dev->fd, width, height, pixel_format, + handles, pitches, offsets, fb_id,0 ); +if (ret) { +fprintf (stderr,"failed to add fb (%ux%u): %s\n" , + width, height,strerror (errno)); +bo_destroy (*bo); +return ret; + } + +return 0 ; +} + +static int allocate_fbs (struct device *dev,drmModeAtomicReqPtr req, +struct resources *res,struct property_arg *prop_args, +unsigned int prop_count) +{ +uint32_t plane_id, fb_obj_id, fb_id, i, width, height, pixel_format; +struct bo *bo; +int ret; + +for (i =0 ; i < res->plane_res->count_planes; i++) { + plane_id = res->planes[i].plane->plane_id; +if (!is_obj_id_in_prop_args (prop_args, prop_count, plane_id)) +continue ; + + width =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_W" ); + height =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_H" ); + pixel_format =DRM_FORMAT_XRGB8888 ; +
tests/modetest/modetest.c static int cursor_supported(void) · line 1608
Quoted 10 lines
tests/modetest/modetest.c +10
-0+ ret =allocate_fb (dev, req, res, width, height, pixel_format, +PATTERN_SMPTE , &bo, &fb_id); +if (ret <0 ) +return ret; + + dev->mode.bo = bo; + dev->mode.fb_id = fb_id; + + fb_obj_id =get_atomic_plane_prop_id (res, plane_id,"FB_ID" ); +if (!fb_obj_id)
Teardown the bo or error.
tests/modetest/modetest.c static int cursor_supported(void) · line 1612
Quoted 4 lines
tests/modetest/modetest.c +4
-0+return -1 ; + + ret =drmModeAtomicAddProperty (req, plane_id, fb_obj_id, fb_id); +if (ret <0 )
Ditto.
Quoted 5 lines
tests/modetest/modetest.c +5
-0+return ret; + } + +return 0 ; +}
tests/modetest/modetest.c static int cursor_supported(void) · line 1627
Quoted 10 lines
tests/modetest/modetest.c +10
-0+ +static void atomic_modeset (struct device *dev,drmModeAtomicReqPtr req, +struct resources *res,struct property_arg *prop_args, +unsigned int prop_count) +{ +uint32_t flags =0 ; + +allocate_fbs (dev, req, res, prop_args, prop_count); + +drmModeAtomicCommit (dev->fd, req, flags,NULL );
Check if these succeed, teardown when needed and return the result ?
Quoted 16 lines
tests/modetest/modetest.c +5
-0+} + +static char optstr[] ="acdD:efM:P:ps:Cvw:" ;int main (int argc,char **argv) {@@ -1515,6 +1647,8 @@ int main(int argc, char **argv)struct pipe_arg *pipe_args =NULL ;struct plane_arg *plane_args =NULL ;struct property_arg *prop_args =NULL ; +drmModeAtomicReqPtr req =NULL ; +char *obj_type =NULL ;unsigned int args =0 ;int ret;
tests/modetest/modetest.c int main(int argc, char **argv) · line 1664
Quoted 6 lines
tests/modetest/modetest.c +3
-0@@ -1525,6 +1659,11 @@ int main(int argc, char **argv) args++;switch (c) { +case 'a' : +if (!req) + req =drmModeAtomicAlloc ();
Currently you'll silently fall back to legacy if this fails. This sounds like a bad idea, imho. Check for failure and error out ?
tests/modetest/modetest.c int main(int argc, char **argv) · line 1790
Quoted 12 lines
tests/modetest/modetest.c +5
-0+ args--; +break ;case 'c' : connectors =1 ;break ;@@ -1646,6 +1785,9 @@ int main(int argc, char **argv)return -1 ; } +if (req) +drmSetClientCap (dev.fd,DRM_CLIENT_CAP_ATOMIC ,1 ); +
Again check for error and bail out ?
Quoted 4 lines
tests/modetest/modetest.c +0
-0dev.resources =get_resources (&dev);if (!dev.resources) {drmClose (dev.fd);
tests/modetest/modetest.c int main(int argc, char **argv) · line 1809
Quoted 10 lines
tests/modetest/modetest.c +5
-2@@ -1660,46 +1802,57 @@ int main(int argc, char **argv)dump_resource (&dev, planes);dump_resource (&dev, framebuffers); -for (i =0 ; i < prop_count; ++i) -set_property (&dev, &prop_args[i]); +if (req) { +for (i =0 ; i < prop_count; ++i) { +get_prop_info (dev.resources, &prop_args[i], obj_type); +drmModeAtomicAddProperty (req, prop_args[i].obj_id, + prop_args[i].prop_id, prop_args[i].value);
Check for failure and warn/error accordingly ?
tests/modetest/modetest.c int main(int argc, char **argv) · line 1813
Quoted 6 lines
tests/modetest/modetest.c +2
-2+ } -if (count || plane_count) { -uint64_t cap =0 ; +atomic_modeset (&dev, req, dev.resources, prop_args, prop_count);
Ditto ?
Maybe I'm confused by the diffstat, but I cannot see where you cleanup all the state calloc'd in allocate_fbs (and further down).
Fwiw most of this can be left unchanged if you opt for the following approach.
if (req) {
do_atomic_stuff()
cleanup()
return X
}
existing legacy code.
Last but not least: for good measure check this with valgrind.
Cheers
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/3] modetest: add atomic modeset support
Quoted 46 lines · Emil Velikov
Hi Hyungwon Hwang
Quoted 43 lines · Hyungwon Hwang
This patch adds support for atomic modeset. Using -a option, user can make modeset to use
DRM_IOCTL_MODE_ATOMICinstead of legacy IOCTLs. Also, by using -w option, user can set the property as before.Signed-off-by Hyungwon Hwang <[email protected]>--- tests/modetest/modetest.c | 221 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 187 insertions(+), 34 deletions(-)tests/modetest/modetest.c +11
-4@@ -1444,25 +1444,32 @@ static int parse_property(struct property_arg *p, const char *arg)static void usage (char *name) { -fprintf (stderr,"usage: %s [-cDdefMPpsCvw]\n" , name); +fprintf (stderr,"usage: %s [-acDdefMPpsCvw]\n" , name); +fprintf (stderr,"\tA: supported in atomic modeset\n" ); +fprintf (stderr,"\tL: supported in legacy modeset\n" ); -fprintf (stderr,"\n Query options:\n\n" ); +fprintf (stderr,"\n Query options: [AL]\n\n" );fprintf (stderr,"\t-c\tlist connectors\n" );fprintf (stderr,"\t-e\tlist encoders\n" );fprintf (stderr,"\t-f\tlist framebuffers\n" );fprintf (stderr,"\t-p\tlist CRTCs and planes (pipes)\n" ); -fprintf (stderr,"\n Test options:\n\n" ); +fprintf (stderr,"\n Common Test options: [AL]\n\n" ); +fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property\n" ); + +fprintf (stderr,"\n Atomic Test options: [A]\n\n" ); +fprintf (stderr,"\t-a\tuse atomic modeset\n" ); + +fprintf (stderr,"\n Legacy test options: [L]\n\n" );fprintf (stderr,"\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n" );fprintf (stderr,"\t-s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]\tset a mode\n" );fprintf (stderr,"\t-C\ttest hw cursor\n" );fprintf (stderr,"\t-v\ttest vsynced page flipping\n" ); -fprintf (stderr,"\t-w <obj_id>:<prop_name>:<value>\tset property\n" );
Quoted 11 lines
tests/modetest/modetest.c static int parse_property(struct property_arg *p, const char *arg) · line 1473
Quoted 8 lines
tests/modetest/modetest.c +3
-3fprintf (stderr,"\n Generic options:\n\n" ); -fprintf (stderr,"\t-d\tdrop master after mode set\n" ); -fprintf (stderr,"\t-M module\tuse the given driver\n" ); -fprintf (stderr,"\t-D device\tuse the given device\n" ); +fprintf (stderr,"\t-d\tdrop master after mode set [L]\n" ); +fprintf (stderr,"\t-M module\tuse the given driver [AL]\n" ); +fprintf (stderr,"\t-D device\tuse the given device [AL]\n" );Readability is greatly impaired with this approach. Can I suggest splitting these into two sections - legacy and atomic.
A bit tired and I've misread the above. Please ignore this comment.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/3 modetest: add atomic page flip support
In reply to Hyungwon HwangThis patch adds support for atomic page flip. User can specify -V option with the plane id for testing atomic page flipping.
--- tests/modetest/modetest.c | 153 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 4 deletions(-)
tests/modetest/modetest.c +149 -4
@@ -719,6 +719,10 @@ struct pipe_arg {struct timeval start;int swap_count; + +/* for atomic modeset */ +uint32_t plane_id; +uint32_t fb_obj_id; };struct plane_arg {
@@ -1444,7 +1448,7 @@ static int parse_property(struct property_arg *p, const char *arg)static void usage (char *name) { -fprintf (stderr,"usage: %s [-acDdefMPpsCvw]\n" , name); +fprintf (stderr,"usage: %s [-acDdefMPpsCvVw]\n" , name);fprintf (stderr,"\tA: supported in atomic modeset\n" );fprintf (stderr,"\tL: supported in legacy modeset\n" );
@@ -1459,6 +1463,7 @@ static void usage(char *name)fprintf (stderr,"\n Atomic Test options: [A]\n\n" );fprintf (stderr,"\t-a\tuse atomic modeset\n" ); +fprintf (stderr,"\t-V <flipping_plane_id>\ttest vsynced page flipping\n" );fprintf (stderr,"\n Legacy test options: [L]\n\n" );fprintf (stderr,"\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n" );
@@ -1627,7 +1632,138 @@ static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req,drmModeAtomicCommit (dev->fd, req, flags,NULL ); } -static char optstr[] ="acdD:efM:P:ps:Cvw:" ; +static void +atomic_page_flip_handler (int fd,unsigned int frame, +unsigned int sec,unsigned int usec,void *data) +{ +static drmModeAtomicReqPtr req =NULL ; +unsigned int new_fb_id; +struct timeval end; +struct pipe_arg *pipe; +double t; +uint32_t flags =0 ; + + pipe = (struct pipe_arg *)(unsigned long )data; + +if (pipe->current_fb_id == pipe->fb_id[0 ]) + new_fb_id = pipe->fb_id[1 ]; +else + new_fb_id = pipe->fb_id[0 ]; + + pipe->current_fb_id = new_fb_id; + pipe->swap_count++; + + req =drmModeAtomicAlloc (); + +drmModeAtomicAddProperty (req, pipe->plane_id, pipe->fb_obj_id, new_fb_id); + + flags =DRM_MODE_PAGE_FLIP_EVENT ; +drmModeAtomicCommit (fd, req, flags, pipe); + +if (pipe->swap_count ==60 ) { +gettimeofday (&end,NULL ); + t = end.tv_sec + end.tv_usec *1e-6 - + (pipe->start.tv_sec + pipe->start.tv_usec *1e-6 ); +fprintf (stderr,"freq: %.02fHz\n" , pipe->swap_count / t); + pipe->swap_count =0 ; + pipe->start = end; + } + +drmModeAtomicFree (req); +} + +static int atomic_test_page_flip (struct device *dev,drmModeAtomicReqPtr req, +struct resources *res,struct property_arg *prop_args, +unsigned int prop_count,unsigned int plane_id) +{ +struct bo *other_bo; +unsigned int other_fb_id; +struct pipe_arg *pipe =NULL ; +drmEventContext evctx; +uint32_t flags =0 , fb_obj_id =0 , pixel_format; +uint64_t width, height; +int ret; + +if (!is_obj_id_in_prop_args (prop_args, prop_count, plane_id)) +return -1 ; + + fb_obj_id =get_atomic_plane_prop_id (res, plane_id,"FB_ID" ); +if (!fb_obj_id) +return -1 ; + + width =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_W" ); + height =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_H" ); + pixel_format =DRM_FORMAT_XRGB8888 ; + + ret =allocate_fb (dev, req, res, width, height, pixel_format, +PATTERN_TILES , &other_bo, &other_fb_id); +if (ret <0 ) +return ret; + + ret =drmModeAtomicAddProperty (req, plane_id, fb_obj_id, + other_fb_id); +if (ret <0 ) + goto err; + +if (!fb_obj_id) { +fprintf (stderr,"page flipping requires at least one plane setting.\n" ); +return -1 ; + } + + pipe =drmMalloc (sizeof *pipe); + +gettimeofday (&pipe->start,NULL ); + pipe->swap_count =0 ; + pipe->plane_id = plane_id; + pipe->fb_obj_id = fb_obj_id; + pipe->fb_id[0 ] = dev->mode.fb_id; + pipe->fb_id[1 ] = other_fb_id; + pipe->current_fb_id = other_fb_id; + + flags =DRM_MODE_PAGE_FLIP_EVENT ; + + ret =drmModeAtomicCommit (dev->fd, req, flags, pipe); +if (ret <0 ) + goto err_rmfb; + +memset (&evctx,0 ,sizeof evctx); + evctx.version =DRM_EVENT_CONTEXT_VERSION ; + evctx.vblank_handler =NULL ; + evctx.page_flip_handler = atomic_page_flip_handler; + +while (1 ) { +struct timeval timeout = { .tv_sec =3 , .tv_usec =0 }; +fd_set fds; +int ret; + +FD_ZERO (&fds); +FD_SET (0 , &fds); +FD_SET (dev->fd, &fds); + ret =select (dev->fd +1 , &fds,NULL ,NULL , &timeout); + +if (ret <=0 ) { +fprintf (stderr,"select timed out or error (ret %d)\n" , + ret); +continue ; + }else if (FD_ISSET (0 , &fds)) { +break ; + } + +drmHandleEvent (dev->fd, &evctx); + } + +err_rmfb: +drmFree (pipe); +drmModeRmFB (dev->fd, other_fb_id); +err: +bo_destroy (other_bo); + +return 0 ; +} + +static char optstr[] ="acdD:efM:P:ps:CvV:w:" ;int main (int argc,char **argv) {
@@ -1641,7 +1777,7 @@ int main(int argc, char **argv)const char *modules[] = {"i915" ,"radeon" ,"nouveau" ,"vmwgfx" ,"omapdrm" ,"exynos" ,"tilcdc" ,"msm" ,"sti" ,"tegra" ,"imx-drm" ,"rockchip" ,"atmel-hlcdc" };char *device =NULL ;char *module =NULL ; -unsigned int i; +unsigned int i, flip_plane_id =0 ;int count =0 , plane_count =0 ;unsigned int prop_count =0 ;struct pipe_arg *pipe_args =NULL ;
@@ -1723,6 +1859,11 @@ int main(int argc, char **argv)case 'v' : test_vsync =1 ;break ; +case 'V' : +if (sscanf (optarg,"%u" , &flip_plane_id) !=1 ) +usage (argv[0 ]); + test_vsync =1 ; +break ;case 'w' : prop_args =realloc (prop_args, (prop_count +1 ) *sizeof *prop_args);
@@ -1775,7 +1916,7 @@ int main(int argc, char **argv)return -1 ; } -if (test_vsync && !count) { +if (test_vsync && (!count && !req)) {fprintf (stderr,"page flipping requires at least one -s option.\n" );return -1 ; }
@@ -1811,6 +1952,10 @@ int main(int argc, char **argv)atomic_modeset (&dev, req, dev.resources, prop_args, prop_count); +if (test_vsync) +atomic_test_page_flip (&dev, req, dev.resources, + prop_args, prop_count, flip_plane_id); +getchar (); }else {for (i =0 ; i < prop_count; ++i)
Signature · 6 lines
2.4.3 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/3] modetest: add atomic page flip support
Quoted 58 lines · Hyungwon Hwang
This patch adds support for atomic page flip. User can specify -V option with the plane id for testing atomic page flipping.
--- tests/modetest/modetest.c | 153 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 4 deletions(-)tests/modetest/modetest.c +21
-2@@ -719,6 +719,10 @@ struct pipe_arg {struct timeval start;int swap_count; + +/* for atomic modeset */ +uint32_t plane_id; +uint32_t fb_obj_id; };struct plane_arg {@@ -1444,7 +1448,7 @@ static int parse_property(struct property_arg *p, const char *arg)static void usage (char *name) { -fprintf (stderr,"usage: %s [-acDdefMPpsCvw]\n" , name); +fprintf (stderr,"usage: %s [-acDdefMPpsCvVw]\n" , name);fprintf (stderr,"\tA: supported in atomic modeset\n" );fprintf (stderr,"\tL: supported in legacy modeset\n" );@@ -1459,6 +1463,7 @@ static void usage(char *name)fprintf (stderr,"\n Atomic Test options: [A]\n\n" );fprintf (stderr,"\t-a\tuse atomic modeset\n" ); +fprintf (stderr,"\t-V <flipping_plane_id>\ttest vsynced page flipping\n" );fprintf (stderr,"\n Legacy test options: [L]\n\n" );fprintf (stderr,"\t-P <crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n" );@@ -1627,7 +1632,138 @@ static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req,drmModeAtomicCommit (dev->fd, req, flags,NULL ); } -static char optstr[] ="acdD:efM:P:ps:Cvw:" ; +static void +atomic_page_flip_handler (int fd,unsigned int frame, +unsigned int sec,unsigned int usec,void *data) +{ +static drmModeAtomicReqPtr req =NULL ; +unsigned int new_fb_id; +struct timeval end; +struct pipe_arg *pipe; +double t; +uint32_t flags =0 ; + + pipe = (struct pipe_arg *)(unsigned long )data; + +if (pipe->current_fb_id == pipe->fb_id[0 ]) + new_fb_id = pipe->fb_id[1 ];
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1659
Quoted 10 lines
tests/modetest/modetest.c +10
-0+else + new_fb_id = pipe->fb_id[0 ]; + + pipe->current_fb_id = new_fb_id; + pipe->swap_count++; + + req =drmModeAtomicAlloc (); + +drmModeAtomicAddProperty (req, pipe->plane_id, pipe->fb_obj_id, new_fb_id); +
We'll crash badly if req is NULL here. I guess we can smoke test the API, but that is no excuse for the missing null check.
Quoted 28 lines
tests/modetest/modetest.c +28
-0+ flags =DRM_MODE_PAGE_FLIP_EVENT ; +drmModeAtomicCommit (fd, req, flags, pipe); + +if (pipe->swap_count ==60 ) { +gettimeofday (&end,NULL ); + t = end.tv_sec + end.tv_usec *1e-6 - + (pipe->start.tv_sec + pipe->start.tv_usec *1e-6 ); +fprintf (stderr,"freq: %.02fHz\n" , pipe->swap_count / t); + pipe->swap_count =0 ; + pipe->start = end; + } + +drmModeAtomicFree (req); +} + +static int atomic_test_page_flip (struct device *dev,drmModeAtomicReqPtr req, +struct resources *res,struct property_arg *prop_args, +unsigned int prop_count,unsigned int plane_id) +{ +struct bo *other_bo; +unsigned int other_fb_id; +struct pipe_arg *pipe =NULL ; +drmEventContext evctx; +uint32_t flags =0 , fb_obj_id =0 , pixel_format; +uint64_t width, height; +int ret; + +if (!is_obj_id_in_prop_args (prop_args, prop_count, plane_id))
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1697
Quoted 10 lines
tests/modetest/modetest.c +10
-0+return -1 ; + + fb_obj_id =get_atomic_plane_prop_id (res, plane_id,"FB_ID" ); +if (!fb_obj_id) +return -1 ; + + width =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_W" ); + height =get_value_in_prop_args (prop_args, prop_count, plane_id, +"SRC_H" );
Here and in the previous patch you assume that always succeeds. Perhaps one should check it otherwise all sort of crazy stuff will happen in allocate_fb() ?
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1699
Quoted 2 lines
tests/modetest/modetest.c +2
-0+ pixel_format =DRM_FORMAT_XRGB8888 ; +
For the future we might consider making this user configurable, although as is it looks like a good default.
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1707
Quoted 8 lines
tests/modetest/modetest.c +8
-0+ ret =allocate_fb (dev, req, res, width, height, pixel_format, +PATTERN_TILES , &other_bo, &other_fb_id); +if (ret <0 ) +return ret; + + ret =drmModeAtomicAddProperty (req, plane_id, fb_obj_id, + other_fb_id); +if (ret <0 )
Why do you return 'success' here ?
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1710
Quoted 3 lines
tests/modetest/modetest.c +3
-0+ goto err; + +if (!fb_obj_id) {
Here (and in previous patch) we're missing RmFB()
Leaking other_bo.
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1715
Quoted 5 lines
tests/modetest/modetest.c +5
-0+fprintf (stderr,"page flipping requires at least one plane setting.\n" ); +return -1 ; + } + + pipe =drmMalloc (sizeof *pipe);
Please use calloc.
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1728
Quoted 13 lines
tests/modetest/modetest.c +13
-0+ +gettimeofday (&pipe->start,NULL ); + pipe->swap_count =0 ; + pipe->plane_id = plane_id; + pipe->fb_obj_id = fb_obj_id; + pipe->fb_id[0 ] = dev->mode.fb_id; + pipe->fb_id[1 ] = other_fb_id; + pipe->current_fb_id = other_fb_id; + + flags =DRM_MODE_PAGE_FLIP_EVENT ; + + ret =drmModeAtomicCommit (dev->fd, req, flags, pipe); +if (ret <0 )
Should you return the error code rather than 0 ?
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1732
Quoted 4 lines
tests/modetest/modetest.c +4
-0+ goto err_rmfb; + +memset (&evctx,0 ,sizeof evctx); + evctx.version =DRM_EVENT_CONTEXT_VERSION ;
This is very bad, please don't do it.
DRM_EVENT_CONTEXT_VERSION defines the version currently present not the one you implement/use. They might match now, but as one bumps the define modetest build against it will end up very badly.
Seems issue is present in the 'legacy' modeset path and vbltest :'(
Quoted 59 lines
tests/modetest/modetest.c +40
-1+ evctx.vblank_handler =NULL ; + evctx.page_flip_handler = atomic_page_flip_handler; + +while (1 ) { +struct timeval timeout = { .tv_sec =3 , .tv_usec =0 }; +fd_set fds; +int ret; + +FD_ZERO (&fds); +FD_SET (0 , &fds); +FD_SET (dev->fd, &fds); + ret =select (dev->fd +1 , &fds,NULL ,NULL , &timeout); + +if (ret <=0 ) { +fprintf (stderr,"select timed out or error (ret %d)\n" , + ret); +continue ; + }else if (FD_ISSET (0 , &fds)) { +break ; + } + +drmHandleEvent (dev->fd, &evctx); + } + +err_rmfb: +drmFree (pipe); +drmModeRmFB (dev->fd, other_fb_id); +err: +bo_destroy (other_bo); + +return 0 ; +} + +static char optstr[] ="acdD:efM:P:ps:CvV:w:" ;int main (int argc,char **argv) {@@ -1641,7 +1777,7 @@ int main(int argc, char **argv)const char *modules[] = {"i915" ,"radeon" ,"nouveau" ,"vmwgfx" ,"omapdrm" ,"exynos" ,"tilcdc" ,"msm" ,"sti" ,"tegra" ,"imx-drm" ,"rockchip" ,"atmel-hlcdc" };char *device =NULL ;char *module =NULL ; -unsigned int i; +unsigned int i, flip_plane_id =0 ;int count =0 , plane_count =0 ;unsigned int prop_count =0 ;struct pipe_arg *pipe_args =NULL ;@@ -1723,6 +1859,11 @@ int main(int argc, char **argv)case 'v' : test_vsync =1 ;break ; +case 'V' : +if (sscanf (optarg,"%u" , &flip_plane_id) !=1 ) +usage (argv[0 ]); + test_vsync =1 ; +break ;case 'w' : prop_args =realloc (prop_args, (prop_count +1 ) *sizeof *prop_args);
tests/modetest/modetest.c int main(int argc, char **argv) · line 1920
Quoted 6 lines
tests/modetest/modetest.c +1
-1@@ -1775,7 +1916,7 @@ int main(int argc, char **argv)return -1 ; } -if (test_vsync && !count) { +if (test_vsync && (!count && !req)) {fprintf (stderr,"page flipping requires at least one -s option.\n" );
Something doesn't match here - the top level (help) description, the conditional and/or the error printf.
Cheers,
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/3] modetest: add atomic page flip support
Dear Emil,
Quoted 176 lines · On Wed, 02 Sep 2015 01:43:41 +0100 Emil Velikov <[email protected]>…
Quoted 71 lines · Hyungwon Hwang
This patch adds support for atomic page flip. User can specify -V option with the plane id for testing atomic page flipping.
--- tests/modetest/modetest.c | 153++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 4 deletions(-)
tests/modetest/modetest.c +6
-1@@ -719,6 +719,10 @@ struct pipe_arg {struct timeval start;int swap_count; + +/* for atomic modeset */ +uint32_t plane_id; +uint32_t fb_obj_id; };struct plane_arg {@@ -1444,7 +1448,7 @@ static int parse_property(struct property_arg *p, const char *arg)static void usage (char *name) { -fprintf (stderr,"usage: %s [-acDdefMPpsCvw]\n" , name); +fprintf (stderr,"usage: %s [-acDdefMPpsCvVw]\n" , name);fprintf (stderr,"\tA: supported in atomic modeset\n" );fprintf (stderr,"\tL: supported in legacy modeset\n" );@@ -1459,6 +1463,7 @@ static void usage(char *name)fprintf (stderr,"\n Atomic Test options: [A]\n\n" );fprintf (stderr,"\t-a\tuse atomic modeset\n" ); + fprintf(stderr, "\t-V <flipping_plane_id>\ttest vsynced page flipping\n"); fprintf(stderr, "\n Legacy test options: [L]\n\n");fprintf(stderr, "\t-P
<crtc_id>:<w>x<h>[+<x>+<y>][*<scale>][@<format>]\tset a plane\n");tests/modetest/modetest.c +24
-1@@ -1627,7 +1632,138 @@ static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, drmModeAtomicCommit(dev->fd, req, flags,NULL ); } -static char optstr[] ="acdD:efM:P:ps:Cvw:" ; +static void +atomic_page_flip_handler (int fd,unsigned int frame, +unsigned int sec,unsigned int usec,void *data) +{ +static drmModeAtomicReqPtr req =NULL ; +unsigned int new_fb_id; +struct timeval end; +struct pipe_arg *pipe; +double t; +uint32_t flags =0 ; + + pipe = (struct pipe_arg *)(unsigned long )data; + +if (pipe->current_fb_id == pipe->fb_id[0 ]) + new_fb_id = pipe->fb_id[1 ]; +else + new_fb_id = pipe->fb_id[0 ]; + + pipe->current_fb_id = new_fb_id; + pipe->swap_count++; + + req =drmModeAtomicAlloc (); + + drmModeAtomicAddProperty(req, pipe->plane_id,Quoted 1 line
pipe->fb_obj_id,new_fb_id); +We'll crash badly if req is NULL here. I guess we can smoke test the API, but that is no excuse for the missing null check.
Quoted 44 lines
tests/modetest/modetest.c +7
-0+ flags =DRM_MODE_PAGE_FLIP_EVENT ; +drmModeAtomicCommit (fd, req, flags, pipe); + + if (pipe->swap_count == 60) { + gettimeofday(&end, NULL); + t = end.tv_sec + end.tv_usec * 1e-6 - + (pipe->start.tv_sec + pipe->start.tv_usec *1e-6);
+ fprintf(stderr, "freq: %.02fHz\n",pipe->swap_count/ t);tests/modetest/modetest.c +8
-0+ pipe->swap_count =0 ; + pipe->start = end; + } + +drmModeAtomicFree (req); +} + +static int atomic_test_page_flip(struct device *dev,drmModeAtomicReqPtr req,
+ struct resources *res, structproperty_arg*prop_args,
+ unsigned int prop_count,unsigned intplane_id) +{tests/modetest/modetest.c +9
-0+struct bo *other_bo; +unsigned int other_fb_id; +struct pipe_arg *pipe =NULL ; +drmEventContext evctx; +uint32_t flags =0 , fb_obj_id =0 , pixel_format; +uint64_t width, height; +int ret; + + if (!is_obj_id_in_prop_args(prop_args, prop_count,
plane_id))tests/modetest/modetest.c +3
-0+return -1 ; + + fb_obj_id = get_atomic_plane_prop_id(res, plane_id,"
FB_ID");tests/modetest/modetest.c +4
-0+if (!fb_obj_id) +return -1 ; + + width = get_value_in_prop_args(prop_args, prop_count,
plane_id,tests/modetest/modetest.c +2
-0+ "SRC_W"); + height = get_value_in_prop_args(prop_args, prop_count,Quoted 2 lines
plane_id,
+ "SRC_H");Here and in the previous patch you assume that always succeeds. Perhaps one should check it otherwise all sort of crazy stuff will happen in
allocate_fb()?tests/modetest/modetest.c
Quoted 2 lines
tests/modetest/modetest.c +2
-0+ pixel_format =DRM_FORMAT_XRGB8888 ; +For the future we might consider making this user configurable, although as is it looks like a good default.
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1707
Quoted 9 lines
+ ret = allocate_fb(dev, req, res, width, height,
pixel_format,tests/modetest/modetest.c +7
-0+ PATTERN_TILES, &other_bo, &other_fb_id); +if (ret <0 ) +return ret; + + ret =drmModeAtomicAddProperty (req, plane_id, fb_obj_id, + other_fb_id); +if (ret <0 )Why do you return 'success' here ?
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1710
Quoted 3 lines
tests/modetest/modetest.c +3
-0+ goto err; + +if (!fb_obj_id) {Here (and in previous patch) we're missing
RmFB()
Leakingother_bo.tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1715
Quoted 6 lines
+ fprintf(stderr, "page flipping requires at least
one plane setting.\n");tests/modetest/modetest.c +4
-0+return -1 ; + } + + pipe =drmMalloc (sizeof *pipe);Please use calloc.
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1728
Quoted 13 lines
tests/modetest/modetest.c +13
-0+ +gettimeofday (&pipe->start,NULL ); + pipe->swap_count =0 ; + pipe->plane_id = plane_id; + pipe->fb_obj_id = fb_obj_id; + pipe->fb_id[0 ] = dev->mode.fb_id; + pipe->fb_id[1 ] = other_fb_id; + pipe->current_fb_id = other_fb_id; + + flags =DRM_MODE_PAGE_FLIP_EVENT ; + + ret =drmModeAtomicCommit (dev->fd, req, flags, pipe); +if (ret <0 )Should you return the error code rather than 0 ?
tests/modetest/modetest.c static void atomic_modeset(struct device *dev, drmModeAtomicReqPtr req, · line 1732
Quoted 4 lines
tests/modetest/modetest.c +4
-0+ goto err_rmfb; + +memset (&evctx,0 ,sizeof evctx); + evctx.version =DRM_EVENT_CONTEXT_VERSION ;
Quoted 7 lines
This is very bad, please don't do it.
DRM_EVENT_CONTEXT_VERSIONdefines the version currently present not the one you implement/use. They might match now, but as one bumps the define modetest build against it will end up very badly.Seems issue is present in the 'legacy' modeset path and vbltest :'(
Yes. It could be a problem in future. Then do you think new defines must be set for the versions? or will it be OK just use a constant in the code?
Thank you for your review.
Best regards,
Hyungwon Hwang
Quoted 74 lines
Quoted 70 lines
tests/modetest/modetest.c +5
-0+ evctx.vblank_handler =NULL ; + evctx.page_flip_handler = atomic_page_flip_handler; + + while (1) { + struct timeval timeout = { .tv_sec = 3, .tv_usec =0 };
tests/modetest/modetest.c +7
-0+fd_set fds; +int ret; + +FD_ZERO (&fds); +FD_SET (0 , &fds); +FD_SET (dev->fd, &fds); + ret = select(dev->fd + 1, &fds, NULL, NULL,&timeout); +
tests/modetest/modetest.c +2
-0+if (ret <=0 ) { + fprintf(stderr, "select timed out or error(ret %d)\n",
tests/modetest/modetest.c +19
-0+ ret); +continue ; + }else if (FD_ISSET (0 , &fds)) { +break ; + } + +drmHandleEvent (dev->fd, &evctx); + } + +err_rmfb: +drmFree (pipe); +drmModeRmFB (dev->fd, other_fb_id); +err: +bo_destroy (other_bo); + +return 0 ; +} + +static char optstr[] ="acdD:efM:P:ps:CvV:w:" ;int main (int argc,char **argv) {@@ -1641,7 +1777,7 @@ int main(int argc, char **argv)const char *modules[] = {"i915" ,"radeon" ,"nouveau" ,"vmwgfx" ,"omapdrm" ,"exynos" ,"tilcdc" ,"msm" ,"sti" ,"tegra" ,"imx-drm", "rockchip", "atmel-hlcdc" }; char *device = NULL; char *module = NULL;
tests/modetest/modetest.c +6
-1-unsigned int i; +unsigned int i, flip_plane_id =0 ;int count =0 , plane_count =0 ;unsigned int prop_count =0 ;struct pipe_arg *pipe_args =NULL ;@@ -1723,6 +1859,11 @@ int main(int argc, char **argv)case 'v' : test_vsync =1 ;break ; +case 'V' : +if (sscanf (optarg,"%u" , &flip_plane_id) !=1 ) +usage (argv[0 ]); + test_vsync =1 ; +break ;case 'w' : prop_args = realloc(prop_args,(prop_count + 1) * sizeof *prop_args); @@ -1775,7 +1916,7 @@ int main(int argc, char **argv) return -1; }tests/modetest/modetest.c +1
-1-if (test_vsync && !count) { +if (test_vsync && (!count && !req)) { fprintf(stderr, "page flipping requires at leastQuoted 1 line
one -s option.\n");
Something doesn't match here - the top level (help) description, the conditional and/or the error printf.
Quoted 2 lines
Cheers,
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 15 lines · Hyungwon Hwang
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 <[email protected]>--- tests/modetest/modetest.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)tests/modetest/modetest.c +0
-0
tests/modetest/modetest.c struct property_arg { · line 870
Quoted 6 lines
tests/modetest/modetest.c +2
-1@@ -866,12 +866,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, +char *obj_type)
Strictly speaking you don't need the struct device > struct resources change here.
But if you prefer doing so, keep the const qualifier for obj_type.
Quoted 7 lines
tests/modetest/modetest.c +0
-2{drmModeObjectProperties *props =NULL ;drmModePropertyRes **props_info =NULL ; -const char *obj_type; -int ret;int i;
...
tests/modetest/modetest.c static void set_property(struct device *dev, struct property_arg *p) · line 931
Quoted 5 lines
tests/modetest/modetest.c +5
-0+static void set_property (struct device *dev,struct property_arg *p) +{ +int ret; +char *obj_type =NULL ; +
Drop the initializer and constify.
-Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel