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