Loading...
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 <drm/drm_edid.h>
11
12#include "psb_intel_drv.h"
13
14/**
15 * psb_intel_ddc_probe
16 * @adapter: Associated I2C adaptor
17 */
18bool psb_intel_ddc_probe(struct i2c_adapter *adapter)
19{
20 u8 out_buf[] = { 0x0, 0x0 };
21 u8 buf[2];
22 int ret;
23 struct i2c_msg msgs[] = {
24 {
25 .addr = 0x50,
26 .flags = 0,
27 .len = 1,
28 .buf = out_buf,
29 },
30 {
31 .addr = 0x50,
32 .flags = I2C_M_RD,
33 .len = 1,
34 .buf = buf,
35 }
36 };
37
38 ret = i2c_transfer(adapter, msgs, 2);
39 if (ret == 2)
40 return true;
41
42 return false;
43}
44
45/**
46 * psb_intel_ddc_get_modes - get modelist from monitor
47 * @connector: DRM connector device to use
48 * @adapter: Associated I2C adaptor
49 *
50 * Fetch the EDID information from @connector using the DDC bus.
51 */
52int psb_intel_ddc_get_modes(struct drm_connector *connector,
53 struct i2c_adapter *adapter)
54{
55 struct edid *edid;
56 int ret = 0;
57
58 edid = drm_get_edid(connector, adapter);
59 if (edid) {
60 drm_connector_update_edid_property(connector, edid);
61 ret = drm_add_edid_modes(connector, edid);
62 kfree(edid);
63 }
64 return ret;
65}
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 * @adapter: Associated I2C adaptor
15 */
16bool 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 * @adapter: Associated I2C adaptor
47 *
48 * Fetch the EDID information from @connector using the DDC bus.
49 */
50int psb_intel_ddc_get_modes(struct drm_connector *connector,
51 struct i2c_adapter *adapter)
52{
53 struct edid *edid;
54 int ret = 0;
55
56 edid = drm_get_edid(connector, adapter);
57 if (edid) {
58 drm_connector_update_edid_property(connector, edid);
59 ret = drm_add_edid_modes(connector, edid);
60 kfree(edid);
61 }
62 return ret;
63}