VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/vboxvideo_vga.c@ 47341

Last change on this file since 47341 was 47341, checked in by vboxsync, 12 years ago

Additions/linux/drm: more kernel version magic and a small additional code drop.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.5 KB
Line 
1/** @file $Id: vboxvideo_vga.c 47341 2013-07-23 12:54:56Z vboxsync $
2 *
3 * VirtualBox Additions Linux kernel video driver, VGA functions
4 */
5
6/*
7 * Copyright (C) 2011-2012 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * --------------------------------------------------------------------
17 *
18 * This code is based on
19 * glint_vga.c
20 * with the following copyright and permission notice:
21 *
22 * Copyright 2010 Matt Turner.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the "Software"),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice shall be included in
32 * all copies or substantial portions of the Software.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
38 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
39 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 * OTHER DEALINGS IN THE SOFTWARE.
41 *
42 * Authors: Matt Turner
43 */
44
45#include <linux/version.h>
46#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
47
48#include "vboxvideo_drv.h"
49#include "drm/drm_crtc_helper.h"
50
51static int vboxvideo_vga_get_modes(struct drm_connector *connector)
52{
53 /* return 0 modes, so that we don't have to implement DDC/I2C yet. */
54 return 0;
55}
56
57static int vboxvideo_vga_mode_valid(struct drm_connector *connector,
58 struct drm_display_mode *mode)
59{
60 /* XXX check mode bandwidth */
61 /* XXX verify against max DAC output frequency */
62 return MODE_OK;
63}
64
65struct drm_encoder *vboxvideo_connector_best_encoder(struct drm_connector
66 *connector)
67{
68 int enc_id = connector->encoder_ids[0];
69 struct drm_mode_object *obj;
70 struct drm_encoder *encoder;
71
72 /* pick the encoder ids */
73 if (enc_id) {
74 obj = drm_mode_object_find(connector->dev, enc_id, DRM_MODE_OBJECT_ENCODER);
75 if (!obj)
76 return NULL;
77 encoder = obj_to_encoder(obj);
78 return encoder;
79 }
80 return NULL;
81}
82
83static enum drm_connector_status vboxvideo_vga_detect(struct drm_connector
84 *connector
85#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
86 , bool force
87#endif
88 )
89{
90 return connector_status_connected;
91}
92
93static void vboxvideo_connector_destroy(struct drm_connector *connector)
94{
95 drm_connector_cleanup(connector);
96 kfree(connector);
97}
98
99struct drm_connector_helper_funcs vboxvideo_vga_connector_helper_funcs =
100{
101 .get_modes = vboxvideo_vga_get_modes,
102 .mode_valid = vboxvideo_vga_mode_valid,
103 .best_encoder = vboxvideo_connector_best_encoder,
104};
105
106struct drm_connector_funcs vboxvideo_vga_connector_funcs =
107{
108 .dpms = drm_helper_connector_dpms,
109 .detect = vboxvideo_vga_detect,
110 .fill_modes = drm_helper_probe_single_connector_modes,
111 .destroy = vboxvideo_connector_destroy,
112};
113
114struct drm_connector *vboxvideo_vga_init(struct drm_device *dev)
115{
116 struct drm_connector *connector;
117 struct vboxvideo_connector *vboxvideo_connector;
118
119 vboxvideo_connector = kzalloc(sizeof(struct vboxvideo_connector),
120 GFP_KERNEL);
121 if (!vboxvideo_connector)
122 return NULL;
123
124 connector = &vboxvideo_connector->base;
125
126 drm_connector_init(dev, connector,
127 &vboxvideo_vga_connector_funcs, DRM_MODE_CONNECTOR_VGA);
128
129 drm_connector_helper_add(connector, &vboxvideo_vga_connector_helper_funcs);
130
131 return connector;
132}
133
134#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette