| 1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- |
| 2 |
* |
| 3 |
* Copyright (C) 2013 Richard Hughes <[email protected]> |
| 4 |
* |
| 5 |
* Licensed under the GNU Lesser General Public License Version 2.1 |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Lesser General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2.1 of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This library is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public |
| 18 |
* License along with this library; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
*/ |
| 21 |
|
| 22 |
//gcc -o test test.c cd-edid.c `pkg-config --cflags --libs colord` -I../.. -Wall |
| 23 |
|
| 24 |
#include <stdlib.h> |
| 25 |
#include <stdio.h> |
| 26 |
|
| 27 |
#include "cd-compat-edid.h" |
| 28 |
|
| 29 |
int |
| 30 |
main (int argc, char *argv[]) |
| 31 |
{ |
| 32 |
CdEdidError rc; |
| 33 |
char *profile = NULL; |
| 34 |
gboolean ret; |
| 35 |
gchar *edid; |
| 36 |
GError *error = NULL; |
| 37 |
gsize edid_len = 0; |
| 38 |
|
| 39 |
/* load EDID blob derived from: |
| 40 |
* cat /sys/class/drm/card0-LVDS-1/edid > edid.bin */ |
| 41 |
ret = g_file_get_contents ("edid.bin", (gchar**) &edid, &edid_len, &error); |
| 42 |
if (!ret) { |
| 43 |
g_warning ("Failed to load file: %s", error->message); |
| 44 |
g_error_free (error); |
| 45 |
return EXIT_FAILURE; |
| 46 |
} |
| 47 |
|
| 48 |
/* test libcolordcompat */ |
| 49 |
rc = cd_edid_get_profile ((unsigned char *) edid, edid_len, &profile); |
| 50 |
if (rc != CD_EDID_ERROR_OK) { |
| 51 |
printf("Failed to get profile, error is %i\n", rc); |
| 52 |
return EXIT_FAILURE; |
| 53 |
} |
| 54 |
printf("Profile to use is %s\n", profile); |
| 55 |
free(profile); |
| 56 |
|
| 57 |
return EXIT_SUCCESS; |
| 58 |
} |