From patchwork Thu Sep 3 01:33:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhao, Yakui" X-Patchwork-Id: 45288 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n831YEOf010382 for ; Thu, 3 Sep 2009 01:34:14 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C54CCA01F6; Wed, 2 Sep 2009 18:34:13 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C4D4A01E7 for ; Wed, 2 Sep 2009 18:34:10 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 02 Sep 2009 18:34:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.44,271,1249282800"; d="scan'208";a="183506416" Received: from yakui_zhao.sh.intel.com (HELO localhost.localdomain) ([10.239.13.106]) by azsmga001.ch.intel.com with ESMTP; 02 Sep 2009 18:34:09 -0700 From: yakui.zhao@intel.com To: airlied@redhat.com Date: Thu, 3 Sep 2009 09:33:48 +0800 Message-Id: <1251941629-6694-3-git-send-email-yakui.zhao@intel.com> X-Mailer: git-send-email 1.5.4.5 In-Reply-To: <1251941629-6694-2-git-send-email-yakui.zhao@intel.com> References: <1251941629-6694-1-git-send-email-yakui.zhao@intel.com> <1251941629-6694-2-git-send-email-yakui.zhao@intel.com> Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.sourceforge.net Subject: [Intel-gfx] [Patch 3/4] DRM: add a function that can add the mode for the output device without EDID X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org From: Zhao Yakui Add a function that can be used to add the default mode for the output device without EDID. It will add the default mode that meets with the requirements of given hdisplay/vdisplay limit. Signed-off-by: Zhao Yakui --- drivers/gpu/drm/drm_edid.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_crtc.h | 2 + 2 files changed, 48 insertions(+) Index: linux-2.6/drivers/gpu/drm/drm_edid.c =================================================================== --- linux-2.6.orig/drivers/gpu/drm/drm_edid.c 2009-09-03 09:14:28.000000000 +0800 +++ linux-2.6/drivers/gpu/drm/drm_edid.c 2009-09-03 09:28:14.000000000 +0800 @@ -1215,3 +1215,49 @@ return num_modes; } EXPORT_SYMBOL(drm_add_edid_modes); + +/** + * drm_add_modes_noedid - add modes for the connectors without EDID + * @connector: connector we're probing + * @hdisplay: the horizontal display limit + * @vdisplay: the vertical display limit + * + * Add the specified modes to the connector's mode list. Only when the + * hdisplay/vdisplay is not beyond the given limit, it will be added. + * + * Return number of modes added or 0 if we couldn't find any. + */ +int drm_add_modes_noedid(struct drm_connector *connector, + int hdisplay, int vdisplay) +{ + int i, count, num_modes = 0; + struct drm_display_mode *mode, *ptr; + struct drm_device *dev = connector->dev; + + count = sizeof(drm_dmt_modes) / sizeof(struct drm_display_mode); + if (hdisplay < 0) + hdisplay = 0; + if (vdisplay < 0) + vdisplay = 0; + + for (i = 0; i < count; i++) { + ptr = &drm_dmt_modes[i]; + if (hdisplay && vdisplay) { + /* + * Only when two are valid, they will be used to check + * whether the mode should be added to the mode list of + * the connector. + */ + if (ptr->hdisplay > hdisplay || + ptr->vdisplay > vdisplay) + continue; + } + mode = drm_mode_duplicate(dev, ptr); + if (mode) { + drm_mode_probed_add(connector, mode); + num_modes++; + } + } + return num_modes; +} +EXPORT_SYMBOL(drm_add_modes_noedid); Index: linux-2.6/include/drm/drm_crtc.h =================================================================== --- linux-2.6.orig/include/drm/drm_crtc.h 2009-09-03 08:56:50.000000000 +0800 +++ linux-2.6/include/drm/drm_crtc.h 2009-09-03 09:24:38.000000000 +0800 @@ -750,4 +750,6 @@ extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool interlaced, int margins); +extern int drm_add_mode_noedid(struct drm_connector *connector, + int hdisplay, int vdisplay); #endif /* __DRM_CRTC_H__ */