From patchwork Sun Jul 15 19:04:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 1199311 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E020B3FC33 for ; Sun, 15 Jul 2012 19:06:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752767Ab2GOTGf (ORCPT ); Sun, 15 Jul 2012 15:06:35 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:64757 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751601Ab2GOTFb (ORCPT ); Sun, 15 Jul 2012 15:05:31 -0400 Received: by mail-wg0-f44.google.com with SMTP id dr13so324126wgb.1 for ; Sun, 15 Jul 2012 12:05:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=0FXDgqW8j/q3YKgBH+qGhmZKCr/ljPZ5kxNUJQKESIY=; b=LaCCRa6fYmZJouaOpf/tlMCVt2x2psZnZHCn5yxMbfpnSzmOsdAp7Ug2evsSeWXmjK 0GqqXgoA1QrYRNFmdFDZlaI0n+ptswyuWOxPKHwNvY7AXZ968Ejf9OW2mZszZ97Cbf0A xNEQkCcU8fOcRMLly7zSjsnNjs0VVfixqFsrtu/UrfZL30nPXgIvcLDFJGHrAhPulTI6 UEAk2F2m/R38/TwndMhqJb6evcZ56P95x2JGJ8OHFst/MbfOSYTbrAf5bO+yumDhaBHh oWfL+SSUq5H8TCjJRiuWmhNDalkVQ/3naOoSNzH+8Ar57r9RNXiTD1NdKRh4sHEfNJEb J2vA== Received: by 10.216.237.149 with SMTP id y21mr4685166weq.102.1342379130332; Sun, 15 Jul 2012 12:05:30 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71ba59.pool.mediaWays.net. [95.113.186.89]) by mx.google.com with ESMTPS id j6sm25479086wiy.4.2012.07.15.12.05.29 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 Jul 2012 12:05:29 -0700 (PDT) From: David Herrmann To: linux-kernel@vger.kernel.org Cc: Florian Tobias Schandinat , Andrew Morton , Greg Kroah-Hartman , linux-fbdev@vger.kernel.org, linux-serial@vger.kernel.org, Alan Cox , David Herrmann Subject: [PATCH v3 08/11] fblog: cache framebuffer BLANK and SUSPEND states Date: Sun, 15 Jul 2012 21:04:43 +0200 Message-Id: <1342379086-7583-9-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <1342379086-7583-1-git-send-email-dh.herrmann@googlemail.com> References: <1342379086-7583-1-git-send-email-dh.herrmann@googlemail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org We must cache these states so we will never draw to the framebuffer while it is suspended or blanked. Signed-off-by: David Herrmann --- drivers/video/console/fblog.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c index 5519f91..9b975bc 100644 --- a/drivers/video/console/fblog.c +++ b/drivers/video/console/fblog.c @@ -33,6 +33,8 @@ enum fblog_flags { FBLOG_KILLED, FBLOG_OPEN, + FBLOG_SUSPENDED, + FBLOG_BLANKED, }; struct fblog_fb { @@ -257,6 +259,7 @@ static int fblog_event(struct notifier_block *self, unsigned long action, struct fb_event *event = data; struct fb_info *info = event->info; struct fblog_fb *fb; + int *blank; switch(action) { case FB_EVENT_FB_REGISTERED: @@ -284,6 +287,44 @@ static int fblog_event(struct notifier_block *self, unsigned long action, if (fb) fblog_close(fb, true); break; + case FB_EVENT_SUSPEND: + /* This is called when the low-level display driver suspends the + * video system. We should not access the video system while it + * is suspended. This is called with the console lock held. */ + mutex_lock(&fblog_registration_lock); + fb = fblog_fbs[info->node]; + mutex_unlock(&fblog_registration_lock); + + if (fb) + set_bit(FBLOG_SUSPENDED, &fb->flags); + break; + case FB_EVENT_RESUME: + /* This is called when the low-level display driver resumes + * operating. It is called with the console lock held. */ + mutex_lock(&fblog_registration_lock); + fb = fblog_fbs[info->node]; + mutex_unlock(&fblog_registration_lock); + + if (fb) + clear_bit(FBLOG_SUSPENDED, &fb->flags); + break; + case FB_EVENT_BLANK: + /* This gets called _after_ the framebuffer was successfully + * blanked. The console-lock is always held while fb_blank is + * called and during this callback. */ + mutex_lock(&fblog_registration_lock); + fb = fblog_fbs[info->node]; + mutex_unlock(&fblog_registration_lock); + + if (!fb) + break; + + blank = (int*)event->data; + if (*blank == FB_BLANK_UNBLANK) + clear_bit(FBLOG_BLANKED, &fb->flags); + else + set_bit(FBLOG_BLANKED, &fb->flags); + break; } return 0;