Browse Source

fbdev: sh_mobile_lcdc: Create functions to turn the display on/off

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Laurent Pinchart 13 years ago
parent
commit
37c5dcc21d
1 changed files with 28 additions and 25 deletions
  1. 28 25
      drivers/video/sh_mobile_lcdcfb.c

+ 28 - 25
drivers/video/sh_mobile_lcdcfb.c

@@ -224,7 +224,7 @@ static int sh_mobile_lcdc_setup_clocks(struct sh_mobile_lcdc_priv *priv,
 }
 }
 
 
 /* -----------------------------------------------------------------------------
 /* -----------------------------------------------------------------------------
- * Sys panel and deferred I/O
+ * Display, panel and deferred I/O
  */
  */
 
 
 static void lcdc_sys_write_index(void *handle, unsigned long data)
 static void lcdc_sys_write_index(void *handle, unsigned long data)
@@ -335,6 +335,27 @@ static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
 		schedule_delayed_work(&info->deferred_work, fbdefio->delay);
 		schedule_delayed_work(&info->deferred_work, fbdefio->delay);
 }
 }
 
 
+static void sh_mobile_lcdc_display_on(struct sh_mobile_lcdc_chan *ch)
+{
+	struct sh_mobile_lcdc_board_cfg	*board_cfg = &ch->cfg.board_cfg;
+
+	/* HDMI must be enabled before LCDC configuration */
+	if (board_cfg->display_on && try_module_get(board_cfg->owner)) {
+		board_cfg->display_on(board_cfg->board_data, ch->info);
+		module_put(board_cfg->owner);
+	}
+}
+
+static void sh_mobile_lcdc_display_off(struct sh_mobile_lcdc_chan *ch)
+{
+	struct sh_mobile_lcdc_board_cfg	*board_cfg = &ch->cfg.board_cfg;
+
+	if (board_cfg->display_off && try_module_get(board_cfg->owner)) {
+		board_cfg->display_off(board_cfg->board_data);
+		module_put(board_cfg->owner);
+	}
+}
+
 /* -----------------------------------------------------------------------------
 /* -----------------------------------------------------------------------------
  * Format helpers
  * Format helpers
  */
  */
@@ -648,7 +669,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 {
 {
 	struct sh_mobile_meram_info *mdev = priv->meram_dev;
 	struct sh_mobile_meram_info *mdev = priv->meram_dev;
-	struct sh_mobile_lcdc_board_cfg	*board_cfg;
 	struct sh_mobile_lcdc_chan *ch;
 	struct sh_mobile_lcdc_chan *ch;
 	unsigned long tmp;
 	unsigned long tmp;
 	int ret;
 	int ret;
@@ -665,8 +685,9 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 	lcdc_wait_bit(priv, _LDCNT2R, LDCNT2R_BR, 0);
 	lcdc_wait_bit(priv, _LDCNT2R, LDCNT2R_BR, 0);
 
 
 	for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
 	for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
-		ch = &priv->ch[k];
+		struct sh_mobile_lcdc_board_cfg	*board_cfg;
 
 
+		ch = &priv->ch[k];
 		if (!ch->enabled)
 		if (!ch->enabled)
 			continue;
 			continue;
 
 
@@ -754,11 +775,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 			fb_deferred_io_init(ch->info);
 			fb_deferred_io_init(ch->info);
 		}
 		}
 
 
-		board_cfg = &ch->cfg.board_cfg;
-		if (board_cfg->display_on && try_module_get(board_cfg->owner)) {
-			board_cfg->display_on(board_cfg->board_data, ch->info);
-			module_put(board_cfg->owner);
-		}
+		sh_mobile_lcdc_display_on(ch);
 
 
 		if (ch->bl) {
 		if (ch->bl) {
 			ch->bl->props.power = FB_BLANK_UNBLANK;
 			ch->bl->props.power = FB_BLANK_UNBLANK;
@@ -772,7 +789,6 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
 static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
 {
 {
 	struct sh_mobile_lcdc_chan *ch;
 	struct sh_mobile_lcdc_chan *ch;
-	struct sh_mobile_lcdc_board_cfg	*board_cfg;
 	int k;
 	int k;
 
 
 	/* clean up deferred io and ask board code to disable panel */
 	/* clean up deferred io and ask board code to disable panel */
@@ -799,11 +815,7 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
 			backlight_update_status(ch->bl);
 			backlight_update_status(ch->bl);
 		}
 		}
 
 
-		board_cfg = &ch->cfg.board_cfg;
-		if (board_cfg->display_off && try_module_get(board_cfg->owner)) {
-			board_cfg->display_off(board_cfg->board_data);
-			module_put(board_cfg->owner);
-		}
+		sh_mobile_lcdc_display_off(ch);
 
 
 		/* disable the meram */
 		/* disable the meram */
 		if (ch->meram_enabled) {
 		if (ch->meram_enabled) {
@@ -1417,7 +1429,6 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb,
 	struct fb_event *event = data;
 	struct fb_event *event = data;
 	struct fb_info *info = event->info;
 	struct fb_info *info = event->info;
 	struct sh_mobile_lcdc_chan *ch = info->par;
 	struct sh_mobile_lcdc_chan *ch = info->par;
-	struct sh_mobile_lcdc_board_cfg	*board_cfg = &ch->cfg.board_cfg;
 
 
 	if (&ch->lcdc->notifier != nb)
 	if (&ch->lcdc->notifier != nb)
 		return NOTIFY_DONE;
 		return NOTIFY_DONE;
@@ -1427,10 +1438,7 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb,
 
 
 	switch(action) {
 	switch(action) {
 	case FB_EVENT_SUSPEND:
 	case FB_EVENT_SUSPEND:
-		if (board_cfg->display_off && try_module_get(board_cfg->owner)) {
-			board_cfg->display_off(board_cfg->board_data);
-			module_put(board_cfg->owner);
-		}
+		sh_mobile_lcdc_display_off(ch);
 		sh_mobile_lcdc_stop(ch->lcdc);
 		sh_mobile_lcdc_stop(ch->lcdc);
 		break;
 		break;
 	case FB_EVENT_RESUME:
 	case FB_EVENT_RESUME:
@@ -1438,12 +1446,7 @@ static int sh_mobile_lcdc_notify(struct notifier_block *nb,
 		sh_mobile_fb_reconfig(info);
 		sh_mobile_fb_reconfig(info);
 		mutex_unlock(&ch->open_lock);
 		mutex_unlock(&ch->open_lock);
 
 
-		/* HDMI must be enabled before LCDC configuration */
-		if (board_cfg->display_on && try_module_get(board_cfg->owner)) {
-			board_cfg->display_on(board_cfg->board_data, info);
-			module_put(board_cfg->owner);
-		}
-
+		sh_mobile_lcdc_display_on(ch);
 		sh_mobile_lcdc_start(ch->lcdc);
 		sh_mobile_lcdc_start(ch->lcdc);
 	}
 	}