All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@nokia.com>
To: Antonino Daplas <adaplas@gmail.com>
Cc: linux-fbdev-devel@lists.sourceforge.net,
	linux-omap@vger.kernel.org, Tony Lindgren <tony@atomide.com>,
	Tomi Valkeinen <Tomi.Valkeinen@nokia.com>,
	Daniel Stone <daniel.stone@nokia.com>,
	Imre Deak <imre.deak@nokia.com>
Subject: [PATCH 16/20] omapfb: dispc: Allow multiple external IRQ handlers
Date: Thu,  4 Jun 2009 20:52:41 +0300	[thread overview]
Message-ID: <024fee28b6c89decf0d50747127db8fc61ac789e.1244131952.git.imre.deak@nokia.com> (raw)
In-Reply-To: <36ddd74a50b8c225b2c571035c67dbff4686b881.1244131952.git.imre.deak@nokia.com>
In-Reply-To: <fab39c1a822c428466db6a19531be646d483664e.1244131952.git.imre.deak@nokia.com>

From: Daniel Stone <daniel.stone@nokia.com>

Previously, the only external (to dispc.c) IRQ handler was RFBI's
frame done handler.  dispc's IRQ framework was very dumb: you could only
have one handler, and the semantics of {request,free}_irq were odd, to
say the least.

The new framework allows multiple consumers to register arbitrary IRQ
masks.

Signed-off-by: Daniel Stone <daniel.stone@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Imre Deak <imre.deak@nokia.com>
---
 drivers/video/omap/dispc.c |   95 +++++++++++++++++++++++++++-----------------
 drivers/video/omap/dispc.h |    7 ++-
 drivers/video/omap/rfbi.c  |    7 ++-
 3 files changed, 67 insertions(+), 42 deletions(-)

diff --git a/drivers/video/omap/dispc.c b/drivers/video/omap/dispc.c
index 9adf54e..350b444 100644
--- a/drivers/video/omap/dispc.c
+++ b/drivers/video/omap/dispc.c
@@ -155,6 +155,8 @@ struct resmap {
 	unsigned long	*map;
 };
 
