|
44 | 44 | #include <nvif/if0011.h>
|
45 | 45 | #include <nvif/if0013.h>
|
46 | 46 | #include <dispnv50/crc.h>
|
| 47 | +#include <dispnv50/tile.h> |
47 | 48 |
|
48 | 49 | int
|
49 | 50 | nouveau_display_vblank_enable(struct drm_crtc *crtc)
|
@@ -220,69 +221,29 @@ nouveau_validate_decode_mod(struct nouveau_drm *drm,
|
220 | 221 | return 0;
|
221 | 222 | }
|
222 | 223 |
|
223 |
| -static inline uint32_t |
224 |
| -nouveau_get_width_in_blocks(uint32_t stride) |
225 |
| -{ |
226 |
| - /* GOBs per block in the x direction is always one, and GOBs are |
227 |
| - * 64 bytes wide |
228 |
| - */ |
229 |
| - static const uint32_t log_block_width = 6; |
230 |
| - |
231 |
| - return (stride + (1 << log_block_width) - 1) >> log_block_width; |
232 |
| -} |
233 |
| - |
234 |
| -static inline uint32_t |
235 |
| -nouveau_get_height_in_blocks(struct nouveau_drm *drm, |
236 |
| - uint32_t height, |
237 |
| - uint32_t log_block_height_in_gobs) |
238 |
| -{ |
239 |
| - uint32_t log_gob_height; |
240 |
| - uint32_t log_block_height; |
241 |
| - |
242 |
| - BUG_ON(drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA); |
243 |
| - |
244 |
| - if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI) |
245 |
| - log_gob_height = 2; |
246 |
| - else |
247 |
| - log_gob_height = 3; |
248 |
| - |
249 |
| - log_block_height = log_block_height_in_gobs + log_gob_height; |
250 |
| - |
251 |
| - return (height + (1 << log_block_height) - 1) >> log_block_height; |
252 |
| -} |
253 |
| - |
254 | 224 | static int
|
255 | 225 | nouveau_check_bl_size(struct nouveau_drm *drm, struct nouveau_bo *nvbo,
|
256 | 226 | uint32_t offset, uint32_t stride, uint32_t h,
|
257 | 227 | uint32_t tile_mode)
|
258 | 228 | {
|
259 |
| - uint32_t gob_size, bw, bh; |
| 229 | + uint32_t gob_size, bw, bh, gobs_in_block; |
260 | 230 | uint64_t bl_size;
|
261 | 231 |
|
262 | 232 | BUG_ON(drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA);
|
263 | 233 |
|
264 |
| - if (drm->client.device.info.chipset >= 0xc0) { |
265 |
| - if (tile_mode & 0xF) |
266 |
| - return -EINVAL; |
267 |
| - tile_mode >>= 4; |
268 |
| - } |
269 |
| - |
270 |
| - if (tile_mode & 0xFFFFFFF0) |
| 234 | + if (nouveau_check_tile_mode(tile_mode, drm->client.device.info.chipset)) |
271 | 235 | return -EINVAL;
|
272 | 236 |
|
273 |
| - if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI) |
274 |
| - gob_size = 256; |
275 |
| - else |
276 |
| - gob_size = 512; |
277 |
| - |
| 237 | + gobs_in_block = nouveau_get_gobs_in_block(tile_mode, drm->client.device.info.chipset); |
278 | 238 | bw = nouveau_get_width_in_blocks(stride);
|
279 |
| - bh = nouveau_get_height_in_blocks(drm, h, tile_mode); |
| 239 | + bh = nouveau_get_height_in_blocks(h, gobs_in_block, drm->client.device.info.family); |
| 240 | + gob_size = nouveau_get_gob_size(drm->client.device.info.family); |
280 | 241 |
|
281 |
| - bl_size = bw * bh * (1 << tile_mode) * gob_size; |
| 242 | + bl_size = bw * bh * gobs_in_block * gob_size; |
282 | 243 |
|
283 |
| - DRM_DEBUG_KMS("offset=%u stride=%u h=%u tile_mode=0x%02x bw=%u bh=%u gob_size=%u bl_size=%llu size=%zu\n", |
284 |
| - offset, stride, h, tile_mode, bw, bh, gob_size, bl_size, |
285 |
| - nvbo->bo.base.size); |
| 244 | + DRM_DEBUG_KMS("offset=%u stride=%u h=%u gobs_in_block=%u bw=%u bh=%u gob_size=%u bl_size=%llu size=%zu\n", |
| 245 | + offset, stride, h, gobs_in_block, bw, bh, gob_size, |
| 246 | + bl_size, nvbo->bo.base.size); |
286 | 247 |
|
287 | 248 | if (bl_size + offset > nvbo->bo.base.size)
|
288 | 249 | return -ERANGE;
|
|
0 commit comments