Path: blob/master/drivers/gpu/drm/i915/intel_modes.c
15113 views
/*1* Copyright (c) 2007 Dave Airlie <[email protected]>2* Copyright (c) 2007, 2010 Intel Corporation3* Jesse Barnes <[email protected]>4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the "Software"),7* to deal in the Software without restriction, including without limitation8* the rights to use, copy, modify, merge, publish, distribute, sublicense,9* and/or sell copies of the Software, and to permit persons to whom the10* Software is furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice (including the next13* paragraph) shall be included in all copies or substantial portions of the14* Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL19* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING21* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER22* DEALINGS IN THE SOFTWARE.23*/2425#include <linux/slab.h>26#include <linux/i2c.h>27#include <linux/fb.h>28#include "drmP.h"29#include "intel_drv.h"30#include "i915_drv.h"3132/**33* intel_ddc_probe34*35*/36bool intel_ddc_probe(struct intel_encoder *intel_encoder, int ddc_bus)37{38struct drm_i915_private *dev_priv = intel_encoder->base.dev->dev_private;39u8 out_buf[] = { 0x0, 0x0};40u8 buf[2];41struct i2c_msg msgs[] = {42{43.addr = 0x50,44.flags = 0,45.len = 1,46.buf = out_buf,47},48{49.addr = 0x50,50.flags = I2C_M_RD,51.len = 1,52.buf = buf,53}54};5556return i2c_transfer(&dev_priv->gmbus[ddc_bus].adapter, msgs, 2) == 2;57}5859/**60* intel_ddc_get_modes - get modelist from monitor61* @connector: DRM connector device to use62* @adapter: i2c adapter63*64* Fetch the EDID information from @connector using the DDC bus.65*/66int intel_ddc_get_modes(struct drm_connector *connector,67struct i2c_adapter *adapter)68{69struct edid *edid;70int ret = 0;7172edid = drm_get_edid(connector, adapter);73if (edid) {74drm_mode_connector_update_edid_property(connector, edid);75ret = drm_add_edid_modes(connector, edid);76connector->display_info.raw_edid = NULL;77kfree(edid);78}7980return ret;81}8283static const char *force_audio_names[] = {84"off",85"auto",86"on",87};8889void90intel_attach_force_audio_property(struct drm_connector *connector)91{92struct drm_device *dev = connector->dev;93struct drm_i915_private *dev_priv = dev->dev_private;94struct drm_property *prop;95int i;9697prop = dev_priv->force_audio_property;98if (prop == NULL) {99prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,100"audio",101ARRAY_SIZE(force_audio_names));102if (prop == NULL)103return;104105for (i = 0; i < ARRAY_SIZE(force_audio_names); i++)106drm_property_add_enum(prop, i, i-1, force_audio_names[i]);107108dev_priv->force_audio_property = prop;109}110drm_connector_attach_property(connector, prop, 0);111}112113static const char *broadcast_rgb_names[] = {114"Full",115"Limited 16:235",116};117118void119intel_attach_broadcast_rgb_property(struct drm_connector *connector)120{121struct drm_device *dev = connector->dev;122struct drm_i915_private *dev_priv = dev->dev_private;123struct drm_property *prop;124int i;125126prop = dev_priv->broadcast_rgb_property;127if (prop == NULL) {128prop = drm_property_create(dev, DRM_MODE_PROP_ENUM,129"Broadcast RGB",130ARRAY_SIZE(broadcast_rgb_names));131if (prop == NULL)132return;133134for (i = 0; i < ARRAY_SIZE(broadcast_rgb_names); i++)135drm_property_add_enum(prop, i, i, broadcast_rgb_names[i]);136137dev_priv->broadcast_rgb_property = prop;138}139140drm_connector_attach_property(connector, prop, 0);141}142143144