RE: [PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-12 Thread Haiyang Zhang


> -Original Message-
> From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
> ow...@vger.kernel.org] On Behalf Of Haiyang Zhang
> Sent: Friday, March 08, 2013 4:46 PM
> To: florianschandi...@gmx.de; linux-fb...@vger.kernel.org
> Cc: Haiyang Zhang; KY Srinivasan; o...@aepfle.de; jasow...@redhat.com;
> linux-kernel@vger.kernel.org; de...@linuxdriverproject.org
> Subject: [PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer
> Driver
> 
> This is the driver for the Hyper-V Synthetic Video, which supports
> screen
> resolution up to Full HD 1920x1080 on Windows Server 2012 host, and
> 1600x1200
> on  Windows Server 2008 R2 or earlier.
> It also solves the double mouse cursor issue of the emulated video mode.
> 
> Signed-off-by: Haiyang Zhang 
> Reviewed-by: K. Y. Srinivasan 
> 

Hi, Florian and Andrew,

So far, I have responded to all comments from the community, and made the
recommended updates. Do you have any additional comments on this driver?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-12 Thread Haiyang Zhang


 -Original Message-
 From: linux-fbdev-ow...@vger.kernel.org [mailto:linux-fbdev-
 ow...@vger.kernel.org] On Behalf Of Haiyang Zhang
 Sent: Friday, March 08, 2013 4:46 PM
 To: florianschandi...@gmx.de; linux-fb...@vger.kernel.org
 Cc: Haiyang Zhang; KY Srinivasan; o...@aepfle.de; jasow...@redhat.com;
 linux-kernel@vger.kernel.org; de...@linuxdriverproject.org
 Subject: [PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer
 Driver
 
 This is the driver for the Hyper-V Synthetic Video, which supports
 screen
 resolution up to Full HD 1920x1080 on Windows Server 2012 host, and
 1600x1200
 on  Windows Server 2008 R2 or earlier.
 It also solves the double mouse cursor issue of the emulated video mode.
 
 Signed-off-by: Haiyang Zhang haiya...@microsoft.com
 Reviewed-by: K. Y. Srinivasan k...@microsoft.com
 

Hi, Florian and Andrew,

So far, I have responded to all comments from the community, and made the
recommended updates. Do you have any additional comments on this driver?

Thanks,
- Haiyang

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-08 Thread Haiyang Zhang
This is the driver for the Hyper-V Synthetic Video, which supports screen
resolution up to Full HD 1920x1080 on Windows Server 2012 host, and 1600x1200
on  Windows Server 2008 R2 or earlier.
It also solves the double mouse cursor issue of the emulated video mode.

Signed-off-by: Haiyang Zhang 
Reviewed-by: K. Y. Srinivasan 

---
v3:
According to the comment from Greg Kroah-Hartman ,
moved pci ids back to the hyperv_fb.c, because it is the only driver using
them.

v2:
Made changes based on reviews from Olaf Hering , Geert
Uytterhoeven .

Renamed the Kconfig string to FB_HYPERV. And, use KBUILD_MODNAME in two
additional places to keep consistency in naming.

Switched fb from system RAM to PCI mmio space, so the workaround for large
memory allocation is not necessary. The fb ops and screen refresh mechanism is
updated accordingly.

Added aperture setting so that VESA fb can be disabled automatically without
code change on the vesafb.c.
---
 drivers/video/Kconfig |9 +
 drivers/video/Makefile|1 +
 drivers/video/hyperv_fb.c |  829 +
 include/linux/hyperv.h|   11 +
 4 files changed, 850 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/hyperv_fb.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4c1546f..5d1a35e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2451,6 +2451,15 @@ config FB_PUV3_UNIGFX
  Choose this option if you want to use the Unigfx device as a
  framebuffer device. Without the support of PCI & AGP.
 
+config FB_HYPERV
+   tristate "Microsoft Hyper-V Synthetic Video support"
+   depends on FB && HYPERV
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   help
+ This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
+
 source "drivers/video/omap/Kconfig"
 source "drivers/video/omap2/Kconfig"
 source "drivers/video/exynos/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9df3873..97f7b6d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -149,6 +149,7 @@ obj-$(CONFIG_FB_MSM)  += msm/
 obj-$(CONFIG_FB_NUC900)   += nuc900fb.o
 obj-$(CONFIG_FB_JZ4740)  += jz4740_fb.o
 obj-$(CONFIG_FB_PUV3_UNIGFX)  += fb-puv3.o
+obj-$(CONFIG_FB_HYPERV)  += hyperv_fb.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_UVESA)+= uvesafb.o
diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
new file mode 100644
index 000..ceb33b0
--- /dev/null
+++ b/drivers/video/hyperv_fb.c
@@ -0,0 +1,829 @@
+/*
+ * Copyright (c) 2012, Microsoft Corporation.
+ *
+ * Author:
+ *   Haiyang Zhang 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * Hyper-V Synthetic Video Frame Buffer Driver
+ *
+ * This is the driver for the Hyper-V Synthetic Video, which supports
+ * screen resolution up to Full HD 1920x1080 with 32 bit color on Windows
+ * Server 2012, and 1600x1200 with 16 bit color on Windows Server 2008 R2
+ * or earlier.
+ *
+ * It also solves the double mouse cursor issue of the emulated video mode.
+ *
+ * The default screen resolution is 1152x864, which may be changed by a
+ * kernel parameter:
+ * video=hyperv_fb:x
+ * For example: video=hyperv_fb:1280x1024
+ *
+ * Portrait orientation is also supported:
+ * For example: video=hyperv_fb:864x1152
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+
+/* Hyper-V Synthetic Video Protocol definitions and structures */
+#define MAX_VMBUS_PKT_SIZE 0x4000
+
+#define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
+#define SYNTHVID_VERSION_WIN7 SYNTHVID_VERSION(3, 0)
+#define SYNTHVID_VERSION_WIN8 SYNTHVID_VERSION(3, 2)
+
+#define SYNTHVID_DEPTH_WIN7 16
+#define SYNTHVID_DEPTH_WIN8 32
+
+#define SYNTHVID_FB_SIZE_WIN7 (4 * 1024 * 1024)
+#define SYNTHVID_WIDTH_MAX_WIN7 1600
+#define SYNTHVID_HEIGHT_MAX_WIN7 1200
+
+#define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
+
+#define PCI_VENDOR_ID_MICROSOFT 0x1414
+#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
+
+
+enum pipe_msg_type {
+   PIPE_MSG_INVALID,
+   PIPE_MSG_DATA,
+   PIPE_MSG_MAX
+};
+
+struct pipe_msg_hdr {
+   u32 type;
+   u32 size; /* size of message after this field */
+} __packed;
+
+
+enum synthvid_msg_type {
+   SYNTHVID_ERROR  = 0,
+   SYNTHVID_VERSION_REQUEST= 1,
+   SYNTHVID_VERSION_RESPONSE 

[PATCH v3] video: Add Hyper-V Synthetic Video Frame Buffer Driver

2013-03-08 Thread Haiyang Zhang
This is the driver for the Hyper-V Synthetic Video, which supports screen
resolution up to Full HD 1920x1080 on Windows Server 2012 host, and 1600x1200
on  Windows Server 2008 R2 or earlier.
It also solves the double mouse cursor issue of the emulated video mode.

Signed-off-by: Haiyang Zhang haiya...@microsoft.com
Reviewed-by: K. Y. Srinivasan k...@microsoft.com

---
v3:
According to the comment from Greg Kroah-Hartman gre...@linuxfoundation.org,
moved pci ids back to the hyperv_fb.c, because it is the only driver using
them.

v2:
Made changes based on reviews from Olaf Hering o...@aepfle.de, Geert
Uytterhoeven ge...@linux-m68k.org.

Renamed the Kconfig string to FB_HYPERV. And, use KBUILD_MODNAME in two
additional places to keep consistency in naming.

Switched fb from system RAM to PCI mmio space, so the workaround for large
memory allocation is not necessary. The fb ops and screen refresh mechanism is
updated accordingly.

Added aperture setting so that VESA fb can be disabled automatically without
code change on the vesafb.c.
---
 drivers/video/Kconfig |9 +
 drivers/video/Makefile|1 +
 drivers/video/hyperv_fb.c |  829 +
 include/linux/hyperv.h|   11 +
 4 files changed, 850 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/hyperv_fb.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 4c1546f..5d1a35e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2451,6 +2451,15 @@ config FB_PUV3_UNIGFX
  Choose this option if you want to use the Unigfx device as a
  framebuffer device. Without the support of PCI  AGP.
 
+config FB_HYPERV
+   tristate Microsoft Hyper-V Synthetic Video support
+   depends on FB  HYPERV
+   select FB_CFB_FILLRECT
+   select FB_CFB_COPYAREA
+   select FB_CFB_IMAGEBLIT
+   help
+ This framebuffer driver supports Microsoft Hyper-V Synthetic Video.
+
 source drivers/video/omap/Kconfig
 source drivers/video/omap2/Kconfig
 source drivers/video/exynos/Kconfig
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9df3873..97f7b6d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -149,6 +149,7 @@ obj-$(CONFIG_FB_MSM)  += msm/
 obj-$(CONFIG_FB_NUC900)   += nuc900fb.o
 obj-$(CONFIG_FB_JZ4740)  += jz4740_fb.o
 obj-$(CONFIG_FB_PUV3_UNIGFX)  += fb-puv3.o
+obj-$(CONFIG_FB_HYPERV)  += hyperv_fb.o
 
 # Platform or fallback drivers go here
 obj-$(CONFIG_FB_UVESA)+= uvesafb.o
diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
new file mode 100644
index 000..ceb33b0
--- /dev/null
+++ b/drivers/video/hyperv_fb.c
@@ -0,0 +1,829 @@
+/*
+ * Copyright (c) 2012, Microsoft Corporation.
+ *
+ * Author:
+ *   Haiyang Zhang haiya...@microsoft.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * Hyper-V Synthetic Video Frame Buffer Driver
+ *
+ * This is the driver for the Hyper-V Synthetic Video, which supports
+ * screen resolution up to Full HD 1920x1080 with 32 bit color on Windows
+ * Server 2012, and 1600x1200 with 16 bit color on Windows Server 2008 R2
+ * or earlier.
+ *
+ * It also solves the double mouse cursor issue of the emulated video mode.
+ *
+ * The default screen resolution is 1152x864, which may be changed by a
+ * kernel parameter:
+ * video=hyperv_fb:widthxheight
+ * For example: video=hyperv_fb:1280x1024
+ *
+ * Portrait orientation is also supported:
+ * For example: video=hyperv_fb:864x1152
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME :  fmt
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/init.h
+#include linux/completion.h
+#include linux/fb.h
+#include linux/pci.h
+
+#include linux/hyperv.h
+
+
+/* Hyper-V Synthetic Video Protocol definitions and structures */
+#define MAX_VMBUS_PKT_SIZE 0x4000
+
+#define SYNTHVID_VERSION(major, minor) ((minor)  16 | (major))
+#define SYNTHVID_VERSION_WIN7 SYNTHVID_VERSION(3, 0)
+#define SYNTHVID_VERSION_WIN8 SYNTHVID_VERSION(3, 2)
+
+#define SYNTHVID_DEPTH_WIN7 16
+#define SYNTHVID_DEPTH_WIN8 32
+
+#define SYNTHVID_FB_SIZE_WIN7 (4 * 1024 * 1024)
+#define SYNTHVID_WIDTH_MAX_WIN7 1600
+#define SYNTHVID_HEIGHT_MAX_WIN7 1200
+
+#define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
+
+#define PCI_VENDOR_ID_MICROSOFT 0x1414
+#define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
+
+
+enum pipe_msg_type {
+   PIPE_MSG_INVALID,
+   PIPE_MSG_DATA,
+   PIPE_MSG_MAX
+};
+
+struct pipe_msg_hdr {
+   u32 type;
+   u32