diff options
author | Marek Olšák <maraeo@gmail.com> | 2011-01-04 23:46:48 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-01-05 22:00:45 -0500 |
commit | 9eba4a93ce520a627e876b0d1851d4f78a701c2b (patch) | |
tree | a0dbb86c2105b4ff89af724b835d0c40fbf59368 | |
parent | 2f299d5de02da3ffb1f9e1a05c91dcd1173ebd3c (diff) |
drm/radeon/kms: manage r300 CMASK RAM access and allow CMASK clear
The CMASK RAM is for colorbuffer compression (used in conjunction
with MSAA). Only one user (filp) can access it.
The CMASK RAM access is managed in the same way as Hyper-Z, but there is
a separate ioctl, because an app that uses MSAA does not necessarily
have to use zbuffering.
Signed-off-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/radeon/r300.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r300d.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_drv.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_kms.c | 39 | ||||
-rw-r--r-- | include/drm/radeon_drm.h | 1 |
6 files changed, 41 insertions, 14 deletions
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c index 36b4f7b48d6a..23fee54c3b75 100644 --- a/drivers/gpu/drm/radeon/r300.c +++ b/drivers/gpu/drm/radeon/r300.c | |||
@@ -745,6 +745,11 @@ static int r300_packet0_check(struct radeon_cs_parser *p, | |||
745 | break; | 745 | break; |
746 | case 0x4E00: | 746 | case 0x4E00: |
747 | /* RB3D_CCTL */ | 747 | /* RB3D_CCTL */ |
748 | if ((idx_value & (1 << 10)) && /* CMASK_ENABLE */ | ||
749 | p->rdev->cmask_filp != p->filp) { | ||
750 | DRM_ERROR("Invalid RB3D_CCTL: Cannot enable CMASK.\n"); | ||
751 | return -EINVAL; | ||
752 | } | ||
748 | track->num_cb = ((idx_value >> 5) & 0x3) + 1; | 753 | track->num_cb = ((idx_value >> 5) & 0x3) + 1; |
749 | break; | 754 | break; |
750 | case 0x4E38: | 755 | case 0x4E38: |
@@ -1206,6 +1211,10 @@ static int r300_packet3_check(struct radeon_cs_parser *p, | |||
1206 | if (p->rdev->hyperz_filp != p->filp) | 1211 | if (p->rdev->hyperz_filp != p->filp) |
1207 | return -EINVAL; | 1212 | return -EINVAL; |
1208 | break; | 1213 | break; |
1214 | case PACKET3_3D_CLEAR_CMASK: | ||
1215 | if (p->rdev->cmask_filp != p->filp) | ||
1216 | return -EINVAL; | ||
1217 | break; | ||
1209 | case PACKET3_NOP: | 1218 | case PACKET3_NOP: |
1210 | break; | 1219 | break; |
1211 | default: | 1220 | default: |
diff --git a/drivers/gpu/drm/radeon/r300d.h b/drivers/gpu/drm/radeon/r300d.h index 0c036c60d9df..1f519a5ffb8c 100644 --- a/drivers/gpu/drm/radeon/r300d.h +++ b/drivers/gpu/drm/radeon/r300d.h | |||
@@ -54,6 +54,7 @@ | |||
54 | #define PACKET3_3D_DRAW_IMMD_2 0x35 | 54 | #define PACKET3_3D_DRAW_IMMD_2 0x35 |
55 | #define PACKET3_3D_DRAW_INDX_2 0x36 | 55 | #define PACKET3_3D_DRAW_INDX_2 0x36 |
56 | #define PACKET3_3D_CLEAR_HIZ 0x37 | 56 | #define PACKET3_3D_CLEAR_HIZ 0x37 |
57 | #define PACKET3_3D_CLEAR_CMASK 0x38 | ||
57 | #define PACKET3_BITBLT_MULTI 0x9B | 58 | #define PACKET3_BITBLT_MULTI 0x9B |
58 | 59 | ||
59 | #define PACKET0(reg, n) (CP_PACKET0 | \ | 60 | #define PACKET0(reg, n) (CP_PACKET0 | \ |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 140eaceab279..a835d95021d1 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -1168,8 +1168,9 @@ struct radeon_device { | |||
1168 | uint8_t audio_category_code; | 1168 | uint8_t audio_category_code; |
1169 | 1169 | ||
1170 | struct notifier_block acpi_nb; | 1170 | struct notifier_block acpi_nb; |
1171 | /* only one userspace can use Hyperz features at a time */ | 1171 | /* only one userspace can use Hyperz features or CMASK at a time */ |
1172 | struct drm_file *hyperz_filp; | 1172 | struct drm_file *hyperz_filp; |
1173 | struct drm_file *cmask_filp; | ||
1173 | /* i2c buses */ | 1174 | /* i2c buses */ |
1174 | struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS]; | 1175 | struct radeon_i2c_chan *i2c_bus[RADEON_MAX_I2C_BUS]; |
1175 | }; | 1176 | }; |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 18225f21ee0f..be5cb4f28c29 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
@@ -48,7 +48,7 @@ | |||
48 | * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen | 48 | * - 2.5.0 - add get accel 2 to work around ddx breakage for evergreen |
49 | * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500) | 49 | * - 2.6.0 - add tiling config query (r6xx+), add initial HiZ support (r300->r500) |
50 | * 2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs | 50 | * 2.7.0 - fixups for r600 2D tiling support. (no external ABI change), add eg dyn gpr regs |
51 | * 2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf | 51 | * 2.8.0 - pageflip support, r500 US_FORMAT regs. r500 ARGB2101010 colorbuf, r300->r500 CMASK |
52 | */ | 52 | */ |
53 | #define KMS_DRIVER_MAJOR 2 | 53 | #define KMS_DRIVER_MAJOR 2 |
54 | #define KMS_DRIVER_MINOR 8 | 54 | #define KMS_DRIVER_MINOR 8 |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index b2686334d46b..28a53e4a925f 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -96,9 +96,27 @@ out: | |||
96 | return r; | 96 | return r; |
97 | } | 97 | } |
98 | 98 | ||
99 | static void radeon_set_filp_rights(struct drm_device *dev, | ||
100 | struct drm_file **owner, | ||
101 | struct drm_file *applier, | ||
102 | uint32_t *value) | ||
103 | { | ||
104 | mutex_lock(&dev->struct_mutex); | ||
105 | if (*value == 1) { | ||
106 | /* wants rights */ | ||
107 | if (!*owner) | ||
108 | *owner = applier; | ||
109 | } else if (*value == 0) { | ||
110 | /* revokes rights */ | ||
111 | if (*owner == applier) | ||
112 | *owner = NULL; | ||
113 | } | ||
114 | *value = *owner == applier ? 1 : 0; | ||
115 | mutex_unlock(&dev->struct_mutex); | ||
116 | } | ||
99 | 117 | ||
100 | /* | 118 | /* |
101 | * Userspace get informations ioctl | 119 | * Userspace get information ioctl |
102 | */ | 120 | */ |
103 | int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | 121 | int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |
104 | { | 122 | { |
@@ -173,18 +191,15 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
173 | DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value); | 191 | DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value); |
174 | return -EINVAL; | 192 | return -EINVAL; |
175 | } | 193 | } |
176 | mutex_lock(&dev->struct_mutex); | 194 | radeon_set_filp_rights(dev, &rdev->hyperz_filp, filp, &value); |
177 | if (value == 1) { | 195 | break; |
178 | /* wants hyper-z */ | 196 | case RADEON_INFO_WANT_CMASK: |
179 | if (!rdev->hyperz_filp) | 197 | /* The same logic as Hyper-Z. */ |
180 | rdev->hyperz_filp = filp; | 198 | if (value >= 2) { |
181 | } else if (value == 0) { | 199 | DRM_DEBUG_KMS("WANT_CMASK: invalid value %d\n", value); |
182 | /* revokes hyper-z */ | 200 | return -EINVAL; |
183 | if (rdev->hyperz_filp == filp) | ||
184 | rdev->hyperz_filp = NULL; | ||
185 | } | 201 | } |
186 | value = rdev->hyperz_filp == filp ? 1 : 0; | 202 | radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value); |
187 | mutex_unlock(&dev->struct_mutex); | ||
188 | break; | 203 | break; |
189 | default: | 204 | default: |
190 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); | 205 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h index 10f8b53bdd40..e95a86b8b689 100644 --- a/include/drm/radeon_drm.h +++ b/include/drm/radeon_drm.h | |||
@@ -906,6 +906,7 @@ struct drm_radeon_cs { | |||
906 | #define RADEON_INFO_ACCEL_WORKING2 0x05 | 906 | #define RADEON_INFO_ACCEL_WORKING2 0x05 |
907 | #define RADEON_INFO_TILING_CONFIG 0x06 | 907 | #define RADEON_INFO_TILING_CONFIG 0x06 |
908 | #define RADEON_INFO_WANT_HYPERZ 0x07 | 908 | #define RADEON_INFO_WANT_HYPERZ 0x07 |
909 | #define RADEON_INFO_WANT_CMASK 0x08 /* get access to CMASK on r300 */ | ||
909 | 910 | ||
910 | struct drm_radeon_info { | 911 | struct drm_radeon_info { |
911 | uint32_t request; | 912 | uint32_t request; |