aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2011-11-14 17:51:28 -0500
committerDave Airlie <airlied@redhat.com>2011-11-15 14:53:23 -0500
commit308e5bcbdb10452e8aba31aa21432fb67ee46d72 (patch)
tree5e4eebef07685c4047f54d1727fc9bcbace8889d /include
parent8cf5c9177151537e73ff1816540e4ba24b174391 (diff)
drm: add an fb creation ioctl that takes a pixel format v5
To properly support the various plane formats supported by different hardware, the kernel must know the pixel format of a framebuffer object. So add a new ioctl taking a format argument corresponding to a fourcc name from the new drm_fourcc.h header file. Implement the fb creation hooks in terms of the new mode_fb_cmd2 using helpers where the old bpp/depth values are needed. v2: create DRM specific fourcc header file for sharing with libdrm etc v3: fix rebase failure and use DRM fourcc codes in intel_display.c and update commit message v4: make fb_cmd2 handle field into an array for multi-object formats pull in Ville's fix for the memcpy in drm_plane_init apply Ville's cleanup to zero out fb_cmd2 arg in drm_mode_addfb v5: add 'flags' field for interlaced support (from Ville) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Acked-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Reviewed-by: Rob Clark <rob.clark@linaro.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/drm/drm.h1
-rw-r--r--include/drm/drm_crtc.h9
-rw-r--r--include/drm/drm_crtc_helper.h4
-rw-r--r--include/drm/drm_fourcc.h63
-rw-r--r--include/drm/drm_mode.h27
5 files changed, 101 insertions, 3 deletions
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 28979677f94e..49d94ede2ec2 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -717,6 +717,7 @@ struct drm_get_cap {
717#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res) 717#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
718#define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane) 718#define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane)
719#define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane) 719#define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane)
720#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
720 721
721/** 722/**
722 * Device specific ioctls should only be in their respective headers 723 * Device specific ioctls should only be in their respective headers
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index e20867ed7c90..a2fbf3399682 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -29,9 +29,10 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/idr.h> 31#include <linux/idr.h>
32
33#include <linux/fb.h> 32#include <linux/fb.h>
34 33
34#include <drm/drm_fourcc.h>
35
35struct drm_device; 36struct drm_device;
36struct drm_mode_set; 37struct drm_mode_set;
37struct drm_framebuffer; 38struct drm_framebuffer;
@@ -246,6 +247,7 @@ struct drm_framebuffer {
246 unsigned int depth; 247 unsigned int depth;
247 int bits_per_pixel; 248 int bits_per_pixel;
248 int flags; 249 int flags;
250 uint32_t pixel_format; /* fourcc format */
249 struct list_head filp_head; 251 struct list_head filp_head;
250 /* if you are using the helper */ 252 /* if you are using the helper */
251 void *helper_private; 253 void *helper_private;
@@ -619,7 +621,7 @@ struct drm_mode_set {
619 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout 621 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
620 */ 622 */
621struct drm_mode_config_funcs { 623struct drm_mode_config_funcs {
622 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd); 624 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd);
623 void (*output_poll_changed)(struct drm_device *dev); 625 void (*output_poll_changed)(struct drm_device *dev);
624}; 626};
625 627
@@ -837,6 +839,9 @@ extern int drm_mode_cursor_ioctl(struct drm_device *dev,
837 void *data, struct drm_file *file_priv); 839 void *data, struct drm_file *file_priv);
838extern int drm_mode_addfb(struct drm_device *dev, 840extern int drm_mode_addfb(struct drm_device *dev,
839 void *data, struct drm_file *file_priv); 841 void *data, struct drm_file *file_priv);
842extern int drm_mode_addfb2(struct drm_device *dev,
843 void *data, struct drm_file *file_priv);
844extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
840extern int drm_mode_rmfb(struct drm_device *dev, 845extern int drm_mode_rmfb(struct drm_device *dev,
841 void *data, struct drm_file *file_priv); 846 void *data, struct drm_file *file_priv);
842extern int drm_mode_getfb(struct drm_device *dev, 847extern int drm_mode_getfb(struct drm_device *dev,
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index 73b071203dcc..b4abb33dbcd8 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -116,8 +116,10 @@ extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
116 116
117extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode); 117extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
118 118
119extern void drm_helper_get_fb_bpp_depth(uint32_t format, unsigned int *depth,
120 int *bpp);
119extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 121extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
120 struct drm_mode_fb_cmd *mode_cmd); 122 struct drm_mode_fb_cmd2 *mode_cmd);
121 123
122static inline void drm_crtc_helper_add(struct drm_crtc *crtc, 124static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
123 const struct drm_crtc_helper_funcs *funcs) 125 const struct drm_crtc_helper_funcs *funcs)
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
new file mode 100644
index 000000000000..48c3d107a8fa
--- /dev/null
+++ b/include/drm/drm_fourcc.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright 2011 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#ifndef DRM_FOURCC_H
25#define DRM_FOURCC_H
26
27/*
28 * We don't use the V4L header because
29 * 1) the fourcc codes are well defined and trivial to construct
30 * 2) we don't want user apps to have to pull in v4l headers just for fourcc
31 * 3) the v4l fourcc codes are mixed up with a bunch of other code and are
32 * part of the v4l API, so changing them to something linux-generic isn't
33 * feasible
34 *
35 * So the below includes the fourcc codes used by the DRM and its drivers,
36 * along with potential device specific codes.
37 */
38
39#include <linux/types.h>
40
41#define fourcc_code(a,b,c,d) ((u32)(a) | ((u32)(b) << 8) | \
42 ((u32)(c) << 16) | ((u32)(d) << 24))
43
44/* RGB codes */
45#define DRM_FOURCC_RGB332 fourcc_code('R','G','B','1')
46#define DRM_FOURCC_RGB555 fourcc_code('R','G','B','O')
47#define DRM_FOURCC_RGB565 fourcc_code('R','G','B','P')
48#define DRM_FOURCC_RGB24 fourcc_code('R','G','B','3')
49#define DRM_FOURCC_RGB32 fourcc_code('R','G','B','4')
50
51#define DRM_FOURCC_BGR24 fourcc_code('B','G','R','3')
52#define DRM_FOURCC_BGR32 fourcc_code('B','G','R','4')
53
54/* YUV codes */
55#define DRM_FOURCC_YUYV fourcc_code('Y', 'U', 'Y', 'V')
56#define DRM_FOURCC_YVYU fourcc_code('Y', 'V', 'Y', 'U')
57#define DRM_FOURCC_UYVY fourcc_code('U', 'Y', 'V', 'Y')
58#define DRM_FOURCC_VYUY fourcc_code('V', 'Y', 'U', 'Y')
59
60/* DRM specific codes */
61#define DRM_INTEL_RGB30 fourcc_code('R','G','B','0') /* RGB x:10:10:10 */
62
63#endif /* DRM_FOURCC_H */
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index 44576a54dc3b..95d7aad5cad3 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -268,6 +268,33 @@ struct drm_mode_fb_cmd {
268 __u32 handle; 268 __u32 handle;
269}; 269};
270 270
271#define DRM_MODE_FB_INTERLACED (1<<0 /* for interlaced framebuffers */
272
273struct drm_mode_fb_cmd2 {
274 __u32 fb_id;
275 __u32 width, height;
276 __u32 pixel_format; /* fourcc code from drm_fourcc.h */
277 __u32 flags; /* see above flags */
278
279 /*
280 * In case of planar formats, this ioctl allows up to 4
281 * buffer objects with offets and pitches per plane.
282 * The pitch and offset order is dictated by the fourcc,
283 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
284 *
285 * YUV 4:2:0 image with a plane of 8 bit Y samples
286 * followed by an interleaved U/V plane containing
287 * 8 bit 2x2 subsampled colour difference samples.
288 *
289 * So it would consist of Y as offset[0] and UV as
290 * offeset[1]. Note that offset[0] will generally
291 * be 0.
292 */
293 __u32 handles[4];
294 __u32 pitches[4]; /* pitch for each plane */
295 __u32 offsets[4]; /* offset of each plane */
296};
297
271#define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01 298#define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
272#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02 299#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
273#define DRM_MODE_FB_DIRTY_FLAGS 0x03 300#define DRM_MODE_FB_DIRTY_FLAGS 0x03