From patchwork Tue Jan 8 04:53:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 1943831 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 98EB53FF0F for ; Tue, 8 Jan 2013 05:29:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 05FBFE6006 for ; Mon, 7 Jan 2013 21:29:51 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by gabe.freedesktop.org (Postfix) with ESMTP id ADCCBE5F40 for ; Mon, 7 Jan 2013 20:53:52 -0800 (PST) Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r084rpB1025132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Jan 2013 23:53:51 -0500 Received: from prime.bne.redhat.com (dhcp-40-183.bne.redhat.com [10.64.40.183]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r084roxX032670 for ; Mon, 7 Jan 2013 23:53:50 -0500 From: Dave Airlie To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] vga_switcheroo: add mux switched interface Date: Tue, 8 Jan 2013 14:53:48 +1000 Message-Id: <1357620829-24526-1-git-send-email-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Dave Airlie this tells the drivers when the mux is switch to/from it, can be used to report outputs as disconnected to userspace etc. Signed-off-by: Dave Airlie Reviewed-by: Alex Deucher --- drivers/gpu/vga/vga_switcheroo.c | 19 +++++++++++++++++++ include/linux/vga_switcheroo.h | 1 + 2 files changed, 20 insertions(+) diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index fa60add..2362175 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -93,6 +93,9 @@ static void vga_switcheroo_enable(void) return; client->id = ret; + + if (client->ops->mux_switched) + client->ops->mux_switched(client->pdev, client->active ? VGA_SWITCHEROO_ON : VGA_SWITCHEROO_OFF); } vga_switcheroo_debugfs_init(&vgasr_priv); vgasr_priv.active = true; @@ -345,6 +348,13 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) if (ret) return ret; + /* call mux switched callbacks */ + if (active->ops->mux_switched) + active->ops->mux_switched(active->pdev, VGA_SWITCHEROO_OFF); + + if (new_client->ops->mux_switched) + new_client->ops->mux_switched(new_client->pdev, VGA_SWITCHEROO_ON); + if (new_client->ops->reprobe) new_client->ops->reprobe(new_client->pdev); @@ -452,7 +462,16 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, vgasr_priv.delayed_switch_active = false; if (just_mux) { + struct vga_switcheroo_client *active; + active = find_active_client(&vgasr_priv.clients); + if (!active) + return 0; ret = vgasr_priv.handler->switchto(client_id); + + if (active->ops->mux_switched) + active->ops->mux_switched(active->pdev, VGA_SWITCHEROO_OFF); + if (client->ops->mux_switched) + client->ops->mux_switched(client->pdev, VGA_SWITCHEROO_ON); goto out; } diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h index ddb419c..6275719 100644 --- a/include/linux/vga_switcheroo.h +++ b/include/linux/vga_switcheroo.h @@ -40,6 +40,7 @@ struct vga_switcheroo_client_ops { void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state); void (*reprobe)(struct pci_dev *dev); bool (*can_switch)(struct pci_dev *dev); + void (*mux_switched)(struct pci_dev *dev, enum vga_switcheroo_state); }; #if defined(CONFIG_VGA_SWITCHEROO)