aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 14:14:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 14:14:52 -0400
commit59534f7298c5e28aaa64e6ed550e247f64ee72ae (patch)
treeb9fef7756abf897d9e1b10950cdf10bf6dfe5cb7 /include/drm
parentac3ee84c604502240122c47b52f0542ec8774f15 (diff)
parentb486787ee4797d6e42a9bd3a6f079385ad0f4472 (diff)
Merge branch 'drm-for-2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-for-2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (207 commits) drm/radeon/kms/pm/r600: select the mid clock mode for single head low profile drm/radeon: fix power supply kconfig interaction. drm/radeon/kms: record object that have been list reserved drm/radeon: AGP memory is only I/O if the aperture can be mapped by the CPU. drm/radeon/kms: don't default display priority to high on rs4xx drm/edid: fix typo in 1600x1200@75 mode drm/nouveau: fix i2c-related init table handlers drm/nouveau: support init table i2c device identifier 0x81 drm/nouveau: ensure we've parsed i2c table entry for INIT_*I2C* handlers drm/nouveau: display error message for any failed init table opcode drm/nouveau: fix init table handlers to return proper error codes drm/nv50: support fractional feedback divider on newer chips drm/nv50: fix monitor detection on certain chipsets drm/nv50: store full dcb i2c entry from vbios drm/nv50: fix suspend/resume with DP outputs drm/nv50: output calculated crtc pll when debugging on drm/nouveau: dump pll limits entries when debugging is on drm/nouveau: bios parser fixes for eDP boards drm/nouveau: fix a nouveau_bo dereference after it's been destroyed drm/nv40: remove some completed ctxprog TODOs ...
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drmP.h3
-rw-r--r--include/drm/drm_crtc.h43
-rw-r--r--include/drm/drm_crtc_helper.h9
-rw-r--r--include/drm/drm_edid.h5
-rw-r--r--include/drm/drm_fb_helper.h67
-rw-r--r--include/drm/drm_fixed.h67
-rw-r--r--include/drm/radeon_drm.h1
-rw-r--r--include/drm/ttm/ttm_bo_api.h46
-rw-r--r--include/drm/ttm/ttm_bo_driver.h57
-rw-r--r--include/drm/ttm/ttm_page_alloc.h74
10 files changed, 293 insertions, 79 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 2f3b3a00b7a3..c1b987158dfa 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1428,10 +1428,13 @@ extern void drm_sysfs_connector_remove(struct drm_connector *connector);
1428/* Graphics Execution Manager library functions (drm_gem.c) */ 1428/* Graphics Execution Manager library functions (drm_gem.c) */
1429int drm_gem_init(struct drm_device *dev); 1429int drm_gem_init(struct drm_device *dev);
1430void drm_gem_destroy(struct drm_device *dev); 1430void drm_gem_destroy(struct drm_device *dev);
1431void drm_gem_object_release(struct drm_gem_object *obj);
1431void drm_gem_object_free(struct kref *kref); 1432void drm_gem_object_free(struct kref *kref);
1432void drm_gem_object_free_unlocked(struct kref *kref); 1433void drm_gem_object_free_unlocked(struct kref *kref);
1433struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev, 1434struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1434 size_t size); 1435 size_t size);
1436int drm_gem_object_init(struct drm_device *dev,
1437 struct drm_gem_object *obj, size_t size);
1435void drm_gem_object_handle_free(struct kref *kref); 1438void drm_gem_object_handle_free(struct kref *kref);
1436void drm_gem_vm_open(struct vm_area_struct *vma); 1439void drm_gem_vm_open(struct vm_area_struct *vma);
1437void drm_gem_vm_close(struct vm_area_struct *vma); 1440void drm_gem_vm_close(struct vm_area_struct *vma);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 1347524a8e30..93a1a31b9c2d 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -31,6 +31,7 @@
31#include <linux/idr.h> 31#include <linux/idr.h>
32 32
33#include <linux/fb.h> 33#include <linux/fb.h>
34#include <linux/slow-work.h>
34 35
35struct drm_device; 36struct drm_device;
36struct drm_mode_set; 37struct drm_mode_set;
@@ -271,8 +272,6 @@ struct drm_framebuffer {
271 unsigned int depth; 272 unsigned int depth;
272 int bits_per_pixel; 273 int bits_per_pixel;
273 int flags; 274 int flags;
274 struct fb_info *fbdev;
275 u32 pseudo_palette[17];
276 struct list_head filp_head; 275 struct list_head filp_head;
277 /* if you are using the helper */ 276 /* if you are using the helper */
278 void *helper_private; 277 void *helper_private;
@@ -369,9 +368,6 @@ struct drm_crtc_funcs {
369 * @enabled: is this CRTC enabled? 368 * @enabled: is this CRTC enabled?
370 * @x: x position on screen 369 * @x: x position on screen
371 * @y: y position on screen 370 * @y: y position on screen
372 * @desired_mode: new desired mode
373 * @desired_x: desired x for desired_mode
374 * @desired_y: desired y for desired_mode
375 * @funcs: CRTC control functions 371 * @funcs: CRTC control functions
376 * 372 *
377 * Each CRTC may have one or more connectors associated with it. This structure 373 * Each CRTC may have one or more connectors associated with it. This structure
@@ -391,8 +387,6 @@ struct drm_crtc {
391 struct drm_display_mode mode; 387 struct drm_display_mode mode;
392 388
393 int x, y; 389 int x, y;
394 struct drm_display_mode *desired_mode;
395 int desired_x, desired_y;
396 const struct drm_crtc_funcs *funcs; 390 const struct drm_crtc_funcs *funcs;
397 391
398 /* CRTC gamma size for reporting to userspace */ 392 /* CRTC gamma size for reporting to userspace */
@@ -467,6 +461,15 @@ enum drm_connector_force {
467 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ 461 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
468}; 462};
469 463
464/* should we poll this connector for connects and disconnects */
465/* hot plug detectable */
466#define DRM_CONNECTOR_POLL_HPD (1 << 0)
467/* poll for connections */
468#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
469/* can cleanly poll for disconnections without flickering the screen */
470/* DACs should rarely do this without a lot of testing */
471#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
472
470/** 473/**
471 * drm_connector - central DRM connector control structure 474 * drm_connector - central DRM connector control structure
472 * @crtc: CRTC this connector is currently connected to, NULL if none 475 * @crtc: CRTC this connector is currently connected to, NULL if none
@@ -511,6 +514,8 @@ struct drm_connector {
511 u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY]; 514 u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY];
512 uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY]; 515 uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
513 516
517 uint8_t polled; /* DRM_CONNECTOR_POLL_* */
518
514 /* requested DPMS state */ 519 /* requested DPMS state */
515 int dpms; 520 int dpms;
516 521
@@ -521,7 +526,6 @@ struct drm_connector {
521 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 526 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
522 uint32_t force_encoder_id; 527 uint32_t force_encoder_id;
523 struct drm_encoder *encoder; /* currently active encoder */ 528 struct drm_encoder *encoder; /* currently active encoder */
524 void *fb_helper_private;
525}; 529};
526 530
527/** 531/**
@@ -548,16 +552,10 @@ struct drm_mode_set {
548 552
549/** 553/**
550 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout 554 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
551 * @resize: adjust CRTCs as necessary for the proposed layout
552 *
553 * Currently only a resize hook is available. DRM will call back into the
554 * driver with a new screen width and height. If the driver can't support
555 * the proposed size, it can return false. Otherwise it should adjust
556 * the CRTC<->connector mappings as needed and update its view of the screen.
557 */ 555 */
558struct drm_mode_config_funcs { 556struct drm_mode_config_funcs {
559 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd); 557 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
560 int (*fb_changed)(struct drm_device *dev); 558 void (*output_poll_changed)(struct drm_device *dev);
561}; 559};
562 560
563struct drm_mode_group { 561struct drm_mode_group {
@@ -590,14 +588,15 @@ struct drm_mode_config {
590 588
591 struct list_head property_list; 589 struct list_head property_list;
592 590
593 /* in-kernel framebuffers - hung of filp_head in drm_framebuffer */
594 struct list_head fb_kernel_list;
595
596 int min_width, min_height; 591 int min_width, min_height;
597 int max_width, max_height; 592 int max_width, max_height;
598 struct drm_mode_config_funcs *funcs; 593 struct drm_mode_config_funcs *funcs;
599 resource_size_t fb_base; 594 resource_size_t fb_base;
600 595
596 /* output poll support */
597 bool poll_enabled;
598 struct delayed_slow_work output_poll_slow_work;
599
601 /* pointers to standard properties */ 600 /* pointers to standard properties */
602 struct list_head property_blob_list; 601 struct list_head property_blob_list;
603 struct drm_property *edid_property; 602 struct drm_property *edid_property;
@@ -666,8 +665,6 @@ extern void drm_fb_release(struct drm_file *file_priv);
666extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group); 665extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
667extern struct edid *drm_get_edid(struct drm_connector *connector, 666extern struct edid *drm_get_edid(struct drm_connector *connector,
668 struct i2c_adapter *adapter); 667 struct i2c_adapter *adapter);
669extern int drm_do_probe_ddc_edid(struct i2c_adapter *adapter,
670 unsigned char *buf, int len);
671extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); 668extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
672extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); 669extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
673extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode); 670extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode);
@@ -799,8 +796,14 @@ extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
799extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev, 796extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
800 int hdisplay, int vdisplay, int vrefresh, 797 int hdisplay, int vdisplay, int vrefresh,
801 bool interlaced, int margins); 798 bool interlaced, int margins);
799extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
800 int hdisplay, int vdisplay, int vrefresh,
801 bool interlaced, int margins, int GTF_M,
802 int GTF_2C, int GTF_K, int GTF_2J);
802extern int drm_add_modes_noedid(struct drm_connector *connector, 803extern int drm_add_modes_noedid(struct drm_connector *connector,
803 int hdisplay, int vdisplay); 804 int hdisplay, int vdisplay);
804 805
805extern bool drm_edid_is_valid(struct edid *edid); 806extern bool drm_edid_is_valid(struct edid *edid);
807struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
808 int hsize, int vsize, int fresh);
806#endif /* __DRM_CRTC_H__ */ 809#endif /* __DRM_CRTC_H__ */
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index b29e20168b5f..dc5873c21e45 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -39,7 +39,6 @@
39 39
40#include <linux/fb.h> 40#include <linux/fb.h>
41 41
42#include "drm_fb_helper.h"
43struct drm_crtc_helper_funcs { 42struct drm_crtc_helper_funcs {
44 /* 43 /*
45 * Control power levels on the CRTC. If the mode passed in is 44 * Control power levels on the CRTC. If the mode passed in is
@@ -96,8 +95,6 @@ struct drm_connector_helper_funcs {
96 95
97extern int drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY); 96extern int drm_helper_probe_single_connector_modes(struct drm_connector *connector, uint32_t maxX, uint32_t maxY);
98extern void drm_helper_disable_unused_functions(struct drm_device *dev); 97extern void drm_helper_disable_unused_functions(struct drm_device *dev);
99extern int drm_helper_hotplug_stage_two(struct drm_device *dev);
100extern bool drm_helper_initial_config(struct drm_device *dev);
101extern int drm_crtc_helper_set_config(struct drm_mode_set *set); 98extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
102extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, 99extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
103 struct drm_display_mode *mode, 100 struct drm_display_mode *mode,
@@ -123,12 +120,14 @@ static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
123 encoder->helper_private = (void *)funcs; 120 encoder->helper_private = (void *)funcs;
124} 121}
125 122
126static inline int drm_connector_helper_add(struct drm_connector *connector, 123static inline void drm_connector_helper_add(struct drm_connector *connector,
127 const struct drm_connector_helper_funcs *funcs) 124 const struct drm_connector_helper_funcs *funcs)
128{ 125{
129 connector->helper_private = (void *)funcs; 126 connector->helper_private = (void *)funcs;
130 return drm_fb_helper_add_connector(connector);
131} 127}
132 128
133extern int drm_helper_resume_force_mode(struct drm_device *dev); 129extern int drm_helper_resume_force_mode(struct drm_device *dev);
130extern void drm_kms_helper_poll_init(struct drm_device *dev);
131extern void drm_kms_helper_poll_fini(struct drm_device *dev);
132extern void drm_helper_hpd_irq_event(struct drm_device *dev);
134#endif 133#endif
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index b4209898f115..39e2cc5c7e66 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -120,7 +120,7 @@ struct detailed_non_pixel {
120 struct detailed_data_string str; 120 struct detailed_data_string str;
121 struct detailed_data_monitor_range range; 121 struct detailed_data_monitor_range range;
122 struct detailed_data_wpindex color; 122 struct detailed_data_wpindex color;
123 struct std_timing timings[5]; 123 struct std_timing timings[6];
124 struct cvt_timing cvt[4]; 124 struct cvt_timing cvt[4];
125 } data; 125 } data;
126} __attribute__((packed)); 126} __attribute__((packed));
@@ -201,7 +201,4 @@ struct edid {
201 201
202#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) 202#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
203 203
204/* define the number of Extension EDID block */
205#define DRM_MAX_EDID_EXT_NUM 4
206
207#endif /* __DRM_EDID_H__ */ 204#endif /* __DRM_EDID_H__ */
diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h
index 58c892a2cbfa..f0a6afc47e76 100644
--- a/include/drm/drm_fb_helper.h
+++ b/include/drm/drm_fb_helper.h
@@ -30,17 +30,12 @@
30#ifndef DRM_FB_HELPER_H 30#ifndef DRM_FB_HELPER_H
31#define DRM_FB_HELPER_H 31#define DRM_FB_HELPER_H
32 32
33struct drm_fb_helper;
34
33struct drm_fb_helper_crtc { 35struct drm_fb_helper_crtc {
34 uint32_t crtc_id; 36 uint32_t crtc_id;
35 struct drm_mode_set mode_set; 37 struct drm_mode_set mode_set;
36}; 38 struct drm_display_mode *desired_mode;
37
38
39struct drm_fb_helper_funcs {
40 void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
41 u16 blue, int regno);
42 void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
43 u16 *blue, int regno);
44}; 39};
45 40
46/* mode specified on the command line */ 41/* mode specified on the command line */
@@ -57,8 +52,28 @@ struct drm_fb_helper_cmdline_mode {
57 bool margins; 52 bool margins;
58}; 53};
59 54
55struct drm_fb_helper_surface_size {
56 u32 fb_width;
57 u32 fb_height;
58 u32 surface_width;
59 u32 surface_height;
60 u32 surface_bpp;
61 u32 surface_depth;
62};
63
64struct drm_fb_helper_funcs {
65 void (*gamma_set)(struct drm_crtc *crtc, u16 red, u16 green,
66 u16 blue, int regno);
67 void (*gamma_get)(struct drm_crtc *crtc, u16 *red, u16 *green,
68 u16 *blue, int regno);
69
70 int (*fb_probe)(struct drm_fb_helper *helper,
71 struct drm_fb_helper_surface_size *sizes);
72};
73
60struct drm_fb_helper_connector { 74struct drm_fb_helper_connector {
61 struct drm_fb_helper_cmdline_mode cmdline_mode; 75 struct drm_fb_helper_cmdline_mode cmdline_mode;
76 struct drm_connector *connector;
62}; 77};
63 78
64struct drm_fb_helper { 79struct drm_fb_helper {
@@ -67,24 +82,26 @@ struct drm_fb_helper {
67 struct drm_display_mode *mode; 82 struct drm_display_mode *mode;
68 int crtc_count; 83 int crtc_count;
69 struct drm_fb_helper_crtc *crtc_info; 84 struct drm_fb_helper_crtc *crtc_info;
85 int connector_count;
86 struct drm_fb_helper_connector **connector_info;
70 struct drm_fb_helper_funcs *funcs; 87 struct drm_fb_helper_funcs *funcs;
71 int conn_limit; 88 int conn_limit;
89 struct fb_info *fbdev;
90 u32 pseudo_palette[17];
72 struct list_head kernel_fb_list; 91 struct list_head kernel_fb_list;
92
93 /* we got a hotplug but fbdev wasn't running the console
94 delay until next set_par */
95 bool delayed_hotplug;
73}; 96};
74 97
75int drm_fb_helper_single_fb_probe(struct drm_device *dev, 98int drm_fb_helper_single_fb_probe(struct drm_fb_helper *helper,
76 int preferred_bpp, 99 int preferred_bpp);
77 int (*fb_create)(struct drm_device *dev, 100
78 uint32_t fb_width, 101int drm_fb_helper_init(struct drm_device *dev,
79 uint32_t fb_height, 102 struct drm_fb_helper *helper, int crtc_count,
80 uint32_t surface_width, 103 int max_conn);
81 uint32_t surface_height, 104void drm_fb_helper_fini(struct drm_fb_helper *helper);
82 uint32_t surface_depth,
83 uint32_t surface_bpp,
84 struct drm_framebuffer **fb_ptr));
85int drm_fb_helper_init_crtc_count(struct drm_fb_helper *helper, int crtc_count,
86 int max_conn);
87void drm_fb_helper_free(struct drm_fb_helper *helper);
88int drm_fb_helper_blank(int blank, struct fb_info *info); 105int drm_fb_helper_blank(int blank, struct fb_info *info);
89int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, 106int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
90 struct fb_info *info); 107 struct fb_info *info);
@@ -99,13 +116,15 @@ int drm_fb_helper_setcolreg(unsigned regno,
99 struct fb_info *info); 116 struct fb_info *info);
100 117
101void drm_fb_helper_restore(void); 118void drm_fb_helper_restore(void);
102void drm_fb_helper_fill_var(struct fb_info *info, struct drm_framebuffer *fb, 119void drm_fb_helper_fill_var(struct fb_info *info, struct drm_fb_helper *fb_helper,
103 uint32_t fb_width, uint32_t fb_height); 120 uint32_t fb_width, uint32_t fb_height);
104void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch, 121void drm_fb_helper_fill_fix(struct fb_info *info, uint32_t pitch,
105 uint32_t depth); 122 uint32_t depth);
106 123
107int drm_fb_helper_add_connector(struct drm_connector *connector);
108int drm_fb_helper_parse_command_line(struct drm_device *dev);
109int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info); 124int drm_fb_helper_setcmap(struct fb_cmap *cmap, struct fb_info *info);
110 125
126bool drm_fb_helper_hotplug_event(struct drm_fb_helper *fb_helper);
127bool drm_fb_helper_initial_config(struct drm_fb_helper *fb_helper, int bpp_sel);
128int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper);
129
111#endif 130#endif
diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h
new file mode 100644
index 000000000000..4a08a664ff1f
--- /dev/null
+++ b/include/drm/drm_fixed.h
@@ -0,0 +1,67 @@
1/*
2 * Copyright 2009 Red Hat Inc.
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 shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Dave Airlie
23 */
24#ifndef DRM_FIXED_H
25#define DRM_FIXED_H
26
27typedef union dfixed {
28 u32 full;
29} fixed20_12;
30
31
32#define dfixed_const(A) (u32)(((A) << 12))/* + ((B + 0.000122)*4096)) */
33#define dfixed_const_half(A) (u32)(((A) << 12) + 2048)
34#define dfixed_const_666(A) (u32)(((A) << 12) + 2731)
35#define dfixed_const_8(A) (u32)(((A) << 12) + 3277)
36#define dfixed_mul(A, B) ((u64)((u64)(A).full * (B).full + 2048) >> 12)
37#define dfixed_init(A) { .full = dfixed_const((A)) }
38#define dfixed_init_half(A) { .full = dfixed_const_half((A)) }
39#define dfixed_trunc(A) ((A).full >> 12)
40
41static inline u32 dfixed_floor(fixed20_12 A)
42{
43 u32 non_frac = dfixed_trunc(A);
44
45 return dfixed_const(non_frac);
46}
47
48static inline u32 dfixed_ceil(fixed20_12 A)
49{
50 u32 non_frac = dfixed_trunc(A);
51
52 if (A.full > dfixed_const(non_frac))
53 return dfixed_const(non_frac + 1);
54 else
55 return dfixed_const(non_frac);
56}
57
58static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B)
59{
60 u64 tmp = ((u64)A.full << 13);
61
62 do_div(tmp, B.full);
63 tmp += 1;
64 tmp /= 2;
65 return lower_32_bits(tmp);
66}
67#endif
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h
index 81e614bf2dc3..3ff9fc071dfe 100644
--- a/include/drm/radeon_drm.h
+++ b/include/drm/radeon_drm.h
@@ -902,6 +902,7 @@ struct drm_radeon_cs {
902#define RADEON_INFO_NUM_GB_PIPES 0x01 902#define RADEON_INFO_NUM_GB_PIPES 0x01
903#define RADEON_INFO_NUM_Z_PIPES 0x02 903#define RADEON_INFO_NUM_Z_PIPES 0x02
904#define RADEON_INFO_ACCEL_WORKING 0x03 904#define RADEON_INFO_ACCEL_WORKING 0x03
905#define RADEON_INFO_CRTC_FROM_ID 0x04
905 906
906struct drm_radeon_info { 907struct drm_radeon_info {
907 uint32_t request; 908 uint32_t request;
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 81eb9f45883c..267a86c74e2e 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -66,6 +66,26 @@ struct ttm_placement {
66 const uint32_t *busy_placement; 66 const uint32_t *busy_placement;
67}; 67};
68 68
69/**
70 * struct ttm_bus_placement
71 *
72 * @addr: mapped virtual address
73 * @base: bus base address
74 * @is_iomem: is this io memory ?
75 * @size: size in byte
76 * @offset: offset from the base address
77 *
78 * Structure indicating the bus placement of an object.
79 */
80struct ttm_bus_placement {
81 void *addr;
82 unsigned long base;
83 unsigned long size;
84 unsigned long offset;
85 bool is_iomem;
86 bool io_reserved;
87};
88
69 89
70/** 90/**
71 * struct ttm_mem_reg 91 * struct ttm_mem_reg
@@ -75,6 +95,7 @@ struct ttm_placement {
75 * @num_pages: Actual size of memory region in pages. 95 * @num_pages: Actual size of memory region in pages.
76 * @page_alignment: Page alignment. 96 * @page_alignment: Page alignment.
77 * @placement: Placement flags. 97 * @placement: Placement flags.
98 * @bus: Placement on io bus accessible to the CPU
78 * 99 *
79 * Structure indicating the placement and space resources used by a 100 * Structure indicating the placement and space resources used by a
80 * buffer object. 101 * buffer object.
@@ -87,6 +108,7 @@ struct ttm_mem_reg {
87 uint32_t page_alignment; 108 uint32_t page_alignment;
88 uint32_t mem_type; 109 uint32_t mem_type;
89 uint32_t placement; 110 uint32_t placement;
111 struct ttm_bus_placement bus;
90}; 112};
91 113
92/** 114/**
@@ -274,6 +296,7 @@ struct ttm_bo_kmap_obj {
274 ttm_bo_map_kmap = 3, 296 ttm_bo_map_kmap = 3,
275 ttm_bo_map_premapped = 4 | TTM_BO_MAP_IOMEM_MASK, 297 ttm_bo_map_premapped = 4 | TTM_BO_MAP_IOMEM_MASK,
276 } bo_kmap_type; 298 } bo_kmap_type;
299 struct ttm_buffer_object *bo;
277}; 300};
278 301
279/** 302/**
@@ -313,7 +336,8 @@ extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
313 * @bo: The buffer object. 336 * @bo: The buffer object.
314 * @placement: Proposed placement for the buffer object. 337 * @placement: Proposed placement for the buffer object.
315 * @interruptible: Sleep interruptible if sleeping. 338 * @interruptible: Sleep interruptible if sleeping.
316 * @no_wait: Return immediately if the buffer is busy. 339 * @no_wait_reserve: Return immediately if other buffers are busy.
340 * @no_wait_gpu: Return immediately if the GPU is busy.
317 * 341 *
318 * Changes placement and caching policy of the buffer object 342 * Changes placement and caching policy of the buffer object
319 * according proposed placement. 343 * according proposed placement.
@@ -325,7 +349,8 @@ extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
325 */ 349 */
326extern int ttm_bo_validate(struct ttm_buffer_object *bo, 350extern int ttm_bo_validate(struct ttm_buffer_object *bo,
327 struct ttm_placement *placement, 351 struct ttm_placement *placement,
328 bool interruptible, bool no_wait); 352 bool interruptible, bool no_wait_reserve,
353 bool no_wait_gpu);
329 354
330/** 355/**
331 * ttm_bo_unref 356 * ttm_bo_unref
@@ -337,6 +362,23 @@ extern int ttm_bo_validate(struct ttm_buffer_object *bo,
337extern void ttm_bo_unref(struct ttm_buffer_object **bo); 362extern void ttm_bo_unref(struct ttm_buffer_object **bo);
338 363
339/** 364/**
365 * ttm_bo_lock_delayed_workqueue
366 *
367 * Prevent the delayed workqueue from running.
368 * Returns
369 * True if the workqueue was queued at the time
370 */
371extern int ttm_bo_lock_delayed_workqueue(struct ttm_bo_device *bdev);
372
373/**
374 * ttm_bo_unlock_delayed_workqueue
375 *
376 * Allows the delayed workqueue to run.
377 */
378extern void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev,
379 int resched);
380
381/**
340 * ttm_bo_synccpu_write_grab 382 * ttm_bo_synccpu_write_grab
341 * 383 *
342 * @bo: The buffer object: 384 * @bo: The buffer object:
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 6b9db917e717..0ea602da43e7 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -176,8 +176,6 @@ struct ttm_tt {
176 176
177#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */ 177#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */
178#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */ 178#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */
179#define TTM_MEMTYPE_FLAG_NEEDS_IOREMAP (1 << 2) /* Fixed memory needs ioremap
180 before kernel access. */
181#define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */ 179#define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */
182 180
183/** 181/**
@@ -189,13 +187,6 @@ struct ttm_tt {
189 * managed by this memory type. 187 * managed by this memory type.
190 * @gpu_offset: If used, the GPU offset of the first managed page of 188 * @gpu_offset: If used, the GPU offset of the first managed page of
191 * fixed memory or the first managed location in an aperture. 189 * fixed memory or the first managed location in an aperture.
192 * @io_offset: The io_offset of the first managed page of IO memory or
193 * the first managed location in an aperture. For TTM_MEMTYPE_FLAG_CMA
194 * memory, this should be set to NULL.
195 * @io_size: The size of a managed IO region (fixed memory or aperture).
196 * @io_addr: Virtual kernel address if the io region is pre-mapped. For
197 * TTM_MEMTYPE_FLAG_NEEDS_IOREMAP there is no pre-mapped io map and
198 * @io_addr should be set to NULL.
199 * @size: Size of the managed region. 190 * @size: Size of the managed region.
200 * @available_caching: A mask of available caching types, TTM_PL_FLAG_XX, 191 * @available_caching: A mask of available caching types, TTM_PL_FLAG_XX,
201 * as defined in ttm_placement_common.h 192 * as defined in ttm_placement_common.h
@@ -221,9 +212,6 @@ struct ttm_mem_type_manager {
221 bool use_type; 212 bool use_type;
222 uint32_t flags; 213 uint32_t flags;
223 unsigned long gpu_offset; 214 unsigned long gpu_offset;
224 unsigned long io_offset;
225 unsigned long io_size;
226 void *io_addr;
227 uint64_t size; 215 uint64_t size;
228 uint32_t available_caching; 216 uint32_t available_caching;
229 uint32_t default_caching; 217 uint32_t default_caching;
@@ -311,7 +299,8 @@ struct ttm_bo_driver {
311 */ 299 */
312 int (*move) (struct ttm_buffer_object *bo, 300 int (*move) (struct ttm_buffer_object *bo,
313 bool evict, bool interruptible, 301 bool evict, bool interruptible,
314 bool no_wait, struct ttm_mem_reg *new_mem); 302 bool no_wait_reserve, bool no_wait_gpu,
303 struct ttm_mem_reg *new_mem);
315 304
316 /** 305 /**
317 * struct ttm_bo_driver_member verify_access 306 * struct ttm_bo_driver_member verify_access
@@ -351,12 +340,21 @@ struct ttm_bo_driver {
351 struct ttm_mem_reg *new_mem); 340 struct ttm_mem_reg *new_mem);
352 /* notify the driver we are taking a fault on this BO 341 /* notify the driver we are taking a fault on this BO
353 * and have reserved it */ 342 * and have reserved it */
354 void (*fault_reserve_notify)(struct ttm_buffer_object *bo); 343 int (*fault_reserve_notify)(struct ttm_buffer_object *bo);
355 344
356 /** 345 /**
357 * notify the driver that we're about to swap out this bo 346 * notify the driver that we're about to swap out this bo
358 */ 347 */
359 void (*swap_notify) (struct ttm_buffer_object *bo); 348 void (*swap_notify) (struct ttm_buffer_object *bo);
349
350 /**
351 * Driver callback on when mapping io memory (for bo_move_memcpy
352 * for instance). TTM will take care to call io_mem_free whenever
353 * the mapping is not use anymore. io_mem_reserve & io_mem_free
354 * are balanced.
355 */
356 int (*io_mem_reserve)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
357 void (*io_mem_free)(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
360}; 358};
361 359
362/** 360/**
@@ -633,7 +631,8 @@ extern bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev,
633 * @proposed_placement: Proposed new placement for the buffer object. 631 * @proposed_placement: Proposed new placement for the buffer object.
634 * @mem: A struct ttm_mem_reg. 632 * @mem: A struct ttm_mem_reg.
635 * @interruptible: Sleep interruptible when sliping. 633 * @interruptible: Sleep interruptible when sliping.
636 * @no_wait: Don't sleep waiting for space to become available. 634 * @no_wait_reserve: Return immediately if other buffers are busy.
635 * @no_wait_gpu: Return immediately if the GPU is busy.
637 * 636 *
638 * Allocate memory space for the buffer object pointed to by @bo, using 637 * Allocate memory space for the buffer object pointed to by @bo, using
639 * the placement flags in @mem, potentially evicting other idle buffer objects. 638 * the placement flags in @mem, potentially evicting other idle buffer objects.
@@ -647,7 +646,8 @@ extern bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev,
647extern int ttm_bo_mem_space(struct ttm_buffer_object *bo, 646extern int ttm_bo_mem_space(struct ttm_buffer_object *bo,
648 struct ttm_placement *placement, 647 struct ttm_placement *placement,
649 struct ttm_mem_reg *mem, 648 struct ttm_mem_reg *mem,
650 bool interruptible, bool no_wait); 649 bool interruptible,
650 bool no_wait_reserve, bool no_wait_gpu);
651/** 651/**
652 * ttm_bo_wait_for_cpu 652 * ttm_bo_wait_for_cpu
653 * 653 *
@@ -682,6 +682,11 @@ extern int ttm_bo_pci_offset(struct ttm_bo_device *bdev,
682 unsigned long *bus_offset, 682 unsigned long *bus_offset,
683 unsigned long *bus_size); 683 unsigned long *bus_size);
684 684
685extern int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
686 struct ttm_mem_reg *mem);
687extern void ttm_mem_io_free(struct ttm_bo_device *bdev,
688 struct ttm_mem_reg *mem);
689
685extern void ttm_bo_global_release(struct ttm_global_reference *ref); 690extern void ttm_bo_global_release(struct ttm_global_reference *ref);
686extern int ttm_bo_global_init(struct ttm_global_reference *ref); 691extern int ttm_bo_global_init(struct ttm_global_reference *ref);
687 692
@@ -798,7 +803,8 @@ extern int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo,
798 * 803 *
799 * @bo: A pointer to a struct ttm_buffer_object. 804 * @bo: A pointer to a struct ttm_buffer_object.
800 * @evict: 1: This is an eviction. Don't try to pipeline. 805 * @evict: 1: This is an eviction. Don't try to pipeline.
801 * @no_wait: Never sleep, but rather return with -EBUSY. 806 * @no_wait_reserve: Return immediately if other buffers are busy.
807 * @no_wait_gpu: Return immediately if the GPU is busy.
802 * @new_mem: struct ttm_mem_reg indicating where to move. 808 * @new_mem: struct ttm_mem_reg indicating where to move.
803 * 809 *
804 * Optimized move function for a buffer object with both old and 810 * Optimized move function for a buffer object with both old and
@@ -812,15 +818,16 @@ extern int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo,
812 */ 818 */
813 819
814extern int ttm_bo_move_ttm(struct ttm_buffer_object *bo, 820extern int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
815 bool evict, bool no_wait, 821 bool evict, bool no_wait_reserve,
816 struct ttm_mem_reg *new_mem); 822 bool no_wait_gpu, struct ttm_mem_reg *new_mem);
817 823
818/** 824/**
819 * ttm_bo_move_memcpy 825 * ttm_bo_move_memcpy
820 * 826 *
821 * @bo: A pointer to a struct ttm_buffer_object. 827 * @bo: A pointer to a struct ttm_buffer_object.
822 * @evict: 1: This is an eviction. Don't try to pipeline. 828 * @evict: 1: This is an eviction. Don't try to pipeline.
823 * @no_wait: Never sleep, but rather return with -EBUSY. 829 * @no_wait_reserve: Return immediately if other buffers are busy.
830 * @no_wait_gpu: Return immediately if the GPU is busy.
824 * @new_mem: struct ttm_mem_reg indicating where to move. 831 * @new_mem: struct ttm_mem_reg indicating where to move.
825 * 832 *
826 * Fallback move function for a mappable buffer object in mappable memory. 833 * Fallback move function for a mappable buffer object in mappable memory.
@@ -834,8 +841,8 @@ extern int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
834 */ 841 */
835 842
836extern int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, 843extern int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
837 bool evict, 844 bool evict, bool no_wait_reserve,
838 bool no_wait, struct ttm_mem_reg *new_mem); 845 bool no_wait_gpu, struct ttm_mem_reg *new_mem);
839 846
840/** 847/**
841 * ttm_bo_free_old_node 848 * ttm_bo_free_old_node
@@ -854,7 +861,8 @@ extern void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
854 * @sync_obj_arg: An argument to pass to the sync object idle / wait 861 * @sync_obj_arg: An argument to pass to the sync object idle / wait
855 * functions. 862 * functions.
856 * @evict: This is an evict move. Don't return until the buffer is idle. 863 * @evict: This is an evict move. Don't return until the buffer is idle.
857 * @no_wait: Never sleep, but rather return with -EBUSY. 864 * @no_wait_reserve: Return immediately if other buffers are busy.
865 * @no_wait_gpu: Return immediately if the GPU is busy.
858 * @new_mem: struct ttm_mem_reg indicating where to move. 866 * @new_mem: struct ttm_mem_reg indicating where to move.
859 * 867 *
860 * Accelerated move function to be called when an accelerated move 868 * Accelerated move function to be called when an accelerated move
@@ -868,7 +876,8 @@ extern void ttm_bo_free_old_node(struct ttm_buffer_object *bo);
868extern int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, 876extern int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
869 void *sync_obj, 877 void *sync_obj,
870 void *sync_obj_arg, 878 void *sync_obj_arg,
871 bool evict, bool no_wait, 879 bool evict, bool no_wait_reserve,
880 bool no_wait_gpu,
872 struct ttm_mem_reg *new_mem); 881 struct ttm_mem_reg *new_mem);
873/** 882/**
874 * ttm_io_prot 883 * ttm_io_prot
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
new file mode 100644
index 000000000000..8bb4de567b2c
--- /dev/null
+++ b/include/drm/ttm/ttm_page_alloc.h
@@ -0,0 +1,74 @@
1/*
2 * Copyright (c) Red Hat Inc.
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, sub license,
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
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors: Dave Airlie <airlied@redhat.com>
24 * Jerome Glisse <jglisse@redhat.com>
25 */
26#ifndef TTM_PAGE_ALLOC
27#define TTM_PAGE_ALLOC
28
29#include "ttm_bo_driver.h"
30#include "ttm_memory.h"
31
32/**
33 * Get count number of pages from pool to pages list.
34 *
35 * @pages: heado of empty linked list where pages are filled.
36 * @flags: ttm flags for page allocation.
37 * @cstate: ttm caching state for the page.
38 * @count: number of pages to allocate.
39 */
40int ttm_get_pages(struct list_head *pages,
41 int flags,
42 enum ttm_caching_state cstate,
43 unsigned count);
44/**
45 * Put linked list of pages to pool.
46 *
47 * @pages: list of pages to free.
48 * @page_count: number of pages in the list. Zero can be passed for unknown
49 * count.
50 * @flags: ttm flags for page allocation.
51 * @cstate: ttm caching state.
52 */
53void ttm_put_pages(struct list_head *pages,
54 unsigned page_count,
55 int flags,
56 enum ttm_caching_state cstate);
57/**
58 * Initialize pool allocator.
59 *
60 * Pool allocator is internaly reference counted so it can be initialized
61 * multiple times but ttm_page_alloc_fini has to be called same number of
62 * times.
63 */
64int ttm_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages);
65/**
66 * Free pool allocator.
67 */
68void ttm_page_alloc_fini(void);
69
70/**
71 * Output the state of pools to debugfs file
72 */
73extern int ttm_page_alloc_debugfs(struct seq_file *m, void *data);
74#endif