18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2018 Red Hat Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci#include "ovly.h" 238c2ecf20Sopenharmony_ci#include "atom.h" 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include <nouveau_bo.h> 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include <nvif/push507c.h> 288c2ecf20Sopenharmony_ci#include <nvif/timer.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include <nvhw/class/cl827e.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistatic int 338c2ecf20Sopenharmony_ciovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 368c2ecf20Sopenharmony_ci int ret; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 12))) 398c2ecf20Sopenharmony_ci return ret; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci PUSH_MTHD(push, NV827E, SET_PRESENT_CONTROL, 428c2ecf20Sopenharmony_ci NVDEF(NV827E, SET_PRESENT_CONTROL, BEGIN_MODE, ASAP) | 438c2ecf20Sopenharmony_ci NVVAL(NV827E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval)); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci PUSH_MTHD(push, NV827E, SET_CONTEXT_DMA_ISO, asyw->image.handle[0]); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci PUSH_MTHD(push, NV827E, SET_COMPOSITION_CONTROL, 488c2ecf20Sopenharmony_ci NVDEF(NV827E, SET_COMPOSITION_CONTROL, MODE, OPAQUE_SUSPEND_BASE)); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci PUSH_MTHD(push, NV827E, SURFACE_SET_OFFSET, asyw->image.offset[0] >> 8); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci PUSH_MTHD(push, NV827E, SURFACE_SET_SIZE, 538c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_SIZE, WIDTH, asyw->image.w) | 548c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_SIZE, HEIGHT, asyw->image.h), 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci SURFACE_SET_STORAGE, 578c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) | 588c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_STORAGE, PITCH, (asyw->image.pitch[0] >> 8)) | 598c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_STORAGE, PITCH, asyw->image.blocks[0]) | 608c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout), 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci SURFACE_SET_PARAMS, 638c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_PARAMS, FORMAT, asyw->image.format) | 648c2ecf20Sopenharmony_ci NVVAL(NV827E, SURFACE_SET_PARAMS, COLOR_SPACE, asyw->image.colorspace)); 658c2ecf20Sopenharmony_ci return 0; 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciint 698c2ecf20Sopenharmony_ciovly827e_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset, 708c2ecf20Sopenharmony_ci struct nvif_device *device) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci s64 time = nvif_msec(device, 2000ULL, 738c2ecf20Sopenharmony_ci if (NVBO_TD32(bo, offset, NV_DISP_NOTIFICATION_1, _3, STATUS, ==, BEGUN)) 748c2ecf20Sopenharmony_ci break; 758c2ecf20Sopenharmony_ci usleep_range(1, 2); 768c2ecf20Sopenharmony_ci ); 778c2ecf20Sopenharmony_ci return time < 0 ? time : 0; 788c2ecf20Sopenharmony_ci} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_civoid 818c2ecf20Sopenharmony_ciovly827e_ntfy_reset(struct nouveau_bo *bo, u32 offset) 828c2ecf20Sopenharmony_ci{ 838c2ecf20Sopenharmony_ci NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, TIME_STAMP_0, 0); 848c2ecf20Sopenharmony_ci NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, TIME_STAMP_1, 0); 858c2ecf20Sopenharmony_ci NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, _2, 0); 868c2ecf20Sopenharmony_ci NVBO_WR32(bo, offset, NV_DISP_NOTIFICATION_1, _3, 878c2ecf20Sopenharmony_ci NVDEF(NV_DISP_NOTIFICATION_1, _3, STATUS, NOT_BEGUN)); 888c2ecf20Sopenharmony_ci} 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistatic const struct nv50_wndw_func 918c2ecf20Sopenharmony_ciovly827e = { 928c2ecf20Sopenharmony_ci .acquire = ovly507e_acquire, 938c2ecf20Sopenharmony_ci .release = ovly507e_release, 948c2ecf20Sopenharmony_ci .ntfy_set = base507c_ntfy_set, 958c2ecf20Sopenharmony_ci .ntfy_clr = base507c_ntfy_clr, 968c2ecf20Sopenharmony_ci .ntfy_reset = ovly827e_ntfy_reset, 978c2ecf20Sopenharmony_ci .ntfy_wait_begun = ovly827e_ntfy_wait_begun, 988c2ecf20Sopenharmony_ci .image_set = ovly827e_image_set, 998c2ecf20Sopenharmony_ci .image_clr = base507c_image_clr, 1008c2ecf20Sopenharmony_ci .scale_set = ovly507e_scale_set, 1018c2ecf20Sopenharmony_ci .update = base507c_update, 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ciconst u32 1058c2ecf20Sopenharmony_ciovly827e_format[] = { 1068c2ecf20Sopenharmony_ci DRM_FORMAT_YUYV, 1078c2ecf20Sopenharmony_ci DRM_FORMAT_UYVY, 1088c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB8888, 1098c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB1555, 1108c2ecf20Sopenharmony_ci DRM_FORMAT_XBGR2101010, 1118c2ecf20Sopenharmony_ci 0 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ciint 1158c2ecf20Sopenharmony_ciovly827e_new(struct nouveau_drm *drm, int head, s32 oclass, 1168c2ecf20Sopenharmony_ci struct nv50_wndw **pwndw) 1178c2ecf20Sopenharmony_ci{ 1188c2ecf20Sopenharmony_ci return ovly507e_new_(&ovly827e, ovly827e_format, drm, head, oclass, 1198c2ecf20Sopenharmony_ci 0x00000004 << (head * 8), pwndw); 1208c2ecf20Sopenharmony_ci} 121