From patchwork Fri Dec 28 07:01:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Sharma X-Patchwork-Id: 1914841 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 4C79BDF25A for ; Fri, 28 Dec 2012 10:38:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 39722E5DC8 for ; Fri, 28 Dec 2012 02:38:23 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id A03BFE5C82 for ; Thu, 27 Dec 2012 22:39:05 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MFQ0067JAEFYDO0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 28 Dec 2012 15:39:03 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [203.254.230.41]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 5C.9F.01231.78E3DD05; Fri, 28 Dec 2012 15:39:03 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-08-50dd3e87e288 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id BB.9F.01231.78E3DD05; Fri, 28 Dec 2012 15:39:03 +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 <0MFQ007PFAGO1S30@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Fri, 28 Dec 2012 15:39:03 +0900 (KST) From: Rahul Sharma To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/exynos: let drm handle edid allocations Date: Fri, 28 Dec 2012 02:01:13 -0500 Message-id: <1356678073-7492-1-git-send-email-rahul.sharma@samsung.com> X-Mailer: git-send-email 1.8.0 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsVy+t8zTd12u7sBBg9uW1lc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujL0vbzIWnDKp6Pj3h7mB8Yl2FyMnh4SAicTlO6/YIWwxiQv3 1rN1MXJxCAksY5To3/CdEaao//pMZojEdEaJA22/oao2Mkn8mHuWFaSKTUBXYvbBZ2AdIgLK En8nrmIEKWIWaGOU6Nu/GWyHsICNxK81M8GKWARUJeYe7wWL8wq4Sxz68YUFYp2cxIc9j9gh agQkvk0+BBTnAIrLSmw6wAxRsoNN4tzDBAhbUuLgihssExgFFzAyrGIUTS1ILihOSs811CtO zC0uzUvXS87P3cQICSupHYwrGywOMQpwMCrx8C7suRMgxJpYVlyZe4hRgoNZSYRX/wdQiDcl sbIqtSg/vqg0J7X4EKMP0CETmaVEk/OBIZ9XEm9obGBsaGhpaGZqaWqAQ1hJnLfZIyVASCA9 sSQ1OzW1ILUIZhwTB6dUA+Pi2f0njk95pOMwJ0hTPWA9o15hkH0Q53OBmX55Oc59oqd/3z81 k+vtw/bfq5Z4q+wzFjzwpp3J47SKUhaj04OETWITqxa3NOow8e2ON10uonVEb2950CmOF4cv dK1PWxunnrP+v5LAkddf4nc2h7bWbPrTemgB15WpYT/bpr32vSNQprdllqwSS3FGoqEWc1Fx IgC5cFaMWAIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKLMWRmVeSWpSXmKPExsVy+t9jQd12u7sBBscm6lpc+fqezYHR4373 caYAxqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wc oLFKCmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMI6xoy9L28yFpwyqej494e5 gfGJdhcjJ4eEgIlE//WZzBC2mMSFe+vZuhi5OIQEpjNKHGj7DeVsZJL4MfcsK0gVm4CuxOyD zxhBbBEBZYm/E1cxghQxC7QxSvTt38wOkhAWsJH4tWYmWBGLgKrE3OO9YHFeAXeJQz++sECs k5P4sOcR+wRG7gWMDKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxgsP2mdQOxpUNFocYBTgY lXh4F/bcCRBiTSwrrsw9xCjBwawkwqv/AyjEm5JYWZValB9fVJqTWnyI0Qdo+0RmKdHkfGBM 5ZXEGxqbmBlZGpkZm5gbG+MQVhLnbfZICRASSE8sSc1OTS1ILYIZx8TBKdXA2JgaIH/hp2XQ g+0S4mJHLyU6VqqVLVzEPNfnRM40E9a/1gkPbtTsnhb3p29+lOvOwntbez9HPvnFk5Ojvinv 4Lq0mubren4zBBIcz6zulnJZvvTjBeNVtzT7K8trmZ+nmS/6rm9/KFadITfVrZ/XwTbzpP4e Td2o74pRj/6mvZJ5nsqprJKrxFKckWioxVxUnAgAmuD3jIgCAAA= X-CFilter-Loop: Reflected X-Mailman-Approved-At: Fri, 28 Dec 2012 02:29:38 -0800 Cc: kgene.kim@samsung.com, seanpaul@google.com, sw0312.kim@samsung.com, joshi@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org There's no need to allocate edid twice and do a memcpy when drm helpers exist to do just that. This patch cleans that interaction up, and doesn't keep the edid hanging around in the connector. Signed-off-by: Sean Paul Signed-off-by: Rahul Sharma --- This patch is based on branch "exynos-drm-next" at http://git.kernel.org/?p=linux/kernel/git/daeinki/drm-exynos.git drivers/gpu/drm/exynos/exynos_drm_connector.c | 36 ++++++++++++++------------- drivers/gpu/drm/exynos/exynos_drm_drv.h | 4 +-- drivers/gpu/drm/exynos/exynos_drm_hdmi.c | 9 +++---- drivers/gpu/drm/exynos/exynos_drm_hdmi.h | 4 +-- drivers/gpu/drm/exynos/exynos_hdmi.c | 25 ++++++++----------- 5 files changed, 37 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c index ab37437..7ee43aa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_connector.c +++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c @@ -96,7 +96,9 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector) to_exynos_connector(connector); struct exynos_drm_manager *manager = exynos_connector->manager; struct exynos_drm_display_ops *display_ops = manager->display_ops; - unsigned int count; + unsigned int count = 0; + struct edid *edid = NULL; + int ret; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -114,27 +116,25 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector) * because lcd panel has only one mode. */ if (display_ops->get_edid) { - int ret; - void *edid; - - edid = kzalloc(MAX_EDID, GFP_KERNEL); - if (!edid) { - DRM_ERROR("failed to allocate edid\n"); - return 0; + edid = display_ops->get_edid(manager->dev, connector); + if (IS_ERR_OR_NULL(edid)) { + ret = PTR_ERR(edid); + edid = NULL; + DRM_ERROR("Panel operation get_edid failed %d\n", ret); + goto out; } - ret = display_ops->get_edid(manager->dev, connector, - edid, MAX_EDID); - if (ret < 0) { - DRM_ERROR("failed to get edid data.\n"); - kfree(edid); - edid = NULL; - return 0; + ret = drm_mode_connector_update_edid_property(connector, edid); + if (ret) { + DRM_ERROR("update edid property failed(%d)\n", ret); + goto out; } - drm_mode_connector_update_edid_property(connector, edid); count = drm_add_edid_modes(connector, edid); - kfree(edid); + if (count < 0) { + DRM_ERROR("Add edid modes failed %d\n", count); + goto out; + } } else { struct exynos_drm_panel_info *panel; struct drm_display_mode *mode = drm_mode_create(connector->dev); @@ -161,6 +161,8 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector) count = 1; } +out: + kfree(edid); return count; } diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index b9e51bc..4606fac 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -148,8 +148,8 @@ struct exynos_drm_overlay { struct exynos_drm_display_ops { enum exynos_drm_output_type type; bool (*is_connected)(struct device *dev); - int (*get_edid)(struct device *dev, struct drm_connector *connector, - u8 *edid, int len); + struct edid *(*get_edid)(struct device *dev, + struct drm_connector *connector); void *(*get_panel)(struct device *dev); int (*check_timing)(struct device *dev, void *timing); int (*power_on)(struct device *dev, int mode); diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c index 3a8eea6..681a4cb 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c @@ -108,18 +108,17 @@ static bool drm_hdmi_is_connected(struct device *dev) return false; } -static int drm_hdmi_get_edid(struct device *dev, - struct drm_connector *connector, u8 *edid, int len) +struct edid *drm_hdmi_get_edid(struct device *dev, + struct drm_connector *connector) { struct drm_hdmi_context *ctx = to_context(dev); DRM_DEBUG_KMS("%s\n", __FILE__); if (hdmi_ops && hdmi_ops->get_edid) - return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector, edid, - len); + return hdmi_ops->get_edid(ctx->hdmi_ctx->ctx, connector); - return 0; + return NULL; } static int drm_hdmi_check_timing(struct device *dev, void *timing) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h index ae4b6ae..45b2ce0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h @@ -30,8 +30,8 @@ struct exynos_drm_hdmi_context { struct exynos_hdmi_ops { /* display */ bool (*is_connected)(void *ctx); - int (*get_edid)(void *ctx, struct drm_connector *connector, - u8 *edid, int len); + struct edid *(*get_edid)(void *ctx, + struct drm_connector *connector); int (*check_timing)(void *ctx, void *timing); int (*power_on)(void *ctx, int mode); diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 8cb42ad..708108b 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -980,8 +980,7 @@ static bool hdmi_is_connected(void *ctx) return hdata->hpd; } -static int hdmi_get_edid(void *ctx, struct drm_connector *connector, - u8 *edid, int len) +static struct edid *hdmi_get_edid(void *ctx, struct drm_connector *connector) { struct edid *raw_edid; struct hdmi_context *hdata = ctx; @@ -989,22 +988,18 @@ static int hdmi_get_edid(void *ctx, struct drm_connector *connector, DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); if (!hdata->ddc_port) - return -ENODEV; + return ERR_PTR(-ENODEV); raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter); - if (raw_edid) { - hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid); - memcpy(edid, raw_edid, min((1 + raw_edid->extensions) - * EDID_LENGTH, len)); - DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n", - (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"), - raw_edid->width_cm, raw_edid->height_cm); - kfree(raw_edid); - } else { - return -ENODEV; - } + if (!raw_edid) + return ERR_PTR(-ENODEV); - return 0; + hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid); + DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n", + (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"), + raw_edid->width_cm, raw_edid->height_cm); + + return raw_edid; } static int hdmi_v13_check_timing(struct fb_videomode *check_timing)