Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2018 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  */
0022 #include "ovly.h"
0023 #include "atom.h"
0024 
0025 #include <nouveau_bo.h>
0026 
0027 #include <nvif/push507c.h>
0028 #include <nvif/timer.h>
0029 
0030 #include <nvhw/class/cl827e.h>
0031 
0032 static int
0033 ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
0034 {
0035     struct nvif_push *push = wndw->wndw.push;
0036     int ret;
0037 
0038     if ((ret = PUSH_WAIT(push, 12)))
0039         return ret;
0040 
0041     PUSH_MTHD(push, NV827E, SET_PRESENT_CONTROL,
0042           NVDEF(NV827E, SET_PRESENT_CONTROL, BEGIN_MODE, ASAP) |
0043           NVVAL(NV827E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval));
0044 
0045     PUSH_MTHD(push, NV827E, SET_CONTEXT_DMA_ISO, asyw->image.handle[0]);
0046 
0047     PUSH_MTHD(push, NV827E, SET_COMPOSITION_CONTROL,
0048           NVDEF(NV827E, SET_COMPOSITION_CONTROL, MODE, OPAQUE_SUSPEND_BASE));
0049 
0050     PUSH_MTHD(push, NV827E, SURFACE_SET_OFFSET, asyw->image.offset[0] >> 8);
0051 
0052     PUSH_MTHD(push, NV827E, SURFACE_SET_SIZE,
0053           NVVAL(NV827E, SURFACE_SET_SIZE, WIDTH, asyw->image.w) |
0054           NVVAL(NV827E, SURFACE_SET_SIZE, HEIGHT, asyw->image.h),
0055 
0056                 SURFACE_SET_STORAGE,
0057           NVVAL(NV827E, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) |
0058           NVVAL(NV827E, SURFACE_SET_STORAGE, PITCH, (asyw->image.pitch[0] >> 8)) |
0059           NVVAL(NV827E, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) |
0060           NVVAL(NV827E, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout),
0061 
0062                 SURFACE_SET_PARAMS,
0063           NVVAL(NV827E, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) |
0064           NVVAL(NV827E, SURFACE_SET_PARAMS, COLOR_SPACE, asyw->image.colorspace));
0065     return 0;
0066 }
0067 
0068 int
0069 ovly827e_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset,
0070              struct nvif_device *device)
0071 {
0072     s64 time = nvif_msec(device, 2000ULL,
0073         if (NVBO_TD32(bo, offset, NV_DISP_NOTIFICATION_1, _3, STATUS, ==, BEGUN))
0074             break;
0075         usleep_range(1, 2);
0076     );
0077     return time < 0 ? time : 0;
0078 }
0079 
0080 void
0081 ovly827e_ntfy_reset(struct nouveau_bo *bo, u32 offset)
0082 {
0083     NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, TIME_STAMP_0, 0);
0084     NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, TIME_STAMP_1, 0);
0085     NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, _2, 0);
0086     NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, _3,
0087             NVDEF(NV_DISP_NOTIFICATION_1, _3, STATUS, NOT_BEGUN));
0088 }
0089 
0090 static const struct nv50_wndw_func
0091 ovly827e = {
0092     .acquire = ovly507e_acquire,
0093     .release = ovly507e_release,
0094     .ntfy_set = base507c_ntfy_set,
0095     .ntfy_clr = base507c_ntfy_clr,
0096     .ntfy_reset = ovly827e_ntfy_reset,
0097     .ntfy_wait_begun = ovly827e_ntfy_wait_begun,
0098     .image_set = ovly827e_image_set,
0099     .image_clr = base507c_image_clr,
0100     .scale_set = ovly507e_scale_set,
0101     .update = base507c_update,
0102 };
0103 
0104 const u32
0105 ovly827e_format[] = {
0106     DRM_FORMAT_YUYV,
0107     DRM_FORMAT_UYVY,
0108     DRM_FORMAT_XRGB8888,
0109     DRM_FORMAT_XRGB1555,
0110     DRM_FORMAT_XBGR2101010,
0111     0
0112 };
0113 
0114 int
0115 ovly827e_new(struct nouveau_drm *drm, int head, s32 oclass,
0116          struct nv50_wndw **pwndw)
0117 {
0118     return ovly507e_new_(&ovly827e, ovly827e_format, drm, head, oclass,
0119                  0x00000004 << (head * 8), pwndw);
0120 }