1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2012, Microsoft Corporation.
10 * Hyper-V Synthetic Video Frame Buffer Driver
12 * This is the driver for the Hyper-V Synthetic Video, which supports
13 * screen resolution up to Full HD 1920x1080 with 32 bit color on Windows
14 * Server 2012, and 1600x1200 with 16 bit color on Windows Server 2008 R2
17 * It also solves the double mouse cursor issue of the emulated video mode.
19 * The default screen resolution is 1152x864, which may be changed by a
21 * video=hyperv_fb:<width>x<height>
22 * For example: video=hyperv_fb:1280x1024
24 * Portrait orientation is also supported:
25 * For example: video=hyperv_fb:864x1152
28 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
30 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/init.h>
33 #include <linux/completion.h>
35 #include <linux/pci.h>
36 #include <linux/efi.h>
38 #include <linux/hyperv.h>
41 /* Hyper-V Synthetic Video Protocol definitions and structures */
42 #define MAX_VMBUS_PKT_SIZE 0x4000
44 #define SYNTHVID_VERSION(major, minor) ((minor) << 16 | (major))
45 #define SYNTHVID_VERSION_WIN7 SYNTHVID_VERSION(3, 0)
46 #define SYNTHVID_VERSION_WIN8 SYNTHVID_VERSION(3, 2)
48 #define SYNTHVID_DEPTH_WIN7 16
49 #define SYNTHVID_DEPTH_WIN8 32
51 #define SYNTHVID_FB_SIZE_WIN7 (4 * 1024 * 1024)
52 #define SYNTHVID_WIDTH_MAX_WIN7 1600
53 #define SYNTHVID_HEIGHT_MAX_WIN7 1200
55 #define SYNTHVID_FB_SIZE_WIN8 (8 * 1024 * 1024)
57 #define PCI_VENDOR_ID_MICROSOFT 0x1414
58 #define PCI_DEVICE_ID_HYPERV_VIDEO 0x5353
69 u32 size; /* size of message after this field */
73 enum synthvid_msg_type {
75 SYNTHVID_VERSION_REQUEST = 1,
76 SYNTHVID_VERSION_RESPONSE = 2,
77 SYNTHVID_VRAM_LOCATION = 3,
78 SYNTHVID_VRAM_LOCATION_ACK = 4,
79 SYNTHVID_SITUATION_UPDATE = 5,
80 SYNTHVID_SITUATION_UPDATE_ACK = 6,
81 SYNTHVID_POINTER_POSITION = 7,
82 SYNTHVID_POINTER_SHAPE = 8,
83 SYNTHVID_FEATURE_CHANGE = 9,
89 struct synthvid_msg_hdr {
91 u32 size; /* size of this header + payload after this field*/
95 struct synthvid_version_req {
99 struct synthvid_version_resp {
102 u8 max_video_outputs;
105 struct synthvid_vram_location {
107 u8 is_vram_gpa_specified;
111 struct synthvid_vram_location_ack {
115 struct video_output_situation {
124 struct synthvid_situation_update {
126 u8 video_output_count;
127 struct video_output_situation video_output[1];
130 struct synthvid_situation_update_ack {
134 struct synthvid_pointer_position {
142 #define CURSOR_MAX_X 96
143 #define CURSOR_MAX_Y 96
144 #define CURSOR_ARGB_PIXEL_SIZE 4
145 #define CURSOR_MAX_SIZE (CURSOR_MAX_X * CURSOR_MAX_Y * CURSOR_ARGB_PIXEL_SIZE)
146 #define CURSOR_COMPLETE (-1)
148 struct synthvid_pointer_shape {
151 u32 width; /* CURSOR_MAX_X at most */
152 u32 height; /* CURSOR_MAX_Y at most */
153 u32 hot_x; /* hotspot relative to upper-left of pointer image */
158 struct synthvid_feature_change {
160 u8 is_ptr_pos_needed;
161 u8 is_ptr_shape_needed;
166 s32 x1, y1; /* top left corner */
167 s32 x2, y2; /* bottom right corner, exclusive */
170 struct synthvid_dirt {
176 struct synthvid_msg {
177 struct pipe_msg_hdr pipe_hdr;
178 struct synthvid_msg_hdr vid_hdr;
180 struct synthvid_version_req ver_req;
181 struct synthvid_version_resp ver_resp;
182 struct synthvid_vram_location vram;
183 struct synthvid_vram_location_ack vram_ack;
184 struct synthvid_situation_update situ;
185 struct synthvid_situation_update_ack situ_ack;
186 struct synthvid_pointer_position ptr_pos;
187 struct synthvid_pointer_shape ptr_shape;
188 struct synthvid_feature_change feature_chg;
189 struct synthvid_dirt dirt;
195 /* FB driver definitions and structures */
196 #define HVFB_WIDTH 1152 /* default screen width */
197 #define HVFB_HEIGHT 864 /* default screen height */
198 #define HVFB_WIDTH_MIN 640
199 #define HVFB_HEIGHT_MIN 480
201 #define RING_BUFSIZE (256 * 1024)
202 #define VSP_TIMEOUT (10 * HZ)
203 #define HVFB_UPDATE_DELAY (HZ / 20)
206 struct fb_info *info;
207 struct resource *mem;
208 bool fb_ready; /* fb device is ready */
209 struct completion wait;
210 u32 synthvid_version;
212 struct delayed_work dwork;
215 u32 pseudo_palette[16];
216 u8 init_buf[MAX_VMBUS_PKT_SIZE];
217 u8 recv_buf[MAX_VMBUS_PKT_SIZE];
219 /* If true, the VSC notifies the VSP on every framebuffer change */
222 struct notifier_block hvfb_panic_nb;
225 static uint screen_width = HVFB_WIDTH;
226 static uint screen_height = HVFB_HEIGHT;
227 static uint screen_depth;
228 static uint screen_fb_size;
230 /* Send message to Hyper-V host */
231 static inline int synthvid_send(struct hv_device *hdev,
232 struct synthvid_msg *msg)
234 static atomic64_t request_id = ATOMIC64_INIT(0);
237 msg->pipe_hdr.type = PIPE_MSG_DATA;
238 msg->pipe_hdr.size = msg->vid_hdr.size;
240 ret = vmbus_sendpacket(hdev->channel, msg,
241 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
242 atomic64_inc_return(&request_id),
243 VM_PKT_DATA_INBAND, 0);
246 pr_err("Unable to send packet via vmbus\n");
252 /* Send screen resolution info to host */
253 static int synthvid_send_situ(struct hv_device *hdev)
255 struct fb_info *info = hv_get_drvdata(hdev);
256 struct synthvid_msg msg;
261 memset(&msg, 0, sizeof(struct synthvid_msg));
263 msg.vid_hdr.type = SYNTHVID_SITUATION_UPDATE;
264 msg.vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
265 sizeof(struct synthvid_situation_update);
266 msg.situ.user_ctx = 0;
267 msg.situ.video_output_count = 1;
268 msg.situ.video_output[0].active = 1;
269 msg.situ.video_output[0].vram_offset = 0;
270 msg.situ.video_output[0].depth_bits = info->var.bits_per_pixel;
271 msg.situ.video_output[0].width_pixels = info->var.xres;
272 msg.situ.video_output[0].height_pixels = info->var.yres;
273 msg.situ.video_output[0].pitch_bytes = info->fix.line_length;
275 synthvid_send(hdev, &msg);
280 /* Send mouse pointer info to host */
281 static int synthvid_send_ptr(struct hv_device *hdev)
283 struct synthvid_msg msg;
285 memset(&msg, 0, sizeof(struct synthvid_msg));
286 msg.vid_hdr.type = SYNTHVID_POINTER_POSITION;
287 msg.vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
288 sizeof(struct synthvid_pointer_position);
289 msg.ptr_pos.is_visible = 1;
290 msg.ptr_pos.video_output = 0;
291 msg.ptr_pos.image_x = 0;
292 msg.ptr_pos.image_y = 0;
293 synthvid_send(hdev, &msg);
295 memset(&msg, 0, sizeof(struct synthvid_msg));
296 msg.vid_hdr.type = SYNTHVID_POINTER_SHAPE;
297 msg.vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
298 sizeof(struct synthvid_pointer_shape);
299 msg.ptr_shape.part_idx = CURSOR_COMPLETE;
300 msg.ptr_shape.is_argb = 1;
301 msg.ptr_shape.width = 1;
302 msg.ptr_shape.height = 1;
303 msg.ptr_shape.hot_x = 0;
304 msg.ptr_shape.hot_y = 0;
305 msg.ptr_shape.data[0] = 0;
306 msg.ptr_shape.data[1] = 1;
307 msg.ptr_shape.data[2] = 1;
308 msg.ptr_shape.data[3] = 1;
309 synthvid_send(hdev, &msg);
314 /* Send updated screen area (dirty rectangle) location to host */
315 static int synthvid_update(struct fb_info *info)
317 struct hv_device *hdev = device_to_hv_device(info->device);
318 struct synthvid_msg msg;
320 memset(&msg, 0, sizeof(struct synthvid_msg));
322 msg.vid_hdr.type = SYNTHVID_DIRT;
323 msg.vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
324 sizeof(struct synthvid_dirt);
325 msg.dirt.video_output = 0;
326 msg.dirt.dirt_count = 1;
327 msg.dirt.rect[0].x1 = 0;
328 msg.dirt.rect[0].y1 = 0;
329 msg.dirt.rect[0].x2 = info->var.xres;
330 msg.dirt.rect[0].y2 = info->var.yres;
332 synthvid_send(hdev, &msg);
339 * Actions on received messages from host:
340 * Complete the wait event.
341 * Or, reply with screen and cursor info.
343 static void synthvid_recv_sub(struct hv_device *hdev)
345 struct fb_info *info = hv_get_drvdata(hdev);
346 struct hvfb_par *par;
347 struct synthvid_msg *msg;
353 msg = (struct synthvid_msg *)par->recv_buf;
355 /* Complete the wait event */
356 if (msg->vid_hdr.type == SYNTHVID_VERSION_RESPONSE ||
357 msg->vid_hdr.type == SYNTHVID_VRAM_LOCATION_ACK) {
358 memcpy(par->init_buf, msg, MAX_VMBUS_PKT_SIZE);
359 complete(&par->wait);
363 /* Reply with screen and cursor info */
364 if (msg->vid_hdr.type == SYNTHVID_FEATURE_CHANGE) {
366 synthvid_send_ptr(hdev);
367 synthvid_send_situ(hdev);
370 par->update = msg->feature_chg.is_dirt_needed;
372 schedule_delayed_work(&par->dwork, HVFB_UPDATE_DELAY);
376 /* Receive callback for messages from the host */
377 static void synthvid_receive(void *ctx)
379 struct hv_device *hdev = ctx;
380 struct fb_info *info = hv_get_drvdata(hdev);
381 struct hvfb_par *par;
382 struct synthvid_msg *recv_buf;
391 recv_buf = (struct synthvid_msg *)par->recv_buf;
394 ret = vmbus_recvpacket(hdev->channel, recv_buf,
396 &bytes_recvd, &req_id);
397 if (bytes_recvd > 0 &&
398 recv_buf->pipe_hdr.type == PIPE_MSG_DATA)
399 synthvid_recv_sub(hdev);
400 } while (bytes_recvd > 0 && ret == 0);
403 /* Check synthetic video protocol version with the host */
404 static int synthvid_negotiate_ver(struct hv_device *hdev, u32 ver)
406 struct fb_info *info = hv_get_drvdata(hdev);
407 struct hvfb_par *par = info->par;
408 struct synthvid_msg *msg = (struct synthvid_msg *)par->init_buf;
412 memset(msg, 0, sizeof(struct synthvid_msg));
413 msg->vid_hdr.type = SYNTHVID_VERSION_REQUEST;
414 msg->vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
415 sizeof(struct synthvid_version_req);
416 msg->ver_req.version = ver;
417 synthvid_send(hdev, msg);
419 t = wait_for_completion_timeout(&par->wait, VSP_TIMEOUT);
421 pr_err("Time out on waiting version response\n");
425 if (!msg->ver_resp.is_accepted) {
430 par->synthvid_version = ver;
436 /* Connect to VSP (Virtual Service Provider) on host */
437 static int synthvid_connect_vsp(struct hv_device *hdev)
439 struct fb_info *info = hv_get_drvdata(hdev);
440 struct hvfb_par *par = info->par;
443 ret = vmbus_open(hdev->channel, RING_BUFSIZE, RING_BUFSIZE,
444 NULL, 0, synthvid_receive, hdev);
446 pr_err("Unable to open vmbus channel\n");
450 /* Negotiate the protocol version with host */
451 if (vmbus_proto_version == VERSION_WS2008 ||
452 vmbus_proto_version == VERSION_WIN7)
453 ret = synthvid_negotiate_ver(hdev, SYNTHVID_VERSION_WIN7);
455 ret = synthvid_negotiate_ver(hdev, SYNTHVID_VERSION_WIN8);
458 pr_err("Synthetic video device version not accepted\n");
462 if (par->synthvid_version == SYNTHVID_VERSION_WIN7)
463 screen_depth = SYNTHVID_DEPTH_WIN7;
465 screen_depth = SYNTHVID_DEPTH_WIN8;
467 screen_fb_size = hdev->channel->offermsg.offer.
468 mmio_megabytes * 1024 * 1024;
473 vmbus_close(hdev->channel);
477 /* Send VRAM and Situation messages to the host */
478 static int synthvid_send_config(struct hv_device *hdev)
480 struct fb_info *info = hv_get_drvdata(hdev);
481 struct hvfb_par *par = info->par;
482 struct synthvid_msg *msg = (struct synthvid_msg *)par->init_buf;
486 /* Send VRAM location */
487 memset(msg, 0, sizeof(struct synthvid_msg));
488 msg->vid_hdr.type = SYNTHVID_VRAM_LOCATION;
489 msg->vid_hdr.size = sizeof(struct synthvid_msg_hdr) +
490 sizeof(struct synthvid_vram_location);
491 msg->vram.user_ctx = msg->vram.vram_gpa = info->fix.smem_start;
492 msg->vram.is_vram_gpa_specified = 1;
493 synthvid_send(hdev, msg);
495 t = wait_for_completion_timeout(&par->wait, VSP_TIMEOUT);
497 pr_err("Time out on waiting vram location ack\n");
501 if (msg->vram_ack.user_ctx != info->fix.smem_start) {
502 pr_err("Unable to set VRAM location\n");
507 /* Send pointer and situation update */
508 synthvid_send_ptr(hdev);
509 synthvid_send_situ(hdev);
517 * Delayed work callback:
518 * It is called at HVFB_UPDATE_DELAY or longer time interval to process
519 * screen updates. It is re-scheduled if further update is necessary.
521 static void hvfb_update_work(struct work_struct *w)
523 struct hvfb_par *par = container_of(w, struct hvfb_par, dwork.work);
524 struct fb_info *info = par->info;
527 synthvid_update(info);
530 schedule_delayed_work(&par->dwork, HVFB_UPDATE_DELAY);
533 static int hvfb_on_panic(struct notifier_block *nb,
534 unsigned long e, void *p)
536 struct hvfb_par *par;
537 struct fb_info *info;
539 par = container_of(nb, struct hvfb_par, hvfb_panic_nb);
540 par->synchronous_fb = true;
542 synthvid_update(info);
547 /* Framebuffer operation handlers */
549 static int hvfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
551 if (var->xres < HVFB_WIDTH_MIN || var->yres < HVFB_HEIGHT_MIN ||
552 var->xres > screen_width || var->yres > screen_height ||
553 var->bits_per_pixel != screen_depth)
556 var->xres_virtual = var->xres;
557 var->yres_virtual = var->yres;
562 static int hvfb_set_par(struct fb_info *info)
564 struct hv_device *hdev = device_to_hv_device(info->device);
566 return synthvid_send_situ(hdev);
570 static inline u32 chan_to_field(u32 chan, struct fb_bitfield *bf)
572 return ((chan & 0xffff) >> (16 - bf->length)) << bf->offset;
575 static int hvfb_setcolreg(unsigned regno, unsigned red, unsigned green,
576 unsigned blue, unsigned transp, struct fb_info *info)
578 u32 *pal = info->pseudo_palette;
583 pal[regno] = chan_to_field(red, &info->var.red)
584 | chan_to_field(green, &info->var.green)
585 | chan_to_field(blue, &info->var.blue)
586 | chan_to_field(transp, &info->var.transp);
591 static int hvfb_blank(int blank, struct fb_info *info)
593 return 1; /* get fb_blank to set the colormap to all black */
596 static void hvfb_cfb_fillrect(struct fb_info *p,
597 const struct fb_fillrect *rect)
599 struct hvfb_par *par = p->par;
601 cfb_fillrect(p, rect);
602 if (par->synchronous_fb)
606 static void hvfb_cfb_copyarea(struct fb_info *p,
607 const struct fb_copyarea *area)
609 struct hvfb_par *par = p->par;
611 cfb_copyarea(p, area);
612 if (par->synchronous_fb)
616 static void hvfb_cfb_imageblit(struct fb_info *p,
617 const struct fb_image *image)
619 struct hvfb_par *par = p->par;
621 cfb_imageblit(p, image);
622 if (par->synchronous_fb)
626 static struct fb_ops hvfb_ops = {
627 .owner = THIS_MODULE,
628 .fb_check_var = hvfb_check_var,
629 .fb_set_par = hvfb_set_par,
630 .fb_setcolreg = hvfb_setcolreg,
631 .fb_fillrect = hvfb_cfb_fillrect,
632 .fb_copyarea = hvfb_cfb_copyarea,
633 .fb_imageblit = hvfb_cfb_imageblit,
634 .fb_blank = hvfb_blank,
638 /* Get options from kernel paramenter "video=" */
639 static void hvfb_get_option(struct fb_info *info)
641 struct hvfb_par *par = info->par;
642 char *opt = NULL, *p;
645 if (fb_get_options(KBUILD_MODNAME, &opt) || !opt || !*opt)
648 p = strsep(&opt, "x");
649 if (!*p || kstrtouint(p, 0, &x) ||
650 !opt || !*opt || kstrtouint(opt, 0, &y)) {
651 pr_err("Screen option is invalid: skipped\n");
655 if (x < HVFB_WIDTH_MIN || y < HVFB_HEIGHT_MIN ||
656 (par->synthvid_version == SYNTHVID_VERSION_WIN8 &&
657 x * y * screen_depth / 8 > SYNTHVID_FB_SIZE_WIN8) ||
658 (par->synthvid_version == SYNTHVID_VERSION_WIN7 &&
659 (x > SYNTHVID_WIDTH_MAX_WIN7 || y > SYNTHVID_HEIGHT_MAX_WIN7))) {
660 pr_err("Screen resolution option is out of range: skipped\n");
670 /* Get framebuffer memory from Hyper-V video pci space */
671 static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
673 struct hvfb_par *par = info->par;
674 struct pci_dev *pdev = NULL;
675 void __iomem *fb_virt;
676 int gen2vm = efi_enabled(EFI_BOOT);
677 resource_size_t pot_start, pot_end;
684 pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
685 PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
687 pr_err("Unable to find PCI Hyper-V video\n");
691 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
692 pci_resource_len(pdev, 0) < screen_fb_size)
695 pot_end = pci_resource_end(pdev, 0);
696 pot_start = pot_end - screen_fb_size + 1;
699 ret = vmbus_allocate_mmio(&par->mem, hdev, pot_start, pot_end,
700 screen_fb_size, 0x100000, true);
702 pr_err("Unable to allocate framebuffer memory\n");
706 fb_virt = ioremap(par->mem->start, screen_fb_size);
710 info->apertures = alloc_apertures(1);
711 if (!info->apertures)
715 info->apertures->ranges[0].base = screen_info.lfb_base;
716 info->apertures->ranges[0].size = screen_info.lfb_size;
717 remove_conflicting_framebuffers(info->apertures,
718 KBUILD_MODNAME, false);
720 info->apertures->ranges[0].base = pci_resource_start(pdev, 0);
721 info->apertures->ranges[0].size = pci_resource_len(pdev, 0);
724 info->fix.smem_start = par->mem->start;
725 info->fix.smem_len = screen_fb_size;
726 info->screen_base = fb_virt;
727 info->screen_size = screen_fb_size;
737 vmbus_free_mmio(par->mem->start, screen_fb_size);
746 /* Release the framebuffer */
747 static void hvfb_putmem(struct fb_info *info)
749 struct hvfb_par *par = info->par;
751 iounmap(info->screen_base);
752 vmbus_free_mmio(par->mem->start, screen_fb_size);
757 static int hvfb_probe(struct hv_device *hdev,
758 const struct hv_vmbus_device_id *dev_id)
760 struct fb_info *info;
761 struct hvfb_par *par;
764 info = framebuffer_alloc(sizeof(struct hvfb_par), &hdev->device);
770 par->fb_ready = false;
771 init_completion(&par->wait);
772 INIT_DELAYED_WORK(&par->dwork, hvfb_update_work);
775 hv_set_drvdata(hdev, info);
776 ret = synthvid_connect_vsp(hdev);
778 pr_err("Unable to connect to VSP\n");
782 ret = hvfb_getmem(hdev, info);
784 pr_err("No memory for framebuffer\n");
788 hvfb_get_option(info);
789 pr_info("Screen resolution: %dx%d, Color depth: %d\n",
790 screen_width, screen_height, screen_depth);
794 info->flags = FBINFO_DEFAULT;
796 info->var.xres_virtual = info->var.xres = screen_width;
797 info->var.yres_virtual = info->var.yres = screen_height;
798 info->var.bits_per_pixel = screen_depth;
800 if (info->var.bits_per_pixel == 16) {
801 info->var.red = (struct fb_bitfield){11, 5, 0};
802 info->var.green = (struct fb_bitfield){5, 6, 0};
803 info->var.blue = (struct fb_bitfield){0, 5, 0};
804 info->var.transp = (struct fb_bitfield){0, 0, 0};
806 info->var.red = (struct fb_bitfield){16, 8, 0};
807 info->var.green = (struct fb_bitfield){8, 8, 0};
808 info->var.blue = (struct fb_bitfield){0, 8, 0};
809 info->var.transp = (struct fb_bitfield){24, 8, 0};
812 info->var.activate = FB_ACTIVATE_NOW;
813 info->var.height = -1;
814 info->var.width = -1;
815 info->var.vmode = FB_VMODE_NONINTERLACED;
817 strcpy(info->fix.id, KBUILD_MODNAME);
818 info->fix.type = FB_TYPE_PACKED_PIXELS;
819 info->fix.visual = FB_VISUAL_TRUECOLOR;
820 info->fix.line_length = screen_width * screen_depth / 8;
821 info->fix.accel = FB_ACCEL_NONE;
823 info->fbops = &hvfb_ops;
824 info->pseudo_palette = par->pseudo_palette;
826 /* Send config to host */
827 ret = synthvid_send_config(hdev);
831 ret = register_framebuffer(info);
833 pr_err("Unable to register framebuffer\n");
837 par->fb_ready = true;
839 par->synchronous_fb = false;
840 par->hvfb_panic_nb.notifier_call = hvfb_on_panic;
841 atomic_notifier_chain_register(&panic_notifier_list,
842 &par->hvfb_panic_nb);
849 vmbus_close(hdev->channel);
851 cancel_delayed_work_sync(&par->dwork);
852 hv_set_drvdata(hdev, NULL);
853 framebuffer_release(info);
858 static int hvfb_remove(struct hv_device *hdev)
860 struct fb_info *info = hv_get_drvdata(hdev);
861 struct hvfb_par *par = info->par;
863 atomic_notifier_chain_unregister(&panic_notifier_list,
864 &par->hvfb_panic_nb);
867 par->fb_ready = false;
869 unregister_framebuffer(info);
870 cancel_delayed_work_sync(&par->dwork);
872 vmbus_close(hdev->channel);
873 hv_set_drvdata(hdev, NULL);
876 framebuffer_release(info);
882 static const struct pci_device_id pci_stub_id_table[] = {
884 .vendor = PCI_VENDOR_ID_MICROSOFT,
885 .device = PCI_DEVICE_ID_HYPERV_VIDEO,
887 { /* end of list */ }
890 static const struct hv_vmbus_device_id id_table[] = {
891 /* Synthetic Video Device GUID */
896 MODULE_DEVICE_TABLE(pci, pci_stub_id_table);
897 MODULE_DEVICE_TABLE(vmbus, id_table);
899 static struct hv_driver hvfb_drv = {
900 .name = KBUILD_MODNAME,
901 .id_table = id_table,
903 .remove = hvfb_remove,
905 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
909 static int hvfb_pci_stub_probe(struct pci_dev *pdev,
910 const struct pci_device_id *ent)
915 static void hvfb_pci_stub_remove(struct pci_dev *pdev)
919 static struct pci_driver hvfb_pci_stub_driver = {
920 .name = KBUILD_MODNAME,
921 .id_table = pci_stub_id_table,
922 .probe = hvfb_pci_stub_probe,
923 .remove = hvfb_pci_stub_remove,
925 .probe_type = PROBE_PREFER_ASYNCHRONOUS,
929 static int __init hvfb_drv_init(void)
933 ret = vmbus_driver_register(&hvfb_drv);
937 ret = pci_register_driver(&hvfb_pci_stub_driver);
939 vmbus_driver_unregister(&hvfb_drv);
946 static void __exit hvfb_drv_exit(void)
948 pci_unregister_driver(&hvfb_pci_stub_driver);
949 vmbus_driver_unregister(&hvfb_drv);
952 module_init(hvfb_drv_init);
953 module_exit(hvfb_drv_exit);
955 MODULE_LICENSE("GPL");
956 MODULE_DESCRIPTION("Microsoft Hyper-V Synthetic Video Frame Buffer Driver");