All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rahul Sharma <rahul.sharma@samsung.com>
To: dri-devel@lists.freedesktop.org
Cc: t.stanislaws@samsung.com, l.krishna@samsung.com,
	joshi@samsung.com, kyungmin.park@samsung.com,
	fahad.k@samsung.com, rahul.sharma@samsung.com,
	prashanth.g@samsung.com, s.shirish@samsung.com
Subject: [PATCH v1 04/14] drm: exynos: hdmi: use s5p-hdmi platform data
Date: Thu, 04 Oct 2012 20:48:46 +0530	[thread overview]
Message-ID: <1349363936-8531-5-git-send-email-rahul.sharma@samsung.com> (raw)
In-Reply-To: <1349363936-8531-1-git-send-email-rahul.sharma@samsung.com>

From: Tomasz Stanislawski <t.stanislaws@samsung.com>

The 'exynos-drm-hdmi' driver makes use of s5p-tv platform devices. Therefore
the driver should use the same platform data to prevent crashes caused by
dereferencing incorrect types.  This patch corrects the exynos-drm-hdmi driver
to the platform data from s5p-hdmi.

Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_hdmi.c |   55 +++++++++++++++-------------------
 1 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 3902917..90dce8c 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -40,6 +40,9 @@
 
 #include "exynos_hdmi.h"
 
+#include <linux/gpio.h>
+#include <media/s5p_hdmi.h>
+
 #define MAX_WIDTH		1920
 #define MAX_HEIGHT		1080
 #define get_hdmi_context(dev)	platform_get_drvdata(to_platform_device(dev))
@@ -76,8 +79,7 @@ struct hdmi_context {
 	struct hdmi_resources		res;
 	void				*parent_ctx;
 
-	void				(*cfg_hpd)(bool external);
-	int				(*get_hpd)(void);
+	int				hpd_gpio;
 };
 
 /* HDMI Version 1.3 */
@@ -2024,8 +2026,6 @@ static void hdmi_poweron(struct hdmi_context *hdata)
 
 	hdata->powered = true;
 
-	if (hdata->cfg_hpd)
-		hdata->cfg_hpd(true);
 	mutex_unlock(&hdata->hdmi_mutex);
 
 	pm_runtime_get_sync(hdata->dev);
@@ -2061,8 +2061,6 @@ static void hdmi_poweroff(struct hdmi_context *hdata)
 	pm_runtime_put_sync(hdata->dev);
 
 	mutex_lock(&hdata->hdmi_mutex);
-	if (hdata->cfg_hpd)
-		hdata->cfg_hpd(false);
 
 	hdata->powered = false;
 
@@ -2110,17 +2108,13 @@ static irqreturn_t hdmi_external_irq_thread(int irq, void *arg)
 	struct exynos_drm_hdmi_context *ctx = arg;
 	struct hdmi_context *hdata = ctx->ctx;
 
-	if (!hdata->get_hpd)
-		goto out;
-
 	mutex_lock(&hdata->hdmi_mutex);
-	hdata->hpd = hdata->get_hpd();
+	hdata->hpd = gpio_get_value(hdata->hpd_gpio);
 	mutex_unlock(&hdata->hdmi_mutex);
 
 	if (ctx->drm_dev)
 		drm_helper_hpd_irq_event(ctx->drm_dev);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -2143,18 +2137,9 @@ static irqreturn_t hdmi_internal_irq_thread(int irq, void *arg)
 			HDMI_INTC_FLAG_HPD_PLUG);
 	}
 
-	mutex_lock(&hdata->hdmi_mutex);
-	hdata->hpd = hdmi_reg_read(hdata, HDMI_HPD_STATUS);
-	if (hdata->powered && hdata->hpd) {
-		mutex_unlock(&hdata->hdmi_mutex);
-		goto out;
-	}
-	mutex_unlock(&hdata->hdmi_mutex);
-
 	if (ctx->drm_dev)
 		drm_helper_hpd_irq_event(ctx->drm_dev);
 
-out:
 	return IRQ_HANDLED;
 }
 
@@ -2287,7 +2272,7 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct exynos_drm_hdmi_context *drm_hdmi_ctx;
 	struct hdmi_context *hdata;
-	struct exynos_drm_hdmi_pdata *pdata;
+	struct s5p_hdmi_platform_data *pdata;
 	struct resource *res;
 	int ret;
 	enum hdmi_type hdmi_type;
@@ -2323,8 +2308,7 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
 
 	hdmi_type = platform_get_device_id(pdev)->driver_data;
 	hdata->is_v13 = (hdmi_type == HDMI_TYPE13);
-	hdata->cfg_hpd = pdata->cfg_hpd;
-	hdata->get_hpd = pdata->get_hpd;
+	hdata->hpd_gpio = pdata->hpd_gpio;
 	hdata->dev = dev;
 
 	ret = hdmi_resources_init(hdata);
@@ -2342,11 +2326,17 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
 		goto err_resource;
 	}
 
