/* * mon.C * * On recupere a coups d'ioctl() des informations sur l'ecran attache' * a la station. * * D'apres /usr/include/sys/fbio.h: * * struct mon_info * { * u_long mon_type; -- bit array: defined above * u_long pixfreq; -- pixel frequency in Hz * u_long hfreq; -- horizontal freq in Hz * u_long vfreq; -- vertical freq in Hz * u_long vsync; -- vertical sync in scanlines * u_long hsync; -- horizontal sync in pixels * -- these are in pixel units * u_short hfporch; -- horizontal front porch * u_short hbporch; -- horizontal back porch * u_short vfporch; -- vertical front porch * u_short vbporch; -- vertical back porch * }; * * Renaud Waldura * Tue Feb 21 19:40:18 1995 * */ #include #include #include #include #include #include ostream& operator << (ostream& os, const struct mon_info& mif) { os << "bit array: " << mif.mon_type << "\npixel frequency: " << mif.pixfreq << " Hz" << "\nhorizontal frequency: " << mif.hfreq << " Hz" << "\nvertical frequency: " << mif.vfreq << " Hz" << "\nvertical sync: " << mif.vsync << " scanlines" << "\nhorizontal sync: " << mif.hsync << " pixels" << "\nhorizontal front porch: " << mif.hfporch << " pixels" << "\nhorizontal back porch: " << mif.hbporch << " pixels" << "\nvertical front porch: " << mif.vfporch << " pixels" << "\nvertical back porch: " << mif.vbporch << " pixels"; return os; } const char* prog_name; void errif (bool error) { if (!error) return; perror(prog_name); exit(1); } main (int argc, const char* argv[]) { prog_name = argv[0]; const char* dev_name = (argc == 2) ? argv[1] : "/dev/cgsix0"; int cg = open(dev_name, O_RDONLY); errif(cg == -1); struct mon_info mif; errif( ioctl(cg, FBIOMONINFO, &mif) == -1 ); cout << "Information on monitor attached to " << dev_name << ": \n" << mif << endl; return 0; }