From patchwork Tue Feb 26 12:36:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Sharma X-Patchwork-Id: 2185431 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C80A7DF215 for ; Tue, 26 Feb 2013 12:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752181Ab3BZMQz (ORCPT ); Tue, 26 Feb 2013 07:16:55 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:29743 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754751Ab3BZMQy (ORCPT ); Tue, 26 Feb 2013 07:16:54 -0500 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MIT00E3PU44RO60@mailout3.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 26 Feb 2013 21:16:52 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 04.CB.17763.4B7AC215; Tue, 26 Feb 2013 21:16:52 +0900 (KST) X-AuditID: cbfee690-b7f6b6d000004563-7b-512ca7b461bd Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 8B.1D.03880.4B7AC215; Tue, 26 Feb 2013 21:16:52 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MIT0062DU28BFU0@mmp2.samsung.com>; Tue, 26 Feb 2013 21:16:52 +0900 (KST) From: Rahul Sharma To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Cc: inki.dae@samsung.com, r.sh.open@gmail.com, sw0312.kim@samsung.com, joshi@samsung.com Subject: [PATCH] drm/exynos: hdmi: move mode_fixup to drm common hdmi Date: Tue, 26 Feb 2013 07:36:28 -0500 Message-id: <1361882188-17956-1-git-send-email-rahul.sharma@samsung.com> X-Mailer: git-send-email 1.8.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsWyRsSkSnfLcp1Ag+svDS2ufH3PZjHp/gQW i++7vrBbzDi/j8li4Yt4ixmTX7I5sHnsnHWX3eN+93Emj74tqxg9Pm+SC2CJ4rJJSc3JLEst 0rdL4Mro2nyGsWCORsW5+y8ZGxjnKnYxcnJICJhITN7xghnCFpO4cG89G4gtJLCUUWJbpw1M za/HrYxdjFxA8emMEqenv2KDcHqZJDobL4F1swnoSsw++IwRxBYRcJNoOjyTFcRmFoiSuHNu PhOILSzgKnFj+QSwGhYBVYkXvcvBtvEKeEic3PWbDWKbnMSHPY/YIez3bBJXnylA1AtIfJt8 iKWLkQMoLiux6QDU0ZISB1fcYJnAKLiAkWEVo2hqQXJBcVJ6kYlecWJucWleul5yfu4mRmB4 nv73bMIOxnsHrA8xJgONm8gsJZqcDwzvvJJ4Q2MTc1NjUzMjS0tLU9KElcR55S/JBAoJpCeW pGanphakFsUXleakFh9iZOLglGpgXD2Tq3lq5CSVVxttHt6ZHilnMTXpcqefPpPqw9OvTVrZ np1kvuK47u6s3ue3RQTT8xZefvMpa8Mirc+Vr5NW6xvcll/fLf4h9U7xgWR/H6ffan/vbX7h +E4oNTJKfOLfW2EBs/7u0mlV9+A+ZsPZFOsqbvf0Y2VI/o43hRFPc/u05D/cKPNgU2Ipzkg0 1GIuKk4EAAphETxlAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsVy+t9jQd0ty3UCDbpOqVtc+fqezWLS/Qks Ft93fWG3mHF+H5PFwhfxFjMmv2RzYPPYOesuu8f97uNMHn1bVjF6fN4kF8AS1cBok5GamJJa pJCal5yfkpmXbqvkHRzvHG9qZmCoa2hpYa6kkJeYm2qr5OIToOuWmQO0XEmhLDGnFCgUkFhc rKRvh2lCaIibrgVMY4Sub0gQXI+RARpIWMOY0bX5DGPBHI2Kc/dfMjYwzlXsYuTkkBAwkfj1 uJURwhaTuHBvPVsXIxeHkMB0RonT019BOb1MEp2Nl5hBqtgEdCVmH3wG1iEi4CbRdHgmK4jN LBAlcefcfCYQW1jAVeLG8glgNSwCqhIvepezgdi8Ah4SJ3f9ZoPYJifxYc8j9gmM3AsYGVYx iqYWJBcUJ6XnGukVJ+YWl+al6yXn525iBEfAM+kdjKsaLA4xCnAwKvHwanRoBwqxJpYVV+Ye YpTgYFYS4Q2p0wkU4k1JrKxKLcqPLyrNSS0+xJgMtH0is5Rocj4wOvNK4g2NTcxNjU0tTSxM zCxJE1YS52U89SRASCA9sSQ1OzW1ILUIZgsTB6dUA6Np3vlKgU9zj37VzFkVx3eRJS5hdmLC Jv/T0amPFq5QeHX4VECH0eGJB9Y2BzJOWbcv1uaV+ssE5ncb9HYZ2RzZ7GrRJqXc9XK1e/a3 oLkbE6rlly1LWME+4YgNU8XxRJ/vNakfb6dkafAr5/nsihTarGWn2PWT/2G5cVf+keL+3d1J votsXJVYijMSDbWYi4oTAXFaI/zEAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Currently, mode_fixup code doesn't consider the limitations of mixer as it is implemented inside the hdmi driver. Following fix, moves the mode_fixup to common drm hdmi driver. To check the mode support, it calls both, mixer and hdmi check_timing callbacks for a given resolution mode. This patch is dependent on https://patchwork.kernel.org/patch/2176021/. Signed-off-by: Rahul Sharma --- It is based on exynos-drm-next-todo branch at git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git drivers/gpu/drm/exynos/exynos_drm_hdmi.c | 40 ++++++++++++++++++++++++--- drivers/gpu/drm/exynos/exynos_drm_hdmi.h | 3 -- drivers/gpu/drm/exynos/exynos_hdmi.c | 47 -------------------------------- 3 files changed, 36 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c index d7db69b..5dc956b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c @@ -205,13 +205,45 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_hdmi_context *ctx = to_context(subdrv_dev); + struct drm_display_mode *m; + int mode_ok; DRM_DEBUG_KMS("%s\n", __FILE__); - if (hdmi_ops && hdmi_ops->mode_fixup) - hdmi_ops->mode_fixup(ctx->hdmi_ctx->ctx, connector, mode, - adjusted_mode); + drm_mode_set_crtcinfo(adjusted_mode, 0); + + mode_ok = drm_hdmi_check_timing(subdrv_dev, adjusted_mode); + + /* just return if user desired mode exists. */ + if (mode_ok == 0) + return; + + /* + * otherwise, find the most suitable mode among modes and change it + * to adjusted_mode. + */ + list_for_each_entry(m, &connector->modes, head) { + mode_ok = drm_hdmi_check_timing(subdrv_dev, m); + + if (mode_ok == 0) { + struct drm_mode_object base; + struct list_head head; + + DRM_INFO("desired mode doesn't exist so\n"); + DRM_INFO("use the most suitable mode among modes.\n"); + + DRM_DEBUG_KMS("Adjusted Mode: [%d]x[%d] [%d]Hz\n", + m->hdisplay, m->vdisplay, m->vrefresh); + + /* preserve display mode header while copying. */ + head = adjusted_mode->head; + base = adjusted_mode->base; + memcpy(adjusted_mode, m, sizeof(*m)); + adjusted_mode->head = head; + adjusted_mode->base = base; + break; + } + } } static void drm_hdmi_mode_set(struct device *subdrv_dev, void *mode) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h index 844addb..fd2ff9f 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h @@ -36,9 +36,6 @@ struct exynos_hdmi_ops { int (*power_on)(void *ctx, int mode); /* manager */ - void (*mode_fixup)(void *ctx, struct drm_connector *connector, - const struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode); void (*mode_set)(void *ctx, struct drm_display_mode *mode); void (*get_max_resol)(void *ctx, unsigned int *width, unsigned int *height); diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index d8d78a6..a5ca2cc 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -1431,52 +1431,6 @@ static void hdmi_conf_apply(struct hdmi_context *hdata) hdmi_regs_dump(hdata, "start"); } -static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector, - const struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) -{ - struct drm_display_mode *m; - struct hdmi_context *hdata = ctx; - int index; - - DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); - - drm_mode_set_crtcinfo(adjusted_mode, 0); - - index = hdmi_find_phy_conf(hdata, adjusted_mode->clock * 1000); - - /* just return if user desired mode exists. */ - if (index >= 0) - return; - - /* - * otherwise, find the most suitable mode among modes and change it - * to adjusted_mode. - */ - list_for_each_entry(m, &connector->modes, head) { - index = hdmi_find_phy_conf(hdata, m->clock * 1000); - - if (index >= 0) { - struct drm_mode_object base; - struct list_head head; - - DRM_INFO("desired mode doesn't exist so\n"); - DRM_INFO("use the most suitable mode among modes.\n"); - - DRM_DEBUG_KMS("Adjusted Mode: [%d]x[%d] [%d]Hz\n", - m->hdisplay, m->vdisplay, m->vrefresh); - - /* preserve display mode header while copying. */ - head = adjusted_mode->head; - base = adjusted_mode->base; - memcpy(adjusted_mode, m, sizeof(*m)); - adjusted_mode->head = head; - adjusted_mode->base = base; - break; - } - } -} - static void hdmi_set_reg(u8 *reg_pair, int num_bytes, u32 value) { int i; @@ -1810,7 +1764,6 @@ static struct exynos_hdmi_ops hdmi_ops = { .check_timing = hdmi_check_timing, /* manager */ - .mode_fixup = hdmi_mode_fixup, .mode_set = hdmi_mode_set, .get_max_resol = hdmi_get_max_resol, .commit = hdmi_commit,