X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=blobdiff_plain;f=src%2Flib%2Fplatform%2FX11%2Frandr-edid.cpp;fp=src%2Flib%2Fplatform%2FX11%2Frandr-edid.cpp;h=4de17e4a111cd7705448dcc75bcad397c97cf3a1;hp=0000000000000000000000000000000000000000;hb=b45bdacdeee5c96e0294717fbe2c47a49a110fd1;hpb=81e38211724bc6e8bd7a60f484433053ed682635 diff --git a/src/lib/platform/X11/randr-edid.cpp b/src/lib/platform/X11/randr-edid.cpp new file mode 100644 index 0000000..4de17e4 --- /dev/null +++ b/src/lib/platform/X11/randr-edid.cpp @@ -0,0 +1,166 @@ +/* + * This file is part of the libCEC(R) library. + * + * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is an original work, containing original code. + * + * libCEC(R) is a trademark of Pulse-Eight Limited. + * + * This program is dual-licensed; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * Alternatively, you can license this library under a commercial license, + * please contact Pulse-Eight Licensing for more information. + * + * For more information contact: + * Pulse-Eight Licensing + * http://www.pulse-eight.com/ + * http://www.pulse-eight.net/ + */ + +#include "env.h" + +#include "lib/platform/os.h" +#include "randr-edid.h" + +#include +#include +#include + +#include + +using namespace PLATFORM; + +static const char * const edid_names[] = +{ +#if (RANDR_MAJOR > 1) || (RANDR_MAJOR == 1 && RANDR_MINOR >2) + RR_PROPERTY_RANDR_EDID, +#else + "EDID", +#endif + "EDID_DATA", + "XFree86_DDC_EDID1_RAWDATA" +}; + +#define EDID_NAME_COUNT (sizeof(edid_names)/sizeof(*edid_names)) + +uint16_t CRandrEdidParser::GetPhysicalAddress(void) +{ + uint16_t physical_address = 0; + + /* open default X11 DISPLAY */ + Display *disp = XOpenDisplay(NULL); + if( disp ) + { + int event_base, error_base; + int maj, min; + + if( XRRQueryExtension(disp, &event_base, &error_base) + && XRRQueryVersion(disp, &maj, &min) ) + { + int version = (maj << 8) | min; + + if( version >= 0x0102 ) + { + size_t atom_avail = 0; + Atom edid_atoms[EDID_NAME_COUNT]; + + if( XInternAtoms(disp, (char **)edid_names, EDID_NAME_COUNT, True, edid_atoms) ) + { + /* remove missing some atoms */ + atom_avail = 0; + for(size_t atom_count=0; atom_count 0 ) + { + int scr_count = ScreenCount(disp); + int screen; + + for(screen=0; screen 1) || (RANDR_MAJOR == 1 && RANDR_MINOR >=3) + if( version >= 0x0103 ) + { + /* get cached resources if they are available */ + rsrc = XRRGetScreenResourcesCurrent(disp, root); + } + + if( NULL == rsrc ) +#endif + rsrc = XRRGetScreenResources(disp, root); + + if( NULL != rsrc ) + { + int output_id; + for( output_id=0; 0 == physical_address && output_id < rsrc->noutput; ++output_id ) + { + RROutput rr_output_id = rsrc->outputs[output_id]; + XRROutputInfo *output_info = XRRGetOutputInfo(disp, rsrc, rr_output_id); + if( NULL != output_info ) + { + if( RR_Connected == output_info->connection ) + { + for(size_t atom_count=0; 0 == physical_address && atom_count