void
hud_pipe_query_install(struct hud_pane *pane, struct pipe_context *pipe,
                       const char *name, unsigned query_type,
                       unsigned result_index,
                       uint64_t max_value, boolean uses_byte_units)
{
   struct hud_graph *gr;
   struct query_info *info;

   gr = CALLOC_STRUCT(hud_graph);
   if (!gr)
      return;

   strcpy(gr->name, name);
   gr->query_data = CALLOC_STRUCT(query_info);
   if (!gr->query_data) {
      FREE(gr);
      return;
   }

   gr->query_new_value = query_new_value;
   gr->free_query_data = free_query_info;

   info = gr->query_data;
   info->pipe = pipe;
   info->query_type = query_type;
   info->result_index = result_index;

   hud_pane_add_graph(pane, gr);
   if (pane->max_value < max_value)
      hud_pane_set_max_value(pane, max_value);
   if (uses_byte_units)
      pane->uses_byte_units = TRUE;
}
Example #2
0
void
hud_fps_graph_install(struct hud_pane *pane)
{
   struct hud_graph *gr = CALLOC_STRUCT(hud_graph);

   if (!gr)
      return;

   strcpy(gr->name, "fps");
   gr->query_data = CALLOC_STRUCT(fps_info);
   if (!gr->query_data) {
      FREE(gr);
      return;
   }

   gr->query_new_value = query_fps;

   /* Don't use free() as our callback as that messes up Gallium's
    * memory debugger.  Use simple free_query_data() wrapper.
    */
   gr->free_query_data = free_query_data;

   hud_graph_set_dump_file(gr);

   hud_pane_add_graph(pane, gr);
}
Example #3
0
/**
  * Create and initialize a new object for a specific sensor interface dev.
  * \param  pane  parent context.
  * \param  dev_name  device name, EG. 'coretemp-isa-0000.Core 1'
  * \param  mode  query type (NIC_DIRECTION_RX/WR/RSSI) statistics.
  */
void
hud_sensors_temp_graph_install(struct hud_pane *pane, const char *dev_name,
                               unsigned int mode)
{
   struct hud_graph *gr;
   struct sensors_temp_info *sti;

   int num_devs = hud_get_num_sensors(0);
   if (num_devs <= 0)
      return;

   sti = find_sti_by_name(dev_name, mode);
   if (!sti)
      return;

   gr = CALLOC_STRUCT(hud_graph);
   if (!gr)
      return;

   snprintf(gr->name, sizeof(gr->name), "%.6s..%s (%s)",
           sti->chipname,
           sti->featurename,
           sti->mode == SENSORS_VOLTAGE_CURRENT ? "Volts" :
           sti->mode == SENSORS_CURRENT_CURRENT ? "Amps" :
           sti->mode == SENSORS_TEMP_CURRENT ? "Curr" :
           sti->mode == SENSORS_POWER_CURRENT ? "Pow" :
           sti->mode == SENSORS_TEMP_CRITICAL ? "Crit" : "Unkn");

   gr->query_data = sti;
   gr->query_new_value = query_sti_load;

   /* Don't use free() as our callback as that messes up Gallium's
    * memory debugger.  Use simple free_query_data() wrapper.
    */
   gr->free_query_data = free_query_data;

   hud_pane_add_graph(pane, gr);
   switch (sti->mode) {
   case SENSORS_TEMP_CURRENT:
   case SENSORS_TEMP_CRITICAL:
      hud_pane_set_max_value(pane, 120);
      break;
   case SENSORS_VOLTAGE_CURRENT:
      hud_pane_set_max_value(pane, 12);
      break;
   case SENSORS_CURRENT_CURRENT:
      hud_pane_set_max_value(pane, 5000);
      break;
   case SENSORS_POWER_CURRENT:
      hud_pane_set_max_value(pane, 5000 /* mW */);
      break;
   }
}
Example #4
0
void
hud_pipe_query_install(struct hud_batch_query_context **pbq,
                       struct hud_pane *pane, struct pipe_context *pipe,
                       const char *name, unsigned query_type,
                       unsigned result_index,
                       uint64_t max_value, enum pipe_driver_query_type type,
                       enum pipe_driver_query_result_type result_type,
                       unsigned flags)
{
   struct hud_graph *gr;
   struct query_info *info;

   gr = CALLOC_STRUCT(hud_graph);
   if (!gr)
      return;

   strncpy(gr->name, name, sizeof(gr->name));
   gr->name[sizeof(gr->name) - 1] = '\0';
   gr->query_data = CALLOC_STRUCT(query_info);
   if (!gr->query_data)
      goto fail_gr;

   gr->query_new_value = query_new_value;
   gr->free_query_data = free_query_info;

   info = gr->query_data;
   info->pipe = pipe;
   info->result_type = result_type;

   if (flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
      if (!batch_query_add(pbq, pipe, query_type, &info->result_index))
         goto fail_info;
      info->batch = *pbq;
   } else {
      info->query_type = query_type;
      info->result_index = result_index;
   }

   hud_pane_add_graph(pane, gr);
   pane->type = type; /* must be set before updating the max_value */

   if (pane->max_value < max_value)
      hud_pane_set_max_value(pane, max_value);
   return;

fail_info:
   FREE(info);
fail_gr:
   FREE(gr);
}
Example #5
0
void
hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index)
{
   struct hud_graph *gr;
   struct cpu_info *info;
   uint64_t busy, total;

   /* see if the cpu exists */
   if (cpu_index != ALL_CPUS && !get_cpu_stats(cpu_index, &busy, &total)) {
      return;
   }

   gr = CALLOC_STRUCT(hud_graph);
   if (!gr)
      return;

   if (cpu_index == ALL_CPUS)
      strcpy(gr->name, "cpu");
   else
      sprintf(gr->name, "cpu%u", cpu_index);

   gr->query_data = CALLOC_STRUCT(cpu_info);
   if (!gr->query_data) {
      FREE(gr);
      return;
   }

   gr->query_new_value = query_cpu_load;

   /* Don't use free() as our callback as that messes up Gallium's
    * memory debugger.  Use simple free_query_data() wrapper.
    */
   gr->free_query_data = free_query_data;

   info = gr->query_data;
   info->cpu_index = cpu_index;

   hud_graph_set_dump_file(gr);

   hud_pane_add_graph(pane, gr);
   hud_pane_set_max_value(pane, 100);
}