1/* $NetBSD: nouveau_dispnv50_ovly827e.c,v 1.2 2021/12/18 23:45:32 riastradh Exp $ */ 2 3/* 4 * Copyright 2018 Red Hat Inc. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24#include <sys/cdefs.h> 25__KERNEL_RCSID(0, "$NetBSD: nouveau_dispnv50_ovly827e.c,v 1.2 2021/12/18 23:45:32 riastradh Exp $"); 26 27#include "ovly.h" 28#include "atom.h" 29 30#include <nouveau_bo.h> 31 32static void 33ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 34{ 35 u32 *push; 36 if ((push = evo_wait(&wndw->wndw, 12))) { 37 evo_mthd(push, 0x0084, 1); 38 evo_data(push, asyw->image.interval << 4); 39 evo_mthd(push, 0x00c0, 1); 40 evo_data(push, asyw->image.handle[0]); 41 evo_mthd(push, 0x0100, 1); 42 evo_data(push, 0x00000002); 43 evo_mthd(push, 0x0800, 1); 44 evo_data(push, asyw->image.offset[0] >> 8); 45 evo_mthd(push, 0x0808, 3); 46 evo_data(push, asyw->image.h << 16 | asyw->image.w); 47 evo_data(push, asyw->image.layout << 20 | 48 (asyw->image.pitch[0] >> 8) << 8 | 49 asyw->image.blocks[0] << 8 | 50 asyw->image.blockh); 51 evo_data(push, asyw->image.format << 8 | 52 asyw->image.colorspace); 53 evo_kick(push, &wndw->wndw); 54 } 55} 56 57int 58ovly827e_ntfy_wait_begun(struct nouveau_bo *bo, u32 offset, 59 struct nvif_device *device) 60{ 61 s64 time = nvif_msec(device, 2000ULL, 62 u32 data = nouveau_bo_rd32(bo, offset / 4 + 3); 63 if ((data & 0xffff0000) == 0xffff0000) 64 break; 65 usleep_range(1, 2); 66 ); 67 return time < 0 ? time : 0; 68} 69 70void 71ovly827e_ntfy_reset(struct nouveau_bo *bo, u32 offset) 72{ 73 nouveau_bo_wr32(bo, offset / 4 + 0, 0x00000000); 74 nouveau_bo_wr32(bo, offset / 4 + 1, 0x00000000); 75 nouveau_bo_wr32(bo, offset / 4 + 2, 0x00000000); 76 nouveau_bo_wr32(bo, offset / 4 + 3, 0x80000000); 77} 78 79static const struct nv50_wndw_func 80ovly827e = { 81 .acquire = ovly507e_acquire, 82 .release = ovly507e_release, 83 .ntfy_set = ovly507e_ntfy_set, 84 .ntfy_clr = ovly507e_ntfy_clr, 85 .ntfy_reset = ovly827e_ntfy_reset, 86 .ntfy_wait_begun = ovly827e_ntfy_wait_begun, 87 .image_set = ovly827e_image_set, 88 .image_clr = ovly507e_image_clr, 89 .scale_set = ovly507e_scale_set, 90 .update = ovly507e_update, 91}; 92 93const u32 94ovly827e_format[] = { 95 DRM_FORMAT_YUYV, 96 DRM_FORMAT_UYVY, 97 DRM_FORMAT_XRGB8888, 98 DRM_FORMAT_XRGB1555, 99 DRM_FORMAT_XBGR2101010, 100 0 101}; 102 103int 104ovly827e_new(struct nouveau_drm *drm, int head, s32 oclass, 105 struct nv50_wndw **pwndw) 106{ 107 return ovly507e_new_(&ovly827e, ovly827e_format, drm, head, oclass, 108 0x00000004 << (head * 8), pwndw); 109} 110