~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/gallium/winsys/sw/fbdev/fbdev_sw_winsys.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Mesa 3-D graphics library
 
3
 * Version:  7.9
 
4
 *
 
5
 * Copyright (C) 2010 LunarG Inc.
 
6
 *
 
7
 * Permission is hereby granted, free of charge, to any person obtaining a
 
8
 * copy of this software and associated documentation files (the "Software"),
 
9
 * to deal in the Software without restriction, including without limitation
 
10
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
11
 * and/or sell copies of the Software, and to permit persons to whom the
 
12
 * Software is furnished to do so, subject to the following conditions:
 
13
 *
 
14
 * The above copyright notice and this permission notice shall be included
 
15
 * in all copies or substantial portions of the Software.
 
16
 *
 
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
20
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
23
 * DEALINGS IN THE SOFTWARE.
 
24
 *
 
25
 * Authors:
 
26
 *    Chia-I Wu <olv@lunarg.com>
 
27
 */
 
28
 
 
29
#include <sys/mman.h>
 
30
#include <sys/ioctl.h>
 
31
#include <linux/fb.h>
 
32
 
 
33
#include "pipe/p_compiler.h"
 
34
#include "util/u_format.h"
 
35
#include "util/u_math.h"
 
36
#include "util/u_memory.h"
 
37
#include "state_tracker/sw_winsys.h"
 
38
 
 
39
#include "fbdev_sw_winsys.h"
 
40
 
 
41
struct fbdev_sw_displaytarget
 
42
{
 
43
   enum pipe_format format;
 
44
   unsigned width;
 
45
   unsigned height;
 
46
   unsigned stride;
 
47
 
 
48
   void *data;
 
49
   void *mapped;
 
50
};
 
51
 
 
52
struct fbdev_sw_winsys
 
53
{
 
54
   struct sw_winsys base;
 
55
 
 
56
   int fd;
 
57
   enum pipe_format format;
 
58
 
 
59
   struct fb_fix_screeninfo finfo;
 
60
   void *fbmem;
 
61
   unsigned rows;
 
62
   unsigned stride;
 
63
};
 
64
 
 
65
static INLINE struct fbdev_sw_displaytarget *
 
66
fbdev_sw_displaytarget(struct sw_displaytarget *dt)
 
67
{
 
68
   return (struct fbdev_sw_displaytarget *) dt;
 
69
}
 
70
 
 
71
static INLINE struct fbdev_sw_winsys *
 
72
fbdev_sw_winsys(struct sw_winsys *ws)
 
73
{
 
74
   return (struct fbdev_sw_winsys *) ws;
 
75
}
 
76
 
 
77
static void
 
78
fbdev_displaytarget_display(struct sw_winsys *ws,
 
79
                            struct sw_displaytarget *dt,
 
80
                            void *context_private)
 
81
{
 
82
   struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
 
83
   struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt);
 
84
   unsigned rows, len, i;
 
85
 
 
86
   rows = MIN2(fbdt->height, fbdev->rows);
 
87
   len = util_format_get_stride(fbdt->format, fbdt->width);
 
88
   len = MIN2(len, fbdev->stride);
 
89
 
 
90
   for (i = 0; i < rows; i++) {
 
91
      void *dst = fbdev->fbmem + fbdev->stride * i;
 
92
      void *src = fbdt->data + fbdt->stride * i;
 
93
 
 
94
      memcpy(dst, src, len);
 
95
   }
 
96
}
 
97
 
 
98
static void
 
99
fbdev_displaytarget_unmap(struct sw_winsys *ws,
 
100
                           struct sw_displaytarget *dt)
 
101
{
 
102
   struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt);
 
103
   fbdt->mapped = NULL;
 
104
}
 
105
 
 
106
static void *
 
107
fbdev_displaytarget_map(struct sw_winsys *ws,
 
108
                        struct sw_displaytarget *dt,
 
109
                        unsigned flags)
 
110
{
 
111
   struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt);
 
112
   fbdt->mapped = fbdt->data;
 
113
   return fbdt->mapped;
 
114
}
 
115
 
 
116
static void
 
117
fbdev_displaytarget_destroy(struct sw_winsys *ws,
 
118
                            struct sw_displaytarget *dt)
 
