1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2007 Intel Corporation
4 *
5 * Authers: Jesse Barnes <jesse.barnes@intel.com>
6 */
7
8 #include <linux/i2c.h>
9
10 #include "psb_intel_drv.h"
11
12 /**
13 * psb_intel_ddc_probe
14 *
15 */
psb_intel_ddc_probe(struct i2c_adapter * adapter)16 bool psb_intel_ddc_probe(struct i2c_adapter *adapter)
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(adapter, msgs, 2);
37 if (ret == 2)
38 return true;
39
40 return false;
41 }
42
43 /**
44 * psb_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 */
psb_intel_ddc_get_modes(struct drm_connector * connector,struct i2c_adapter * adapter)49 int psb_intel_ddc_get_modes(struct drm_connector *connector,
50 struct i2c_adapter *adapter)
51 {
52 struct edid *edid;
53 int ret = 0;
54
55 edid = drm_get_edid(connector, adapter);
56 if (edid) {
57 drm_connector_update_edid_property(connector, edid);
58 ret = drm_add_edid_modes(connector, edid);
59 kfree(edid);
60 }
61 return ret;
62 }
63