overlay.c (db2bec187dd68e79d512112df1f6e7a849e7f0ce) overlay.c (967e7bde8739fe3b215f7537e8f1f39c044902af)
1/*
2 * Copyright 2013 Ilia Mirkin
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

--- 82 unchanged lines hidden (view full) ---

91
92static int
93nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
94 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
95 unsigned int crtc_w, unsigned int crtc_h,
96 uint32_t src_x, uint32_t src_y,
97 uint32_t src_w, uint32_t src_h)
98{
1/*
2 * Copyright 2013 Ilia Mirkin
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

--- 82 unchanged lines hidden (view full) ---

91
92static int
93nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
94 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
95 unsigned int crtc_w, unsigned int crtc_h,
96 uint32_t src_x, uint32_t src_y,
97 uint32_t src_w, uint32_t src_h)
98{
99 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
99 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
100 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
101 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
102 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
103 struct nouveau_bo *cur = nv_plane->cur;
104 bool flip = nv_plane->flip;
105 int soff = NV_PCRTC0_SIZE * nv_crtc->index;
106 int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index;
107 int format, ret;

--- 4 unchanged lines hidden (view full) ---

112 src_w >>= 16;
113 src_h >>= 16;
114
115 format = ALIGN(src_w * 4, 0x100);
116
117 if (format > 0xffff)
118 return -ERANGE;
119
100 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
101 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
102 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
103 struct nouveau_bo *cur = nv_plane->cur;
104 bool flip = nv_plane->flip;
105 int soff = NV_PCRTC0_SIZE * nv_crtc->index;
106 int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index;
107 int format, ret;

--- 4 unchanged lines hidden (view full) ---

112 src_w >>= 16;
113 src_h >>= 16;
114
115 format = ALIGN(src_w * 4, 0x100);
116
117 if (format > 0xffff)
118 return -ERANGE;
119
120 if (nv_device(dev)->chipset >= 0x30) {
120 if (dev->info.chipset >= 0x30) {
121 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
122 return -ERANGE;
123 } else {
124 if (crtc_w < (src_w >> 3) || crtc_h < (src_h >> 3))
125 return -ERANGE;
126 }
127
128 ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM);

--- 38 unchanged lines hidden (view full) ---

167 nouveau_bo_unpin(cur);
168
169 return 0;
170}
171
172static int
173nv10_disable_plane(struct drm_plane *plane)
174{
121 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
122 return -ERANGE;
123 } else {
124 if (crtc_w < (src_w >> 3) || crtc_h < (src_h >> 3))
125 return -ERANGE;
126 }
127
128 ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM);

--- 38 unchanged lines hidden (view full) ---

167 nouveau_bo_unpin(cur);
168
169 return 0;
170}
171
172static int
173nv10_disable_plane(struct drm_plane *plane)
174{
175 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
175 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
176 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
177
178 nvif_wr32(dev, NV_PVIDEO_STOP, 1);
179 if (nv_plane->cur) {
180 nouveau_bo_unpin(nv_plane->cur);
181 nv_plane->cur = NULL;
182 }
183

--- 6 unchanged lines hidden (view full) ---

190 plane->funcs->disable_plane(plane);
191 drm_plane_cleanup(plane);
192 kfree(plane);
193}
194
195static void
196nv10_set_params(struct nouveau_plane *plane)
197{
176 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
177
178 nvif_wr32(dev, NV_PVIDEO_STOP, 1);
179 if (nv_plane->cur) {
180 nouveau_bo_unpin(nv_plane->cur);
181 nv_plane->cur = NULL;
182 }
183

--- 6 unchanged lines hidden (view full) ---

190 plane->funcs->disable_plane(plane);
191 drm_plane_cleanup(plane);
192 kfree(plane);
193}
194
195static void
196nv10_set_params(struct nouveau_plane *plane)
197{
198 struct nouveau_object *dev = nouveau_drm(plane->base.dev)->device;
198 struct nvif_device *dev = &nouveau_drm(plane->base.dev)->device;
199 u32 luma = (plane->brightness - 512) << 16 | plane->contrast;
200 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) |
201 (cos_mul(plane->hue, plane->saturation) & 0xffff);
202 u32 format = 0;
203
204 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(0), luma);
205 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(1), luma);
206 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(0), chroma);

--- 52 unchanged lines hidden (view full) ---

259 struct nouveau_drm *drm = nouveau_drm(device);
260 struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL);
261 int num_formats = ARRAY_SIZE(formats);
262 int ret;
263
264 if (!plane)
265 return;
266
199 u32 luma = (plane->brightness - 512) << 16 | plane->contrast;
200 u32 chroma = ((sin_mul(plane->hue, plane->saturation) & 0xffff) << 16) |
201 (cos_mul(plane->hue, plane->saturation) & 0xffff);
202 u32 format = 0;
203
204 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(0), luma);
205 nvif_wr32(dev, NV_PVIDEO_LUMINANCE(1), luma);
206 nvif_wr32(dev, NV_PVIDEO_CHROMINANCE(0), chroma);

--- 52 unchanged lines hidden (view full) ---

259 struct nouveau_drm *drm = nouveau_drm(device);
260 struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL);
261 int num_formats = ARRAY_SIZE(formats);
262 int ret;
263
264 if (!plane)
265 return;
266
267 switch (nv_device(drm->device)->chipset) {
267 switch (drm->device.info.chipset) {
268 case 0x10:
269 case 0x11:
270 case 0x15:
271 case 0x1a:
272 case 0x20:
273 num_formats = 2;
274 break;
275 }

--- 62 unchanged lines hidden (view full) ---

338
339static int
340nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
341 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
342 unsigned int crtc_w, unsigned int crtc_h,
343 uint32_t src_x, uint32_t src_y,
344 uint32_t src_w, uint32_t src_h)
345{
268 case 0x10:
269 case 0x11:
270 case 0x15:
271 case 0x1a:
272 case 0x20:
273 num_formats = 2;
274 break;
275 }

--- 62 unchanged lines hidden (view full) ---

338
339static int
340nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
341 struct drm_framebuffer *fb, int crtc_x, int crtc_y,
342 unsigned int crtc_w, unsigned int crtc_h,
343 uint32_t src_x, uint32_t src_y,
344 uint32_t src_w, uint32_t src_h)
345{
346 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
346 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
347 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
348 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
349 struct nouveau_bo *cur = nv_plane->cur;
350 uint32_t overlay = 1;
351 int brightness = (nv_plane->brightness - 512) * 62 / 512;
352 int pitch, ret, i;
353
354 /* Source parameters given in 16.16 fixed point, ignore fractional. */

