/ src / core / graphics.cc
graphics.cc
 1  #include "version.h"
 2  #include "hw.h"
 3  #include "sysfs.h"
 4  #include "osutils.h"
 5  #include "graphics.h"
 6  #include "heuristics.h"
 7  
 8  #include <vector>
 9  #include <iostream>
10  
11  __ID("@(#) $Id$");
12  
13  using namespace std;
14  
15  bool scan_graphics(hwNode & n)
16  {
17    vector < sysfs::entry > entries = sysfs::entries_by_class("graphics");
18  
19    if (entries.empty())
20      return false;
21  
22    for (vector < sysfs::entry >::iterator it = entries.begin();
23        it != entries.end(); ++it)
24    {
25      const sysfs::entry & e = *it;
26      string dev = e.string_attr("dev");
27      if(dev!="")
28      {
29        hwNode *device = n.findChildByBusInfo(e.leaf().businfo());
30        if(!device)
31          device = n.addChild(hwNode("graphics", hw::display));
32        device->claim();
33        device->setLogicalName(e.name());
34        device->addCapability("fb", "framebuffer");
35        if(device->getProduct() == "") device->setProduct(e.string_attr("name"));
36        string resolution = e.string_attr("virtual_size");
37        string depth = e.string_attr("bits_per_pixel");
38        if(resolution != "") device->setConfig("resolution", resolution);
39        if(depth != "") device->setConfig("depth", depth);
40      }
41    }
42  
43    return true;
44  }