119
{
 
120
   struct fbdev_sw_displaytarget *fbdt = fbdev_sw_displaytarget(dt);
 
121
 
 
122
   if (fbdt->data)
 
123
      align_free(fbdt->data);
 
124
 
 
125
   FREE(fbdt);
 
126
}
 
127
 
 
128
static struct sw_displaytarget *
 
129
fbdev_displaytarget_create(struct sw_winsys *ws,
 
130
                           unsigned tex_usage,
 
131
                           enum pipe_format format,
 
132
                           unsigned width, unsigned height,
 
133
                           unsigned alignment,
 
134
                           unsigned *stride)
 
135
{
 
136
   struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
 
137
   struct fbdev_sw_displaytarget *fbdt;
 
138
   unsigned nblocksy, size, format_stride;
 
139
 
 
140
   if (fbdev->format != format)
 
141
      return NULL;
 
142
 
 
143
   fbdt = CALLOC_STRUCT(fbdev_sw_displaytarget);
 
144
   if (!fbdt)
 
145
      return NULL;
 
146
 
 
147
   fbdt->format = format;
 
148
   fbdt->width = width;
 
149
   fbdt->height = height;
 
150
 
 
151
   format_stride = util_format_get_stride(format, width);
 
152
   fbdt->stride = align(format_stride, alignment);
 
153
 
 
154
   nblocksy = util_format_get_nblocksy(format, height);
 
155
   size = fbdt->stride * nblocksy;
 
156
 
 
157
   fbdt->data = align_malloc(size, alignment);
 
158
   if (!fbdt->data) {
 
159
      FREE(fbdt);
 
160
      return NULL;
 
161
   }
 
162
 
 
163
   *stride = fbdt->stride;
 
164
 
 
165
   return (struct sw_displaytarget *) fbdt;
 
166
}
 
167
 
 
168
static boolean
 
169
fbdev_is_displaytarget_format_supported(struct sw_winsys *ws,
 
170
                                        unsigned tex_usage,
 
171
                                        enum pipe_format format)
 
172
{
 
173
   struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
 
174
   return (fbdev->format == format);
 
175
}
 
176
 
 
177
static void
 
178
fbdev_destroy(struct sw_winsys *ws)
 
179
{
 
180
   struct fbdev_sw_winsys *fbdev = fbdev_sw_winsys(ws);
 
181
 
 
182
   munmap(fbdev->fbmem, fbdev->finfo.smem_len);
 
183
   FREE(fbdev);
 
184
}
 
185
 
 
186
struct sw_winsys *
 
187
fbdev_create_sw_winsys(int fd, enum pipe_format format)
 
188
{
 
189
   struct fbdev_sw_winsys *fbdev;
 
190
 
 
191
   fbdev = CALLOC_STRUCT(fbdev_sw_winsys);
 
192
   if (!fbdev)
 
193
      return NULL;
 
194
 
 
195
   fbdev->fd = fd;
 
196
   fbdev->format = format;
 
197
   if (ioctl(fbdev->fd, FBIOGET_FSCREENINFO, &fbdev->finfo)) {
 
198
      FREE(fbdev);
 
199
      return NULL;
 
200
   }
 
201
 
 
202
   fbdev->fbmem = mmap(0, fbdev->finfo.smem_len,
 
203
         PROT_WRITE, MAP_SHARED, fbdev->fd, 0);
 
204
   if (fbdev->fbmem == MAP_FAILED) {
 
205
      FREE(fbdev);
 
206
      return NULL;
 
207
   }
 
208
 
 
209
   fbdev->rows = fbdev->finfo.smem_len / fbdev->finfo.line_length;
 
210
   fbdev->stride = fbdev->finfo.line_length;
 
211
 
 
212
   fbdev->base.destroy = fbdev_destroy;
 
213
   fbdev->base.is_displaytarget_format_supported =
 
214
      fbdev_is_displaytarget_format_supported;
 
215
 
 
216
   fbdev->base.displaytarget_create = fbdev_displaytarget_create;
 
217
   fbdev->base.displaytarget_destroy = fbdev_displaytarget_destroy;
 
218
   fbdev->base.displaytarget_map = fbdev_displaytarget_map;
 
219
   fbdev->base.displaytarget_unmap = fbdev_displaytarget_unmap;
 
220
 
 
221
   fbdev->base.displaytarget_display = fbdev_displaytarget_display;
 
222
 
 
223
   return &fbdev->base;
 
224
}