aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-12-13 08:02:26 -0500
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>2011-12-19 15:07:13 -0500
commitfb21c2f42879c05c76ea9e249b6905fc729f8529 (patch)
tree93c4581f4f2947dae8ebd36eae0cf86f38ec93d3 /Documentation
parentb779505282590289546aab9ffead4490fe195d40 (diff)
fbdev: Add FOURCC-based format configuration API
This API will be used to support YUV frame buffer formats in a standard way. Last but not least, create a much needed fbdev API documentation and document the format setting APIs. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/fb/api.txt306
1 files changed, 306 insertions, 0 deletions
diff --git a/Documentation/fb/api.txt b/Documentation/fb/api.txt
new file mode 100644
index 000000000000..d4ff7de85700
--- /dev/null
+++ b/Documentation/fb/api.txt
@@ -0,0 +1,306 @@
1 The Frame Buffer Device API
2 ---------------------------
3
4Last revised: June 21, 2011
5
6
70. Introduction
8---------------
9
10This document describes the frame buffer API used by applications to interact
11with frame buffer devices. In-kernel APIs between device drivers and the frame
12buffer core are not described.
13
14Due to a lack of documentation in the original frame buffer API, drivers
15behaviours differ in subtle (and not so subtle) ways. This document describes
16the recommended API implementation, but applications should be prepared to
17deal with different behaviours.
18
19
201. Capabilities
21---------------
22
23Device and driver capabilities are reported in the fixed screen information
24capabilities field.
25
26struct fb_fix_screeninfo {
27 ...
28 __u16 capabilities; /* see FB_CAP_* */
29 ...
30};
31
32Application should use those capabilities to find out what features they can
33expect from the device and driver.
34
35- FB_CAP_FOURCC
36
37The driver supports the four character code (FOURCC) based format setting API.
38When supported, formats are configured using a FOURCC instead of manually
39specifying color components layout.
40
41
422. Types and visuals
43--------------------
44
45Pixels are stored in memory in hardware-dependent formats. Applications need
46to be aware of the pixel storage format in order to write image data to the
47frame buffer memory in the format expected by the hardware.
48
49Formats are described by frame buffer types and visuals. Some visuals require
50additional information, which are stored in the variable screen information
51bits_per_pixel, grayscale, red, green, blue and transp fields.
52
53Visuals describe how color information is encoded and assembled to create
54macropixels. Types describe how macropixels are stored in memory. The following
55types and visuals are supported.
56
57- FB_TYPE_PACKED_PIXELS
58
59Macropixels are stored contiguously in a single plane. If the number of bits
60per macropixel is not a multiple of 8, whether macropixels are padded to the
61next multiple of 8 bits or packed together into bytes depends on the visual.
62
63Padding at end of lines may be present and is then reported through the fixed
64screen information line_length field.
65
66- FB_TYPE_PLANES
67
68Macropixels are split across multiple planes. The number of planes is equal to
69the number of bits per macropixel, with plane i'th storing i'th bit from all
70macropixels.
71
72Planes are located contiguously in memory.
73
74- FB_TYPE_INTERLEAVED_PLANES
75
76Macropixels are split across multiple planes. The number of planes is equal to
77the number of bits per macropixel, with plane i'th storing i'th bit from all
78macropixels.
79
80Planes are interleaved in memory. The interleave factor, defined as the
81distance in bytes between the beginning of two consecutive interleaved blocks
82belonging to different planes, is stored in the fixed screen information
83type_aux field.
84
85- FB_TYPE_FOURCC
86
87Macropixels are stored in memory as described by the format FOURCC identifier
88stored in the variable screen information grayscale field.
89
90- FB_VISUAL_MONO01
91
92Pixels are black or white and stored on a number of bits (typically one)
93specified by the variable screen information bpp field.
94
95Black pixels are represented by all bits set to 1 and white pixels by all bits
96set to 0. When the number of bits per pixel is smaller than 8, several pixels
97are packed together in a byte.
98
99FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only.
100
101- FB_VISUAL_MONO10
102
103Pixels are black or white and stored on a number of bits (typically one)
104specified by the variable screen information bpp field.
105
106Black pixels are represented by all bits set to 0 and white pixels by all bits
107set to 1. When the number of bits per pixel is smaller than 8, several pixels
108are packed together in a byte.
109
110FB_VISUAL_MONO01 is currently used with FB_TYPE_PACKED_PIXELS only.
111
112- FB_VISUAL_TRUECOLOR
113
114Pixels are broken into red, green and blue components, and each component
115indexes a read-only lookup table for the corresponding value. Lookup tables
116are device-dependent, and provide linear or non-linear ramps.
117
118Each component is stored in a macropixel according to the variable screen
119information red, green, blue and transp fields.
120
121- FB_VISUAL_PSEUDOCOLOR and FB_VISUAL_STATIC_PSEUDOCOLOR
122
123Pixel values are encoded as indices into a colormap that stores red, green and
124blue components. The colormap is read-only for FB_VISUAL_STATIC_PSEUDOCOLOR
125and read-write for FB_VISUAL_PSEUDOCOLOR.
126
127Each pixel value is stored in the number of bits reported by the variable
128screen information bits_per_pixel field.
129
130- FB_VISUAL_DIRECTCOLOR
131
132Pixels are broken into red, green and blue components, and each component
133indexes a programmable lookup table for the corresponding value.
134
135Each component is stored in a macropixel according to the variable screen
136information red, green, blue and transp fields.
137
138- FB_VISUAL_FOURCC
139
140Pixels are encoded and interpreted as described by the format FOURCC
141identifier stored in the variable screen information grayscale field.
142
143
1443. Screen information
145---------------------
146
147Screen information are queried by applications using the FBIOGET_FSCREENINFO
148and FBIOGET_VSCREENINFO ioctls. Those ioctls take a pointer to a
149fb_fix_screeninfo and fb_var_screeninfo structure respectively.
150
151struct fb_fix_screeninfo stores device independent unchangeable information
152about the frame buffer device and the current format. Those information can't
153be directly modified by applications, but can be changed by the driver when an
154application modifies the format.
155
156struct fb_fix_screeninfo {
157 char id[16]; /* identification string eg "TT Builtin" */
158 unsigned long smem_start; /* Start of frame buffer mem */
159 /* (physical address) */
160 __u32 smem_len; /* Length of frame buffer mem */
161 __u32 type; /* see FB_TYPE_* */
162 __u32 type_aux; /* Interleave for interleaved Planes */
163 __u32 visual; /* see FB_VISUAL_* */
164 __u16 xpanstep; /* zero if no hardware panning */
165 __u16 ypanstep; /* zero if no hardware panning */
166 __u16 ywrapstep; /* zero if no hardware ywrap */
167 __u32 line_length; /* length of a line in bytes */
168 unsigned long mmio_start; /* Start of Memory Mapped I/O */
169 /* (physical address) */
170 __u32 mmio_len; /* Length of Memory Mapped I/O */
171 __u32 accel; /* Indicate to driver which */
172 /* specific chip/card we have */
173 __u16 capabilities; /* see FB_CAP_* */
174 __u16 reserved[2]; /* Reserved for future compatibility */
175};
176
177struct fb_var_screeninfo stores device independent changeable information
178about a frame buffer device, its current format and video mode, as well as
179other miscellaneous parameters.
180
181struct fb_var_screeninfo {
182 __u32 xres; /* visible resolution */
183 __u32 yres;
184 __u32 xres_virtual; /* virtual resolution */
185 __u32 yres_virtual;
186 __u32 xoffset; /* offset from virtual to visible */
187 __u32 yoffset; /* resolution */
188
189 __u32 bits_per_pixel; /* guess what */
190 __u32 grayscale; /* 0 = color, 1 = grayscale, */
191 /* >1 = FOURCC */
192 struct fb_bitfield red; /* bitfield in fb mem if true color, */
193 struct fb_bitfield green; /* else only length is significant */
194 struct fb_bitfield blue;
195 struct fb_bitfield transp; /* transparency */
196
197 __u32 nonstd; /* != 0 Non standard pixel format */
198
199 __u32 activate; /* see FB_ACTIVATE_* */
200
201 __u32 height; /* height of picture in mm */
202 __u32 width; /* width of picture in mm */
203
204 __u32 accel_flags; /* (OBSOLETE) see fb_info.flags */
205
206 /* Timing: All values in pixclocks, except pixclock (of course) */
207 __u32 pixclock; /* pixel clock in ps (pico seconds) */
208 __u32 left_margin; /* time from sync to picture */
209 __u32 right_margin; /* time from picture to sync */
210 __u32 upper_margin; /* time from sync to picture */
211 __u32 lower_margin;
212 __u32 hsync_len; /* length of horizontal sync */
213 __u32 vsync_len; /* length of vertical sync */
214 __u32 sync; /* see FB_SYNC_* */
215 __u32 vmode; /* see FB_VMODE_* */
216 __u32 rotate; /* angle we rotate counter clockwise */
217 __u32 colorspace; /* colorspace for FOURCC-based modes */
218 __u32 reserved[4]; /* Reserved for future compatibility */
219};
220
221To modify variable information, applications call the FBIOPUT_VSCREENINFO
222ioctl with a pointer to a fb_var_screeninfo structure. If the call is
223successful, the driver will update the fixed screen information accordingly.
224
225Instead of filling the complete fb_var_screeninfo structure manually,
226applications should call the FBIOGET_VSCREENINFO ioctl and modify only the
227fields they care about.
228
229
2304. Format configuration
231-----------------------
232
233Frame buffer devices offer two ways to configure the frame buffer format: the
234legacy API and the FOURCC-based API.
235
236
237The legacy API has been the only frame buffer format configuration API for a
238long time and is thus widely used by application. It is the recommended API
239for applications when using RGB and grayscale formats, as well as legacy
240non-standard formats.
241
242To select a format, applications set the fb_var_screeninfo bits_per_pixel field
243to the desired frame buffer depth. Values up to 8 will usually map to
244monochrome, grayscale or pseudocolor visuals, although this is not required.
245
246- For grayscale formats, applications set the grayscale field to one. The red,
247 blue, green and transp fields must be set to 0 by applications and ignored by
248 drivers. Drivers must fill the red, blue and green offsets to 0 and lengths
249 to the bits_per_pixel value.
250
251- For pseudocolor formats, applications set the grayscale field to zero. The
252 red, blue, green and transp fields must be set to 0 by applications and
253 ignored by drivers. Drivers must fill the red, blue and green offsets to 0
254 and lengths to the bits_per_pixel value.
255
256- For truecolor and directcolor formats, applications set the grayscale field
257 to zero, and the red, blue, green and transp fields to describe the layout of
258 color components in memory.
259
260struct fb_bitfield {
261 __u32 offset; /* beginning of bitfield */
262 __u32 length; /* length of bitfield */
263 __u32 msb_right; /* != 0 : Most significant bit is */
264 /* right */
265};
266
267 Pixel values are bits_per_pixel wide and are split in non-overlapping red,
268 green, blue and alpha (transparency) components. Location and size of each
269 component in the pixel value are described by the fb_bitfield offset and
270 length fields. Offset are computed from the right.
271
272 Pixels are always stored in an integer number of bytes. If the number of
273 bits per pixel is not a multiple of 8, pixel values are padded to the next
274 multiple of 8 bits.
275
276Upon successful format configuration, drivers update the fb_fix_screeninfo
277type, visual and line_length fields depending on the selected format.
278
279
280The FOURCC-based API replaces format descriptions by four character codes
281(FOURCC). FOURCCs are abstract identifiers that uniquely define a format
282without explicitly describing it. This is the only API that supports YUV
283formats. Drivers are also encouraged to implement the FOURCC-based API for RGB
284and grayscale formats.
285
286Drivers that support the FOURCC-based API report this capability by setting
287the FB_CAP_FOURCC bit in the fb_fix_screeninfo capabilities field.
288
289FOURCC definitions are located in the linux/videodev2.h header. However, and
290despite starting with the V4L2_PIX_FMT_prefix, they are not restricted to V4L2
291and don't require usage of the V4L2 subsystem. FOURCC documentation is
292available in Documentation/DocBook/v4l/pixfmt.xml.
293
294To select a format, applications set the grayscale field to the desired FOURCC.
295For YUV formats, they should also select the appropriate colorspace by setting
296the colorspace field to one of the colorspaces listed in linux/videodev2.h and
297documented in Documentation/DocBook/v4l/colorspaces.xml.
298
299The red, green, blue and transp fields are not used with the FOURCC-based API.
300For forward compatibility reasons applications must zero those fields, and
301drivers must ignore them. Values other than 0 may get a meaning in future
302extensions.
303
304Upon successful format configuration, drivers update the fb_fix_screeninfo
305type, visual and line_length fields depending on the selected format. The type
306and visual fields are set to FB_TYPE_FOURCC and FB_VISUAL_FOURCC respectively.