--- 62 unchanged lines hidden (view full) ---

417 nouveau_bo_unpin(cur);
418
419 return 0;
420}
421
422static int
423nv04_disable_plane(struct drm_plane *plane)
424{
347 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
348 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
349 struct nouveau_bo *cur = nv_plane->cur;
350 uint32_t overlay = 1;
351 int brightness = (nv_plane->brightness - 512) * 62 / 512;
352 int pitch, ret, i;
353
354 /* Source parameters given in 16.16 fixed point, ignore fractional. */

--- 62 unchanged lines hidden (view full) ---

417 nouveau_bo_unpin(cur);
418
419 return 0;
420}
421
422static int
423nv04_disable_plane(struct drm_plane *plane)
424{
425 struct nouveau_object *dev = nouveau_drm(plane->dev)->device;
425 struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
426 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
427
428 nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0);
429 nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0);
430 nvif_wr32(dev, NV_PVIDEO_SU_STATE, 0);
431 nvif_wr32(dev, NV_PVIDEO_RM_STATE, 0);
432 if (nv_plane->cur) {
433 nouveau_bo_unpin(nv_plane->cur);

--- 50 unchanged lines hidden (view full) ---

484err:
485 kfree(plane);
486 NV_ERROR(drm, "Failed to create plane\n");
487}
488
489void
490nouveau_overlay_init(struct drm_device *device)
491{
426 struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
427
428 nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0);
429 nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0);
430 nvif_wr32(dev, NV_PVIDEO_SU_STATE, 0);
431 nvif_wr32(dev, NV_PVIDEO_RM_STATE, 0);
432 if (nv_plane->cur) {
433 nouveau_bo_unpin(nv_plane->cur);

--- 50 unchanged lines hidden (view full) ---

484err:
485 kfree(plane);
486 NV_ERROR(drm, "Failed to create plane\n");
487}
488
489void
490nouveau_overlay_init(struct drm_device *device)
491{
492 struct nouveau_object *dev = nouveau_drm(device)->device;
493 if (nv_device(dev)->chipset < 0x10)
492 struct nvif_device *dev = &nouveau_drm(device)->device;
493 if (dev->info.chipset < 0x10)
494 nv04_overlay_init(device);
494 nv04_overlay_init(device);
495 else if (nv_device(dev)->chipset <= 0x40)
495 else if (dev->info.chipset <= 0x40)
496 nv10_overlay_init(device);
497}
496 nv10_overlay_init(device);
497}