示例#1
0
static int do_components(int argc, const char **argv)
{
   VC_MEM_ACCESS_HANDLE_T vc;
   VC_MEM_ADDR_T addr, statsaddr;
   size_t size;
   MMAL_VC_STATS_T stats;
   int rc;


   if (argc > 2 && (strcasecmp(argv[2], "update") == 0))
   {
      MMAL_STATUS_T status;
      do_connect();
      status = mmal_vc_get_stats(&stats, 0);
      if (status != MMAL_SUCCESS)
      {
         fprintf(stderr, "Failed to update MMAL stats. error %s",
              mmal_status_to_string(status));
         return -1;
      }
   }
   else
   {
      if ((rc = OpenVideoCoreMemory(&vc)) < 0)
      {
         fprintf(stderr,"Unable to open videocore memory: %d\n", rc);
         return -1;
      }
      if (!LookupVideoCoreSymbol(vc, "mmal_vc_stats", &addr, &size))
      {
         fprintf(stderr,"Could not get MMAL stats address\n");
         goto fail;
      }
      if (!ReadVideoCoreUInt32(vc, &statsaddr, addr))
      {
         fprintf(stderr,"Could not read MMAL stats pointer at address 0x%x\n",
               addr);
         goto fail;
      }
      if (!ReadVideoCoreMemory(vc, &stats, statsaddr, sizeof(stats)))
      {
         fprintf(stderr,"Could not read MMAL stats at address 0x%x\n", addr);
         goto fail;
      }
      CloseVideoCoreMemory(vc);
   }
   rc = print_component_stats(&stats);
   return rc;

fail:
   CloseVideoCoreMemory(vc);
   return -1;
}
示例#2
0
static int do_imageconv_stats(int argc, const char **argv)
{
   VC_MEM_ACCESS_HANDLE_T vc;
   VC_MEM_ADDR_T addr, statsaddr;
   size_t size;
   IMAGECONV_STATS_T stats;
   long convert_time;
   double frame_rate;
   int rc;
   int reset_stats = 0;

   if (argc > 2)
      reset_stats = strcasecmp(argv[2], "reset") == 0;

   if ((rc = OpenVideoCoreMemory(&vc)) < 0)
   {
      fprintf(stderr,"Unable to open videocore memory: %d\n", rc);
      return -1;
   }
   if (!LookupVideoCoreSymbol(vc, "imageconv_stats", &addr, &size))
   {
      fprintf(stderr,"Could not get imageconv stats address\n");
      goto fail;
   }
   if (!ReadVideoCoreUInt32(vc, &statsaddr, addr))
   {
      fprintf(stderr, "Could not read imageconv stats address\n");
      goto fail;
   }

   if (reset_stats)
   {
      memset(&stats, 0, sizeof(stats));
      stats.magic = IMAGECONV_STATS_MAGIC;
      if (!WriteVideoCoreMemory(vc, &stats, statsaddr, sizeof(stats)))
      {
         fprintf(stderr, "Could not write stats at 0x%x\n", statsaddr);
         goto fail;
      }
   }

   if (!ReadVideoCoreMemory(vc, &stats, statsaddr, sizeof(stats)))
   {
      fprintf(stderr, "Could not read stats at 0x%x\n", statsaddr);
      goto fail;
   }

   if (stats.magic != IMAGECONV_STATS_MAGIC)
   {
      fprintf(stderr, "Bad magic 0x%x\n", stats.magic);
      goto fail;
   }

   if (stats.conversions)
      convert_time = stats.time_spent / stats.conversions;
   else
      convert_time = 0;

   if (stats.conversions)
      frame_rate = 1000000.0 * stats.conversions /
         (stats.last_image_ts - stats.first_image_ts);
   else
      frame_rate = 0;

   printf("%-25s:\t%d\n", "conversions", stats.conversions);
   printf("%-25s:\t%d\n", "size requests", stats.size_requests);
   printf("%-25s:\t%d\n", "max vrf delay", stats.max_vrf_delay);
   printf("%-25s:\t%d\n", "vrf wait time", stats.vrf_wait_time);
   printf("%-25s:\t%d\n", "duplicate conversions", stats.duplicate_conversions);
   printf("%-25s:\t%d\n", "failures", stats.failures);
   printf("%-25s:\t%ld\n", "convert time / image (us)", convert_time);
   printf("%-25s:\t%.1f\n", "client frame_rate", frame_rate);
   printf("%-25s:\t%d us\n", "max delay to consume", stats.max_delay);

   CloseVideoCoreMemory(vc);
   return 0;
fail:
   CloseVideoCoreMemory(vc);
   return -1;

}
示例#3
0
static int do_eventlog(int argc, const char **argv)
{
   VC_MEM_ACCESS_HANDLE_T vc;
   VC_MEM_ADDR_T addr;     /** The address of the pointer to the log */
   size_t size;
   VC_MEM_ADDR_T logaddr;       /** The address of the log itself */
   MMAL_DBG_LOG_T log;

   (void)argc; (void)argv;
   int rc;
   if ((rc = OpenVideoCoreMemory(&vc)) < 0)
   {
      fprintf(stderr,"Unable to open videocore memory: %d\n", rc);
      return -1;
   }
   if (!LookupVideoCoreSymbol(vc, "mmal_dbg_log", &addr, &size))
   {
      fprintf(stderr,"Could not get MMAL log address\n");
      goto fail;
   }
   if (!ReadVideoCoreUInt32(vc, &logaddr, addr))
   {
      fprintf(stderr,"Could not read MMAL log pointer at address 0x%x\n",
              addr);
      goto fail;
   }
   if (!ReadVideoCoreMemory(vc, &log, logaddr, sizeof(log)))
   {
      fprintf(stderr,"Could not read MMAL log at address 0x%x\n",
              logaddr);
      goto fail;
   }
   if (log.magic != MMAL_MAGIC)
   {
      fprintf(stderr,"Bad magic 0x%08x in log at 0x%x\n", log.magic, logaddr);
      goto fail;
   }
   if (log.size != sizeof(log))
   {
      fprintf(stderr,"MMAL Log size mismatch (got %d, expected %d)\n",
              log.size, sizeof(log));
      goto fail;
   }
   if (log.elemsize != sizeof(MMAL_DBG_ENTRY_T))
   {
      fprintf(stderr,"MMAL log element size mismatch (got %d, expected %d)\n",
              log.elemsize, sizeof(MMAL_DBG_ENTRY_T));
      goto fail;
   }

   printf("reading MMAL log at 0x%x version %d magic %x\n",
          logaddr, log.version, log.magic);
   printf("%d events, %d entries each size %d\n", log.index, log.num_entries,
          log.elemsize);
   print_mmal_event_log(vc, &log);

   CloseVideoCoreMemory(vc);
   return 0;
fail:
   CloseVideoCoreMemory(vc);
   return -1;

}