+	ret = gpio_request(hdata->hpd_gpio, "HPD");
+	if (ret) {
+		DRM_ERROR("failed to request HPD gpio\n");
+		goto err_resource;
+	}
+
 	/* DDC i2c driver */
 	if (i2c_add_driver(&ddc_driver)) {
 		DRM_ERROR("failed to register ddc i2c driver\n");
 		ret = -ENOENT;
-		goto err_resource;
+		goto err_gpio;
 	}
 
 	hdata->ddc_port = hdmi_ddc;
@@ -2360,32 +2350,31 @@ static int __devinit hdmi_probe(struct platform_device *pdev)
 
 	hdata->hdmiphy_port = hdmi_hdmiphy;
 
-	hdata->external_irq = platform_get_irq_byname(pdev, "external_irq");
+	hdata->external_irq = gpio_to_irq(hdata->hpd_gpio);
 	if (hdata->external_irq < 0) {
-		DRM_ERROR("failed to get platform irq\n");
+		DRM_ERROR("failed to get GPIO external irq\n");
 		ret = hdata->external_irq;
 		goto err_hdmiphy;
 	}
 
-	hdata->internal_irq = platform_get_irq_byname(pdev, "internal_irq");
+	hdata->internal_irq = platform_get_irq(pdev, 0);
 	if (hdata->internal_irq < 0) {
 		DRM_ERROR("failed to get platform internal irq\n");
 		ret = hdata->internal_irq;
 		goto err_hdmiphy;
 	}
 
+	hdata->hpd = gpio_get_value(hdata->hpd_gpio);
+
 	ret = request_threaded_irq(hdata->external_irq, NULL,
 			hdmi_external_irq_thread, IRQF_TRIGGER_RISING |
 			IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 			"hdmi_external", drm_hdmi_ctx);
 	if (ret) {
-		DRM_ERROR("failed to register hdmi internal interrupt\n");
+		DRM_ERROR("failed to register hdmi external interrupt\n");
 		goto err_hdmiphy;
 	}
 
-	if (hdata->cfg_hpd)
-		hdata->cfg_hpd(false);
-
 	ret = request_threaded_irq(hdata->internal_irq, NULL,
 			hdmi_internal_irq_thread, IRQF_ONESHOT,
 			"hdmi_internal", drm_hdmi_ctx);
@@ -2407,6 +2396,8 @@ err_hdmiphy:
 	i2c_del_driver(&hdmiphy_driver);
 err_ddc:
 	i2c_del_driver(&ddc_driver);
+err_gpio:
+	gpio_free(hdata->hpd_gpio);
 err_resource:
 	hdmi_resources_cleanup(hdata);
 err_data:
@@ -2426,6 +2417,8 @@ static int __devexit hdmi_remove(struct platform_device *pdev)
 	free_irq(hdata->internal_irq, hdata);
 	free_irq(hdata->external_irq, hdata);
 
+	gpio_free(hdata->hpd_gpio);
+
 	hdmi_resources_cleanup(hdata);
 
 	/* hdmiphy i2c driver */
-- 
1.7.0.4

  parent reply	other threads:[~2012-10-04  7:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-04 15:18 [PATCH v1 00/14] drm: exynos: hdmi: add dt based support for exynos5 hdmi Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 01/14] media: s5p-hdmi: add HPD GPIO to platform data Rahul Sharma
2012-10-05  9:40   ` Tomasz Stanislawski
2012-10-04 15:18 ` [PATCH v1 02/14] drm: exynos: hdmi: support for platform variants Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 03/14] drm: exynos: hdmi: fix interrupt handling Rahul Sharma
2012-10-04 15:18 ` Rahul Sharma [this message]
2012-10-04 15:18 ` [PATCH v1 05/14] drm: exynos: hdmi: turn off HPD interrupt in HDMI chip Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 06/14] drm: exynos: remove drm hdmi platform data struct Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 07/14] drm: exynos: hdmi: add support for exynos5 ddc Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 08/14] drm: exynos: hdmi: add support for exynos5 hdmiphy Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 09/14] drm: exynos: hdmi: add support for platform variants for mixer Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 10/14] drm: exynos: hdmi: add support to disable video processor in mixer Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 11/14] drm: exynos: hdmi: add support for exynos5 mixer Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 12/14] drm: exynos: hdmi: replace is_v13 with version check in hdmi Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 13/14] drm: exynos: hdmi: add support for exynos5 hdmi Rahul Sharma
2012-10-04 15:18 ` [PATCH v1 14/14] drm: exynos: hdmi: remove drm common hdmi platform data struct Rahul Sharma
2012-10-04 15:42 [PATCH v1 00/14] drm: exynos: hdmi: add dt based support for exynos5 hdmi Rahul Sharma
2012-10-04 15:42 ` [PATCH v1 04/14] drm: exynos: hdmi: use s5p-hdmi platform data Rahul Sharma
2012-10-04 15:42   ` Rahul Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349363936-8531-5-git-send-email-rahul.sharma@samsung.com \
    --to=rahul.sharma@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fahad.k@samsung.com \
    --cc=joshi@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=l.krishna@samsung.com \
    --cc=prashanth.g@samsung.com \
    --cc=s.shirish@samsung.com \
    --cc=t.stanislaws@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.