Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (c) 2007 Intel Corporation
0004  *
0005  * Authers: Jesse Barnes <jesse.barnes@intel.com>
0006  */
0007 
0008 #include <linux/i2c.h>
0009 
0010 #include <drm/drm_edid.h>
0011 
0012 #include "psb_intel_drv.h"
0013 
0014 /**
0015  * psb_intel_ddc_probe
0016  * @adapter:   Associated I2C adaptor
0017  */
0018 bool psb_intel_ddc_probe(struct i2c_adapter *adapter)
0019 {
0020     u8 out_buf[] = { 0x0, 0x0 };
0021     u8 buf[2];
0022     int ret;
0023     struct i2c_msg msgs[] = {
0024         {
0025          .addr = 0x50,
0026          .flags = 0,
0027          .len = 1,
0028          .buf = out_buf,
0029          },
0030         {
0031          .addr = 0x50,
0032          .flags = I2C_M_RD,
0033          .len = 1,
0034          .buf = buf,
0035          }
0036     };
0037 
0038     ret = i2c_transfer(adapter, msgs, 2);
0039     if (ret == 2)
0040         return true;
0041 
0042     return false;
0043 }
0044 
0045 /**
0046  * psb_intel_ddc_get_modes - get modelist from monitor
0047  * @connector: DRM connector device to use
0048  * @adapter:   Associated I2C adaptor
0049  *
0050  * Fetch the EDID information from @connector using the DDC bus.
0051  */
0052 int psb_intel_ddc_get_modes(struct drm_connector *connector,
0053                 struct i2c_adapter *adapter)
0054 {
0055     struct edid *edid;
0056     int ret = 0;
0057 
0058     edid = drm_get_edid(connector, adapter);
0059     if (edid) {
0060         drm_connector_update_edid_property(connector, edid);
0061         ret = drm_add_edid_modes(connector, edid);
0062         kfree(edid);
0063     }
0064     return ret;
0065 }