+#define MAX_IRQ_HANDLERS            4
+
 static struct {
 	void __iomem	*base;
 
@@ -167,9 +169,11 @@ static struct {
 
 	int		ext_mode;
 
-	unsigned long	enabled_irqs;
-	void		(*irq_callback)(void *);
-	void		*irq_callback_data;
+	struct {
+		u32	irq_mask;
+		void	(*callback)(void *);
+		void	*data;
+	} irq_handlers[MAX_IRQ_HANDLERS];
 	struct completion	frame_done;
 
 	int		fir_hinc[OMAPFB_PLANE_NUM];
@@ -809,56 +813,70 @@ static void set_lcd_timings(void)
 	panel->pixel_clock = fck / lck_div / pck_div / 1000;
 }
 
-int omap_dispc_request_irq(void (*callback)(void *data), void *data)
+static void recalc_irq_mask(void)
 {
-	int r = 0;
+	int i;
+	unsigned long irq_mask = DISPC_IRQ_MASK_ERROR;
 
-	BUG_ON(callback == NULL);
+	for (i = 0; i < MAX_IRQ_HANDLERS; i++) {
+		if (!dispc.irq_handlers[i].callback)
+			continue;
 
-	if (dispc.irq_callback)
-		r = -EBUSY;
-	else {
-		dispc.irq_callback = callback;
-		dispc.irq_callback_data = data;
+		irq_mask |= dispc.irq_handlers[i].irq_mask;
 	}
 
-	return r;
-}
-EXPORT_SYMBOL(omap_dispc_request_irq);
-
-void omap_dispc_enable_irqs(int irq_mask)
-{
 	enable_lcd_clocks(1);
-	dispc.enabled_irqs = irq_mask;
-	irq_mask |= DISPC_IRQ_MASK_ERROR;
 	MOD_REG_FLD(DISPC_IRQENABLE, 0x7fff, irq_mask);
 	enable_lcd_clocks(0);
 }
-EXPORT_SYMBOL(omap_dispc_enable_irqs);
 
-void omap_dispc_disable_irqs(int irq_mask)
+int omap_dispc_request_irq(unsigned long irq_mask, void (*callback)(void *data),
+			   void *data)
 {
-	enable_lcd_clocks(1);
-	dispc.enabled_irqs &= ~irq_mask;
-	irq_mask &= ~DISPC_IRQ_MASK_ERROR;
-	MOD_REG_FLD(DISPC_IRQENABLE, 0x7fff, irq_mask);
-	enable_lcd_clocks(0);
+	int i;
+
+	BUG_ON(callback == NULL);
+
+	for (i = 0; i < MAX_IRQ_HANDLERS; i++) {
+		if (dispc.irq_handlers[i].callback)
+			continue;
+
+		dispc.irq_handlers[i].irq_mask = irq_mask;
+		dispc.irq_handlers[i].callback = callback;
+		dispc.irq_handlers[i].data = data;
+		recalc_irq_mask();
+
+		return 0;
+	}
+
+	return -EBUSY;
 }
-EXPORT_SYMBOL(omap_dispc_disable_irqs);
+EXPORT_SYMBOL(omap_dispc_request_irq);
 
-void omap_dispc_free_irq(void)
+void omap_dispc_free_irq(unsigned long irq_mask, void (*callback)(void *data),
+			 void *data)
 {
-	enable_lcd_clocks(1);
-	omap_dispc_disable_irqs(DISPC_IRQ_MASK_ALL);
-	dispc.irq_callback = NULL;
-	dispc.irq_callback_data = NULL;
-	enable_lcd_clocks(0);
+	int i;
+
+	for (i = 0; i < MAX_IRQ_HANDLERS; i++) {
+		if (dispc.irq_handlers[i].callback == callback &&
+		    dispc.irq_handlers[i].data == data) {
+			dispc.irq_handlers[i].irq_mask = 0;
+			dispc.irq_handlers[i].callback = NULL;
+			dispc.irq_handlers[i].data = NULL;
+			recalc_irq_mask();
+			return;
+		}
+	}
+
+	BUG();
 }
 EXPORT_SYMBOL(omap_dispc_free_irq);
 
 static irqreturn_t omap_dispc_irq_handler(int irq, void *dev)
 {
 	u32 stat;
+	int i = 0;
 
 	enable_lcd_clocks(1);
 
@@ -873,8 +891,12 @@ static irqreturn_t omap_dispc_irq_handler(int irq, void *dev)
 		}
 	}
 
-	if ((stat & dispc.enabled_irqs) && dispc.irq_callback)
-		dispc.irq_callback(dispc.irq_callback_data);
+	for (i = 0; i < MAX_IRQ_HANDLERS; i++) {
+		if (unlikely(dispc.irq_handlers[i].callback &&
+			     (stat & dispc.irq_handlers[i].irq_mask)))
+			dispc.irq_handlers[i].callback(
+						dispc.irq_handlers[i].data);
+	}
 
 	dispc_write_reg(DISPC_IRQSTATUS, stat);
 
@@ -1410,8 +1432,7 @@ static int omap_dispc_init(struct omapfb_device *fbdev, int ext_mode,
 	l = dispc_read_reg(DISPC_IRQSTATUS);
 	dispc_write_reg(DISPC_IRQSTATUS, l);
 
-	/* Enable those that we handle always */
-	omap_dispc_enable_irqs(DISPC_IRQ_FRAMEMASK);
+	recalc_irq_mask();
 
 	if ((r = request_irq(INT_24XX_DSS_IRQ, omap_dispc_irq_handler,
 			   0, MODULE_NAME, fbdev)) < 0) {
diff --git a/drivers/video/omap/dispc.h b/drivers/video/omap/dispc.h
index ef720a7..c15ea77 100644
--- a/drivers/video/omap/dispc.h
+++ b/drivers/video/omap/dispc.h
@@ -37,9 +37,10 @@ extern void omap_dispc_set_lcd_size(int width, int height);
 extern void omap_dispc_enable_lcd_out(int enable);
 extern void omap_dispc_enable_digit_out(int enable);
 
-extern int  omap_dispc_request_irq(void (*callback)(void *data), void *data);
-extern void omap_dispc_free_irq(void);
+extern int omap_dispc_request_irq(unsigned long irq_mask,
+				   void (*callback)(void *data), void *data);
+extern void omap_dispc_free_irq(unsigned long irq_mask,
+				 void (*callback)(void *data), void *data);
 
 extern const struct lcd_ctrl omap2_int_ctrl;
-
 #endif
diff --git a/drivers/video/omap/rfbi.c b/drivers/video/omap/rfbi.c
index 9332d6c..ee01e84 100644
--- a/drivers/video/omap/rfbi.c
+++ b/drivers/video/omap/rfbi.c
@@ -57,6 +57,7 @@
 
 #define DISPC_BASE		0x48050400
 #define DISPC_CONTROL		0x0040
+#define DISPC_IRQ_FRAMEMASK     0x0001
 
 static struct {
 	void __iomem	*base;
@@ -553,7 +554,9 @@ static int rfbi_init(struct omapfb_device *fbdev)
 	l = (0x01 << 2);
 	rfbi_write_reg(RFBI_CONTROL, l);
 
-	if ((r = omap_dispc_request_irq(rfbi_dma_callback, NULL)) < 0) {
+	r = omap_dispc_request_irq(DISPC_IRQ_FRAMEMASK, rfbi_dma_callback,
+				   NULL);
+	if (r < 0) {
 		dev_err(fbdev->dev, "can't get DISPC irq\n");
 		rfbi_enable_clocks(0);
 		return r;
@@ -570,7 +573,7 @@ static int rfbi_init(struct omapfb_device *fbdev)
 
 static void rfbi_cleanup(void)
 {
-	omap_dispc_free_irq();
+	omap_dispc_free_irq(DISPC_IRQ_FRAMEMASK, rfbi_dma_callback, NULL);
 	rfbi_put_clocks();
 	iounmap(rfbi.base);
 }
-- 
1.6.3.1


  reply	other threads:[~2009-06-04 17:52 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-04 17:52 [PATCH 00/20] omapfb: Add support for new LCDs / misc fixes Imre Deak
2009-06-04 17:52 ` [PATCH 01/20] omapfb: Add support for the Apollon LCD Imre Deak
2009-06-04 17:52   ` [PATCH 02/20] omapfb: Add support for MIPI-DCS compatible LCDs Imre Deak
2009-06-04 17:52     ` [PATCH 03/20] N770: Enable LCD MIPI-DCS in Kconfig Imre Deak
2009-06-04 17:52       ` [PATCH 04/20] omapfb: Add support for the Amstrad Delta LCD Imre Deak
2009-06-04 17:52         ` [PATCH 05/20] omapfb: Add support for the 2430SDP LCD Imre Deak
2009-06-04 17:52           ` [PATCH 06/20] omapfb: Add support for the OMAP2EVM LCD Imre Deak
2009-06-04 17:52             ` [PATCH 07/20] omapfb: Add support for the 3430SDP LCD Imre Deak
2009-06-04 17:52               ` [PATCH 08/20] omapfb: Add support for the OMAP3 EVM LCD Imre Deak
2009-06-04 17:52                 ` [PATCH 09/20] omapfb: Add support for the OMAP3 Beagle DVI output Imre Deak
2009-06-04 17:52                   ` [PATCH 10/20] omapfb: Add support for the Gumstix Overo LCD Imre Deak
2009-06-04 17:52                     ` [PATCH 11/20] omapfb: Add support for the ZOOM MDK LCD Imre Deak
2009-06-04 17:52                       ` [PATCH 12/20] omapfb: Add support for rotation on the Blizzard LCD ctrl Imre Deak
2009-06-04 17:52                         ` [PATCH 13/20] omapfb: dispc: Various typo fixes Imre Deak
2009-06-04 17:52                           ` [PATCH 14/20] omapfb: dispc: Disable iface clocks along with func clocks Imre Deak
2009-06-04 17:52                             ` [PATCH 15/20] omapfb: dispc: Enable wake up capability Imre Deak
2009-06-04 17:52                               ` Imre Deak [this message]
2009-06-04 17:52                                 ` [PATCH 17/20] omapfb: suspend/resume only if FB device is already initialized Imre Deak
2009-06-04 17:52                                   ` [PATCH 18/20] omapfb: Fix coding style / remove dead line Imre Deak
2009-06-04 17:52                                     ` [PATCH 19/20] omapfb: Add FB manual update option to Kconfig Imre Deak
2009-06-04 17:52                                       ` [PATCH 20/20] omapfb: HWA742: fix pointer to be const Imre Deak
2009-06-14 21:45                                         ` Krzysztof Helt
2009-06-14 21:44                                       ` [Linux-fbdev-devel] [PATCH 19/20] omapfb: Add FB manual update option to Kconfig Krzysztof Helt
2009-06-14 21:43                                     ` [Linux-fbdev-devel] [PATCH 18/20] omapfb: Fix coding style / remove dead line Krzysztof Helt
2009-06-14 21:42                                   ` [Linux-fbdev-devel] [PATCH 17/20] omapfb: suspend/resume only if FB device is already initialized Krzysztof Helt
2009-06-14 21:41                                 ` [Linux-fbdev-devel] [PATCH 16/20] omapfb: dispc: Allow multiple external IRQ handlers Krzysztof Helt
2009-06-14 21:40                               ` [Linux-fbdev-devel] [PATCH 15/20] omapfb: dispc: Enable wake up capability Krzysztof Helt
2009-06-14 21:39                             ` [Linux-fbdev-devel] [PATCH 14/20] omapfb: dispc: Disable iface clocks along with func clocks Krzysztof Helt
2009-06-14 21:38                           ` [Linux-fbdev-devel] [PATCH 13/20] omapfb: dispc: Various typo fixes Krzysztof Helt
2009-06-14 21:38                         ` [Linux-fbdev-devel] [PATCH 12/20] omapfb: Add support for rotation on the Blizzard LCD ctrl Krzysztof Helt
2009-06-14 21:37                       ` [Linux-fbdev-devel] [PATCH 11/20] omapfb: Add support for the ZOOM MDK LCD Krzysztof Helt
2009-06-14 21:47                       ` Krzysztof Helt
2009-06-16 11:10                         ` Imre Deak
2009-06-14 21:35                     ` [Linux-fbdev-devel] [PATCH 10/20] omapfb: Add support for the Gumstix Overo LCD Krzysztof Helt
2009-06-14 21:34                   ` [Linux-fbdev-devel] [PATCH 09/20] omapfb: Add support for the OMAP3 Beagle DVI output Krzysztof Helt
2009-06-14 21:33                 ` [Linux-fbdev-devel] [PATCH 08/20] omapfb: Add support for the OMAP3 EVM LCD Krzysztof Helt
2009-06-16 10:54                   ` Imre Deak
2009-06-14 21:31               ` [Linux-fbdev-devel] [PATCH 07/20] omapfb: Add support for the 3430SDP LCD Krzysztof Helt
2009-06-14 21:30             ` [Linux-fbdev-devel] [PATCH 06/20] omapfb: Add support for the OMAP2EVM LCD Krzysztof Helt
2009-06-16 10:51               ` Imre Deak
2009-06-14 21:29           ` [Linux-fbdev-devel] [PATCH 05/20] omapfb: Add support for the 2430SDP LCD Krzysztof Helt
2009-06-16 10:47             ` Imre Deak
2009-06-05 10:38         ` [PATCH 04/20] omapfb: Add support for the Amstrad Delta LCD Janusz Krzysztofik
2009-06-05 10:38           ` Janusz Krzysztofik
2009-06-05 11:39           ` Janusz Krzysztofik
2009-06-05 15:39           ` Jonathan McDowell
2009-06-05 15:39             ` Jonathan McDowell
2009-06-14 21:27         ` [Linux-fbdev-devel] " Krzysztof Helt
2009-06-07 22:43     ` [PATCH 02/20] omapfb: Add support for MIPI-DCS compatible LCDs Krzysztof Helt
2009-06-09 11:15       ` [Linux-fbdev-devel] " Imre Deak
2009-06-10 14:48         ` [PATCH] " Imre Deak
2009-06-14 21:48         ` [Linux-fbdev-devel] [PATCH 02/20] " Krzysztof Helt
2009-06-07 22:41   ` [Linux-fbdev-devel] [PATCH 01/20] omapfb: Add support for the Apollon LCD Krzysztof Helt
2009-06-11 12:02   ` [PULL REQUEST] omapfb: Add support for new LCDs / misc fixes Imre Deak
2009-06-16 16:58     ` Krzysztof Helt
2009-06-17 10:25       ` Imre Deak
2009-06-22 19:17         ` Imre Deak
2009-06-23 21:02           ` Krzysztof Helt
2009-06-04 21:00 ` [Linux-fbdev-devel] [PATCH 00/20] " Krzysztof Helt
2009-06-24 11:33 Imre Deak
2009-06-24 11:33 ` [PATCH 01/20] omapfb: Add support for the Apollon LCD Imre Deak
2009-06-24 11:33   ` [PATCH 02/20] omapfb: Add support for MIPI-DCS compatible LCDs Imre Deak
2009-06-24 11:33     ` [PATCH 03/20] omapfb: Add support for the Amstrad Delta LCD Imre Deak
2009-06-24 11:33       ` [PATCH 04/20] omapfb: Add support for the 2430SDP LCD Imre Deak
2009-06-24 11:33         ` [PATCH 05/20] omapfb: Add support for the OMAP2EVM LCD Imre Deak
2009-06-24 11:33           ` [PATCH 06/20] omapfb: Add support for the 3430SDP LCD Imre Deak
2009-06-24 11:33             ` [PATCH 07/20] omapfb: Add support for the OMAP3 EVM LCD Imre Deak
2009-06-24 11:33               ` [PATCH 08/20] omapfb: Add support for the OMAP3 Beagle DVI output Imre Deak
2009-06-24 11:33                 ` [PATCH 09/20] omapfb: Add support for the Gumstix Overo LCD Imre Deak
2009-06-24 11:33                   ` [PATCH 10/20] omapfb: Add support for the ZOOM MDK LCD Imre Deak
2009-06-24 11:33                     ` [PATCH 11/20] omapfb: Add support for rotation on the Blizzard LCD ctrl Imre Deak
2009-06-24 11:33                       ` [PATCH 12/20] N770: Enable LCD MIPI-DCS in Kconfig Imre Deak
2009-06-24 11:33                         ` [PATCH 13/20] omapfb: dispc: Various typo fixes Imre Deak
2009-06-24 11:33                           ` [PATCH 14/20] omapfb: dispc: Disable iface clocks along with func clocks Imre Deak
2009-06-24 11:33                             ` [PATCH 15/20] omapfb: dispc: Enable wake up capability Imre Deak
2009-06-24 11:33                               ` [PATCH 16/20] omapfb: dispc: Allow multiple external IRQ handlers Imre Deak
2009-06-24 12:16                                 ` Felipe Balbi
2009-06-24 13:35                                   ` Imre Deak

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=024fee28b6c89decf0d50747127db8fc61ac789e.1244131952.git.imre.deak@nokia.com \
    --to=imre.deak@nokia.com \
    --cc=Tomi.Valkeinen@nokia.com \
    --cc=adaplas@gmail.com \
    --cc=daniel.stone@nokia.com \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.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.