From patchwork Sun Jul 8 21:56:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 1170381 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 A6AFE40134 for ; Sun, 8 Jul 2012 22:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752475Ab2GHV55 (ORCPT ); Sun, 8 Jul 2012 17:57:57 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:42390 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752486Ab2GHV5F (ORCPT ); Sun, 8 Jul 2012 17:57:05 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so708039wey.19 for ; Sun, 08 Jul 2012 14:57:05 -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=+ezl5GPf+UR8EfjpGbcq68GzSI1FGeQN64EwDFO5yIs=; b=u6qX7J6CgtHAudY0tbsZQ2KfiW6a+1FXYDxN9+e/QRMJTXnZnxe+l3RuxQSLKX/Fa2 NU9HhJNlhaSysYU6Ul1cZgSXBbRHkyEfKz8eEUaozr4rgvSTgMJ821IFIGt8frGsAHE3 c0Orm/DZnXKtiTyA35zIqiDdCIhLPd+iMhk5H3C7x80H+A6K08crueGe7RXUi8G3z/te 11qzfbSknpj1wP4KPYAmxE6yd47ib4CdsVOT01uiLiF10UHkaBP/qtshdn/2G8SKkWRM t05eiy+oR70LagnKYwrJh0wiHotQP2YYByIwgDuDLZsL7W1WLFUmYFr+gyJ7c+j0x5od p/cA== Received: by 10.216.173.136 with SMTP id v8mr12797290wel.167.1341784624936; Sun, 08 Jul 2012 14:57:04 -0700 (PDT) Received: from localhost.localdomain (stgt-5f719b43.pool.mediaWays.net. [95.113.155.67]) by mx.google.com with ESMTPS id j6sm29743837wiy.4.2012.07.08.14.57.03 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 Jul 2012 14:57:04 -0700 (PDT) From: David Herrmann To: linux-serial@vger.kernel.org Cc: linux-kernel@vger.kernel.org, florianschandinat@gmx.de, linux-fbdev@vger.kernel.org, gregkh@linuxfoundation.org, alan@lxorguk.ukuu.org.uk, bonbons@linux-vserver.org, David Herrmann Subject: [PATCH v2 08/11] fblog: cache framebuffer BLANK and SUSPEND states Date: Sun, 8 Jul 2012 23:56:51 +0200 Message-Id: <1341784614-2797-9-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <1341784614-2797-1-git-send-email-dh.herrmann@googlemail.com> References: <1341784614-2797-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 b490dba..fd1f3d6 100644 --- a/drivers/video/console/fblog.c +++ b/drivers/video/console/fblog.c @@ -31,6 +31,8 @@ enum fblog_flags { FBLOG_KILLED, FBLOG_OPEN, + FBLOG_SUSPENDED, + FBLOG_BLANKED, }; struct fblog_fb { @@ -255,6 +257,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: @@ -280,6 +283,44 @@ static int fblog_event(struct notifier_block *self, unsigned long action, if (fb) fblog_close(fb, true, 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;