v3d: Switch v3d_decoder.c to the XML's top min_ver/max_ver fields.
authorEric Anholt <eric@anholt.net>
Wed, 27 Jun 2018 21:10:52 +0000 (14:10 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 29 Jun 2018 20:36:28 +0000 (13:36 -0700)
The XML zipper wants one XML per version for filling out its tables, but
we want to do more than one GPU version per XML now.  Assume that the
"gen" field will be the same as min_ver and look up our XML text assuming
that they're listed in increasing min_ver.

src/broadcom/cle/v3d_decoder.c
src/broadcom/cle/v3d_packet_v21.xml
src/broadcom/cle/v3d_packet_v33.xml
src/broadcom/cle/v3d_packet_v41.xml
src/broadcom/cle/v3d_packet_v42.xml

index d76c004730b92e0988b7ea8b8c3a72f419ee7d86..832ff3c7089329b371bdea5ebaefcf974f5d4f79 100644 (file)
@@ -467,6 +467,10 @@ start_element(void *data, const char *element_name, const char **atts)
                 if (ver == NULL)
                         fail(&ctx->loc, "no ver given");
 
+                /* Make sure that we picked an XML that matched our version.
+                 */
+                assert(ver_in_range(ctx->devinfo->ver, min_ver, max_ver));
+
                 int major, minor;
                 int n = sscanf(ver, "%d.%d", &major, &minor);
                 if (n == 0)
@@ -631,10 +635,14 @@ v3d_spec_load(const struct v3d_device_info *devinfo)
         uint32_t text_offset = 0, text_length = 0, total_length;
 
         for (int i = 0; i < ARRAY_SIZE(genxml_files_table); i++) {
-                if (genxml_files_table[i].gen_10 == devinfo->ver) {
+                if (i != 0) {
+                        assert(genxml_files_table[i - 1].gen_10 <
+                               genxml_files_table[i].gen_10);
+                }
+
+                if (genxml_files_table[i].gen_10 <= devinfo->ver) {
                         text_offset = genxml_files_table[i].offset;
                         text_length = genxml_files_table[i].length;
-                        break;
                 }
         }
 
index 9ca983308d3951c7ef0cdb7848264860804b797b..df838a7084579db19d0d498231c7056f2eaa79e1 100644 (file)
@@ -1,4 +1,4 @@
-<vcxml gen="2.1">
+<vcxml gen="2.1" min_ver="21" max_ver="21">
 
   <enum name="Compare Function" prefix="V3D_COMPARE_FUNC">
     <value name="NEVER" value="0"/>
index 1ece1c9555814c9504c8e30eb8eb0fd6bec7135a..2e112f4bac3bf65313e202e4ee7a1fbda5aeda74 100644 (file)
@@ -1,4 +1,4 @@
-<vcxml gen="3.3">
+<vcxml gen="3.3" min_ver="33" max_ver="33">
 
   <enum name="Compare Function" prefix="V3D_COMPARE_FUNC">
     <value name="NEVER" value="0"/>
index 9f0c54eadc9d03d2000ef3906109ce574b11a781..d509d974bc41f7bae4ea09cb0be6843db58eed15 100644 (file)
@@ -1,4 +1,4 @@
-<vcxml gen="4.1">
+<vcxml gen="4.1" min_ver="41" max_ver="41">
 
   <enum name="Compare Function" prefix="V3D_COMPARE_FUNC">
     <value name="NEVER" value="0"/>
index 5a335d89c225fc7c2b6058a1bb8eaad3cb30851a..8bad4c533b63b0c924bd735513753af1a38e4fc0 100644 (file)
@@ -1,4 +1,4 @@
-<vcxml gen="4.2">
+<vcxml gen="4.2" min_ver="42" max_ver="42">
 
   <enum name="Compare Function" prefix="V3D_COMPARE_FUNC">
     <value name="NEVER" value="0"/>