modesetting-101: rename modeflags, as to avoid conflicts with the xorg definitions
[platform/upstream/libdrm.git] / linux-core / intel_modes.c
1 /*
2  * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
3  * Copyright (c) 2007 Intel Corporation
4  *   Jesse Barnes <jesse.barnes@intel.com>
5  */
6
7 #include <linux/i2c.h>
8 #include <linux/fb.h>
9 #include "drmP.h"
10 #include "intel_drv.h"
11
12 /**
13  * intel_ddc_probe
14  *
15  */
16 bool intel_ddc_probe(struct intel_output *intel_output)
17 {
18         u8 out_buf[] = { 0x0, 0x0};
19         u8 buf[2];
20         int ret;
21         struct i2c_msg msgs[] = {
22                 {
23                         .addr = 0x50,
24                         .flags = 0,
25                         .len = 1,
26                         .buf = out_buf,
27                 },
28                 {
29                         .addr = 0x50,
30                         .flags = I2C_M_RD,
31                         .len = 1,
32                         .buf = buf,
33                 }
34         };
35
36         ret = i2c_transfer(&intel_output->ddc_bus->adapter, msgs, 2);
37         if (ret == 2)
38                 return true;
39
40         return false;
41 }
42
43 /**
44  * intel_ddc_get_modes - get modelist from monitor
45  * @connector: DRM connector device to use
46  *
47  * Fetch the EDID information from @connector using the DDC bus.
48  */
49 int intel_ddc_get_modes(struct intel_output *intel_output)
50 {
51         struct edid *edid;
52         int ret = 0;
53
54         edid = drm_get_edid(&intel_output->base, &intel_output->ddc_bus->adapter);
55         if (edid) {
56                 drm_mode_connector_update_edid_property(&intel_output->base, edid);
57                 ret = drm_add_edid_modes(&intel_output->base, edid);
58                 kfree(edid);
59         }
60         return ret;
61 }