Commit | Line | Data |
---|---|---|
89c78134 AC |
1 | /* |
2 | * Copyright (c) 2007 Intel Corporation | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | * | |
17 | * Authers: Jesse Barnes <jesse.barnes@intel.com> | |
18 | */ | |
19 | ||
20 | #include <linux/i2c.h> | |
89c78134 AC |
21 | #include <drm/drmP.h> |
22 | #include "psb_intel_drv.h" | |
23 | ||
24 | /** | |
25 | * psb_intel_ddc_probe | |
26 | * | |
27 | */ | |
352b16a0 | 28 | bool psb_intel_ddc_probe(struct i2c_adapter *adapter) |
89c78134 AC |
29 | { |
30 | u8 out_buf[] = { 0x0, 0x0 }; | |
31 | u8 buf[2]; | |
32 | int ret; | |
33 | struct i2c_msg msgs[] = { | |
34 | { | |
35 | .addr = 0x50, | |
36 | .flags = 0, | |
37 | .len = 1, | |
38 | .buf = out_buf, | |
39 | }, | |
40 | { | |
41 | .addr = 0x50, | |
42 | .flags = I2C_M_RD, | |
43 | .len = 1, | |
44 | .buf = buf, | |
45 | } | |
46 | }; | |
47 | ||
352b16a0 | 48 | ret = i2c_transfer(adapter, msgs, 2); |
89c78134 AC |
49 | if (ret == 2) |
50 | return true; | |
51 | ||
52 | return false; | |
53 | } | |
54 | ||
55 | /** | |
56 | * psb_intel_ddc_get_modes - get modelist from monitor | |
57 | * @connector: DRM connector device to use | |
58 | * | |
59 | * Fetch the EDID information from @connector using the DDC bus. | |
60 | */ | |
352b16a0 PJ |
61 | int psb_intel_ddc_get_modes(struct drm_connector *connector, |
62 | struct i2c_adapter *adapter) | |
89c78134 AC |
63 | { |
64 | struct edid *edid; | |
65 | int ret = 0; | |
66 | ||
352b16a0 | 67 | edid = drm_get_edid(connector, adapter); |
89c78134 | 68 | if (edid) { |
352b16a0 PJ |
69 | drm_mode_connector_update_edid_property(connector, edid); |
70 | ret = drm_add_edid_modes(connector, edid); | |
89c78134 AC |
71 | kfree(edid); |
72 | } | |
73 | return ret; | |
74 | } |