VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/vboxvideo_crtc.c@ 42784

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

Linux 3.6-rc1 compile fix, spaces

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/** @file $Id: vboxvideo_crtc.c 42784 2012-08-12 20:31:36Z vboxsync $
2 *
3 * VirtualBox Additions Linux kernel video driver, KMS support
4 */
5
6/*
7 * Copyright (C) 2011 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_crtc.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 <VBox/VBoxVideoGuest.h>
49
50#include "vboxvideo_drv.h"
51
52#include "drm/drm_crtc_helper.h"
53
54static void vboxvideo_crtc_dpms(struct drm_crtc *crtc, int mode)
55{
56 struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
57 struct drm_device *dev = crtc->dev;
58 struct vboxvideo_device *gdev = dev->dev_private;
59
60 if (mode == vboxvideo_crtc->last_dpms) /* Don't do unnecesary mode changes. */
61 return;
62
63 vboxvideo_crtc->last_dpms = mode;
64
65 switch (mode) {
66 case DRM_MODE_DPMS_STANDBY:
67 case DRM_MODE_DPMS_SUSPEND:
68 case DRM_MODE_DPMS_OFF:
69 vboxvideo_crtc->enabled = false;
70 break;
71 case DRM_MODE_DPMS_ON:
72 vboxvideo_crtc->enabled = true;
73 break;
74 }
75}
76
77static bool vboxvideo_crtc_mode_fixup(struct drm_crtc *crtc,
78 struct drm_display_mode *mode,
79 struct drm_display_mode *adjusted_mode)
80{
81 return true;
82}
83
84static int vboxvideo_crtc_mode_set(struct drm_crtc *crtc,
85 struct drm_display_mode *mode,
86 struct drm_display_mode *adjusted_mode,
87 int x, int y, struct drm_framebuffer *old_fb)
88{
89 /*
90 struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
91
92 vboxvideo_crtc_set_base(crtc, x, y, old_fb);
93 vboxvideo_set_crtc_timing(crtc, adjusted_mode);
94 vboxvideo_set_pll(crtc, adjusted_mode);
95 */
96 return 0;
97}
98
99static void vboxvideo_crtc_prepare(struct drm_crtc *crtc)
100{
101 struct drm_device *dev = crtc->dev;
102 struct drm_crtc *crtci;
103
104 /*
105 list_for_each_entry(crtci, &dev->mode_config.crtc_list, head)
106 vboxvideo_crtc_dpms(crtci, DRM_MODE_DPMS_OFF);
107 */
108}
109
110static void vboxvideo_crtc_commit(struct drm_crtc *crtc)
111{
112 struct drm_device *dev = crtc->dev;
113 struct drm_crtc *crtci;
114
115 /*
116 list_for_each_entry(crtci, &dev->mode_config.crtc_list, head) {
117 if (crtci->enabled)
118 vboxvideo_crtc_dpms(crtci, DRM_MODE_DPMS_ON);
119 }
120 */
121}
122
123static void vboxvideo_crtc_load_lut(struct drm_crtc *crtc)
124{
125 /* Dummy */
126}
127
128static void vboxvideo_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
129 u16 *green, u16 *blue, uint32_t size)
130{
131 /* Dummy */
132}
133
134static void vboxvideo_crtc_destroy(struct drm_crtc *crtc)
135{
136 struct vboxvideo_crtc *vboxvideo_crtc = to_vboxvideo_crtc(crtc);
137
138 drm_crtc_cleanup(crtc);
139 kfree(vboxvideo_crtc);
140}
141
142static const struct drm_crtc_funcs vboxvideo_crtc_funcs = {
143 /*
144 .cursor_set = vboxvideo_crtc_cursor_set,
145 .cursor_move = vboxvideo_crtc_cursor_move,
146 */
147 .cursor_set = NULL,
148 .cursor_move = NULL,
149 .gamma_set = vboxvideo_crtc_gamma_set,
150 .set_config = drm_crtc_helper_set_config,
151 .destroy = vboxvideo_crtc_destroy,
152};
153
154static const struct drm_crtc_helper_funcs vboxvideo_helper_funcs = {
155 .dpms = vboxvideo_crtc_dpms,
156 .mode_fixup = vboxvideo_crtc_mode_fixup,
157 .mode_set = vboxvideo_crtc_mode_set,
158 /*
159 .mode_set_base = vboxvideo_crtc_set_base,
160 */
161 .prepare = vboxvideo_crtc_prepare,
162 .commit = vboxvideo_crtc_commit,
163 .load_lut = vboxvideo_crtc_load_lut,
164};
165
166void vboxvideo_crtc_init(struct drm_device *dev, int index)
167{
168 struct vboxvideo_device *gdev = dev->dev_private;
169 struct vboxvideo_crtc *vboxvideo_crtc;
170 int i;
171
172 vboxvideo_crtc = kzalloc( sizeof(struct vboxvideo_crtc)
173 + (VBOXVIDEOFB_CONN_LIMIT
174 * sizeof(struct drm_connector *)),
175 GFP_KERNEL);
176 if (vboxvideo_crtc == NULL)
177 return;
178
179 drm_crtc_init(dev, &vboxvideo_crtc->base, &vboxvideo_crtc_funcs);
180
181 vboxvideo_crtc->crtc_id = index;
182 vboxvideo_crtc->last_dpms = VBOXVIDEO_DPMS_CLEARED;
183 gdev->mode_info.crtcs[index] = vboxvideo_crtc;
184
185 drm_crtc_helper_add(&vboxvideo_crtc->base, &vboxvideo_helper_funcs);
186}
187
188#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
Note: See TracBrowser for help on using the repository browser.

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