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 "wndw.h" 238c2ecf20Sopenharmony_ci#include "atom.h" 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include <drm/drm_atomic_helper.h> 268c2ecf20Sopenharmony_ci#include <drm/drm_plane_helper.h> 278c2ecf20Sopenharmony_ci#include <nouveau_bo.h> 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#include <nvif/clc37e.h> 308c2ecf20Sopenharmony_ci#include <nvif/pushc37b.h> 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#include <nvhw/class/clc37e.h> 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic int 358c2ecf20Sopenharmony_ciwndwc37e_csc_clr(struct nv50_wndw *wndw) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci return 0; 388c2ecf20Sopenharmony_ci} 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistatic int 418c2ecf20Sopenharmony_ciwndwc37e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 448c2ecf20Sopenharmony_ci int ret; 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 13))) 478c2ecf20Sopenharmony_ci return ret; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CSC_RED2RED, asyw->csc.matrix, 12); 508c2ecf20Sopenharmony_ci return 0; 518c2ecf20Sopenharmony_ci} 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistatic int 548c2ecf20Sopenharmony_ciwndwc37e_ilut_clr(struct nv50_wndw *wndw) 558c2ecf20Sopenharmony_ci{ 568c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 578c2ecf20Sopenharmony_ci int ret; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 608c2ecf20Sopenharmony_ci return ret; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_INPUT_LUT, 0x00000000); 638c2ecf20Sopenharmony_ci return 0; 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic int 678c2ecf20Sopenharmony_ciwndwc37e_ilut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 708c2ecf20Sopenharmony_ci int ret; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 4))) 738c2ecf20Sopenharmony_ci return ret; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTROL_INPUT_LUT, 768c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_CONTROL_INPUT_LUT, OUTPUT_MODE, asyw->xlut.i.output_mode) | 778c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_CONTROL_INPUT_LUT, RANGE, asyw->xlut.i.range) | 788c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_CONTROL_INPUT_LUT, SIZE, asyw->xlut.i.size), 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci SET_OFFSET_INPUT_LUT, asyw->xlut.i.offset >> 8, 818c2ecf20Sopenharmony_ci SET_CONTEXT_DMA_INPUT_LUT, asyw->xlut.handle); 828c2ecf20Sopenharmony_ci return 0; 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistatic bool 868c2ecf20Sopenharmony_ciwndwc37e_ilut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, int size) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci if (size != 256 && size != 1024) 898c2ecf20Sopenharmony_ci return false; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci asyw->xlut.i.size = size == 1024 ? NVC37E_SET_CONTROL_INPUT_LUT_SIZE_SIZE_1025 : 928c2ecf20Sopenharmony_ci NVC37E_SET_CONTROL_INPUT_LUT_SIZE_SIZE_257; 938c2ecf20Sopenharmony_ci asyw->xlut.i.range = NVC37E_SET_CONTROL_INPUT_LUT_RANGE_UNITY; 948c2ecf20Sopenharmony_ci asyw->xlut.i.output_mode = NVC37E_SET_CONTROL_INPUT_LUT_OUTPUT_MODE_INTERPOLATE; 958c2ecf20Sopenharmony_ci asyw->xlut.i.load = head907d_olut_load; 968c2ecf20Sopenharmony_ci return true; 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciint 1008c2ecf20Sopenharmony_ciwndwc37e_blend_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 1018c2ecf20Sopenharmony_ci{ 1028c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 1038c2ecf20Sopenharmony_ci int ret; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 8))) 1068c2ecf20Sopenharmony_ci return ret; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_COMPOSITION_CONTROL, 1098c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_COMPOSITION_CONTROL, COLOR_KEY_SELECT, DISABLE) | 1108c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_CONTROL, DEPTH, asyw->blend.depth), 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci SET_COMPOSITION_CONSTANT_ALPHA, 1138c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_CONSTANT_ALPHA, K1, asyw->blend.k1) | 1148c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_CONSTANT_ALPHA, K2, 0), 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci SET_COMPOSITION_FACTOR_SELECT, 1178c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_FACTOR_SELECT, SRC_COLOR_FACTOR_MATCH_SELECT, 1188c2ecf20Sopenharmony_ci asyw->blend.src_color) | 1198c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_FACTOR_SELECT, SRC_COLOR_FACTOR_NO_MATCH_SELECT, 1208c2ecf20Sopenharmony_ci asyw->blend.src_color) | 1218c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_FACTOR_SELECT, DST_COLOR_FACTOR_MATCH_SELECT, 1228c2ecf20Sopenharmony_ci asyw->blend.dst_color) | 1238c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_COMPOSITION_FACTOR_SELECT, DST_COLOR_FACTOR_NO_MATCH_SELECT, 1248c2ecf20Sopenharmony_ci asyw->blend.dst_color), 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci SET_KEY_ALPHA, 1278c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_ALPHA, MIN, 0x0000) | 1288c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_ALPHA, MAX, 0xffff), 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci SET_KEY_RED_CR, 1318c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_RED_CR, MIN, 0x0000) | 1328c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_RED_CR, MAX, 0xffff), 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci SET_KEY_GREEN_Y, 1358c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_GREEN_Y, MIN, 0x0000) | 1368c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_GREEN_Y, MAX, 0xffff), 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci SET_KEY_BLUE_CB, 1398c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_BLUE_CB, MIN, 0x0000) | 1408c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_KEY_BLUE_CB, MAX, 0xffff)); 1418c2ecf20Sopenharmony_ci return 0; 1428c2ecf20Sopenharmony_ci} 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ciint 1458c2ecf20Sopenharmony_ciwndwc37e_image_clr(struct nv50_wndw *wndw) 1468c2ecf20Sopenharmony_ci{ 1478c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 1488c2ecf20Sopenharmony_ci int ret; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 4))) 1518c2ecf20Sopenharmony_ci return ret; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_PRESENT_CONTROL, 1548c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, 0) | 1558c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PRESENT_CONTROL, BEGIN_MODE, NON_TEARING)); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_ISO(0), 0x00000000); 1588c2ecf20Sopenharmony_ci return 0; 1598c2ecf20Sopenharmony_ci} 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_cistatic int 1628c2ecf20Sopenharmony_ciwndwc37e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 1638c2ecf20Sopenharmony_ci{ 1648c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 1658c2ecf20Sopenharmony_ci int ret; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 17))) 1688c2ecf20Sopenharmony_ci return ret; 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_PRESENT_CONTROL, 1718c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval) | 1728c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) | 1738c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PRESENT_CONTROL, TIMESTAMP_MODE, DISABLE)); 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_SIZE, 1768c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_SIZE, WIDTH, asyw->image.w) | 1778c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_SIZE, HEIGHT, asyw->image.h), 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci SET_STORAGE, 1808c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh) | 1818c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_STORAGE, MEMORY_LAYOUT, asyw->image.layout), 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci SET_PARAMS, 1848c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PARAMS, FORMAT, asyw->image.format) | 1858c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PARAMS, COLOR_SPACE, asyw->image.colorspace) | 1868c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PARAMS, INPUT_RANGE, BYPASS) | 1878c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PARAMS, UNDERREPLICATE, DISABLE) | 1888c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PARAMS, DE_GAMMA, NONE) | 1898c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PARAMS, CSC, asyw->csc.valid) | 1908c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PARAMS, CLAMP_BEFORE_BLEND, DISABLE) | 1918c2ecf20Sopenharmony_ci NVDEF(NVC37E, SET_PARAMS, SWAP_UV, DISABLE), 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci SET_PLANAR_STORAGE(0), 1948c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PLANAR_STORAGE, PITCH, asyw->image.blocks[0]) | 1958c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_PLANAR_STORAGE, PITCH, asyw->image.pitch[0] >> 6)); 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_ISO(0), asyw->image.handle, 1); 1988c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_OFFSET(0), asyw->image.offset[0] >> 8); 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_POINT_IN(0), 2018c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_POINT_IN, X, asyw->state.src_x >> 16) | 2028c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_POINT_IN, Y, asyw->state.src_y >> 16)); 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_SIZE_IN, 2058c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_SIZE_IN, WIDTH, asyw->state.src_w >> 16) | 2068c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_SIZE_IN, HEIGHT, asyw->state.src_h >> 16)); 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_SIZE_OUT, 2098c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_SIZE_OUT, WIDTH, asyw->state.crtc_w) | 2108c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_SIZE_OUT, HEIGHT, asyw->state.crtc_h)); 2118c2ecf20Sopenharmony_ci return 0; 2128c2ecf20Sopenharmony_ci} 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ciint 2158c2ecf20Sopenharmony_ciwndwc37e_ntfy_clr(struct nv50_wndw *wndw) 2168c2ecf20Sopenharmony_ci{ 2178c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 2188c2ecf20Sopenharmony_ci int ret; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 2218c2ecf20Sopenharmony_ci return ret; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_NOTIFIER, 0x00000000); 2248c2ecf20Sopenharmony_ci return 0; 2258c2ecf20Sopenharmony_ci} 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ciint 2288c2ecf20Sopenharmony_ciwndwc37e_ntfy_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 2298c2ecf20Sopenharmony_ci{ 2308c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 2318c2ecf20Sopenharmony_ci int ret; 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 3))) 2348c2ecf20Sopenharmony_ci return ret; 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_NOTIFIER, asyw->ntfy.handle, 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci SET_NOTIFIER_CONTROL, 2398c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_NOTIFIER_CONTROL, MODE, asyw->ntfy.awaken) | 2408c2ecf20Sopenharmony_ci NVVAL(NVC37E, SET_NOTIFIER_CONTROL, OFFSET, asyw->ntfy.offset >> 4)); 2418c2ecf20Sopenharmony_ci return 0; 2428c2ecf20Sopenharmony_ci} 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ciint 2458c2ecf20Sopenharmony_ciwndwc37e_sema_clr(struct nv50_wndw *wndw) 2468c2ecf20Sopenharmony_ci{ 2478c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 2488c2ecf20Sopenharmony_ci int ret; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 2))) 2518c2ecf20Sopenharmony_ci return ret; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_CONTEXT_DMA_SEMAPHORE, 0x00000000); 2548c2ecf20Sopenharmony_ci return 0; 2558c2ecf20Sopenharmony_ci} 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ciint 2588c2ecf20Sopenharmony_ciwndwc37e_sema_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 2598c2ecf20Sopenharmony_ci{ 2608c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 2618c2ecf20Sopenharmony_ci int ret; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 5))) 2648c2ecf20Sopenharmony_ci return ret; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_SEMAPHORE_CONTROL, asyw->sema.offset, 2678c2ecf20Sopenharmony_ci SET_SEMAPHORE_ACQUIRE, asyw->sema.acquire, 2688c2ecf20Sopenharmony_ci SET_SEMAPHORE_RELEASE, asyw->sema.release, 2698c2ecf20Sopenharmony_ci SET_CONTEXT_DMA_SEMAPHORE, asyw->sema.handle); 2708c2ecf20Sopenharmony_ci return 0; 2718c2ecf20Sopenharmony_ci} 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ciint 2748c2ecf20Sopenharmony_ciwndwc37e_update(struct nv50_wndw *wndw, u32 *interlock) 2758c2ecf20Sopenharmony_ci{ 2768c2ecf20Sopenharmony_ci struct nvif_push *push = wndw->wndw.push; 2778c2ecf20Sopenharmony_ci int ret; 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci if ((ret = PUSH_WAIT(push, 5))) 2808c2ecf20Sopenharmony_ci return ret; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, SET_INTERLOCK_FLAGS, interlock[NV50_DISP_INTERLOCK_CURS] << 1 | 2838c2ecf20Sopenharmony_ci interlock[NV50_DISP_INTERLOCK_CORE], 2848c2ecf20Sopenharmony_ci SET_WINDOW_INTERLOCK_FLAGS, interlock[NV50_DISP_INTERLOCK_WNDW]); 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci PUSH_MTHD(push, NVC37E, UPDATE, 0x00000001 | 2878c2ecf20Sopenharmony_ci NVVAL(NVC37E, UPDATE, INTERLOCK_WITH_WIN_IMM, 2888c2ecf20Sopenharmony_ci !!(interlock[NV50_DISP_INTERLOCK_WIMM] & wndw->interlock.data))); 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci return PUSH_KICK(push); 2918c2ecf20Sopenharmony_ci} 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_civoid 2948c2ecf20Sopenharmony_ciwndwc37e_release(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, 2958c2ecf20Sopenharmony_ci struct nv50_head_atom *asyh) 2968c2ecf20Sopenharmony_ci{ 2978c2ecf20Sopenharmony_ci} 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ciint 3008c2ecf20Sopenharmony_ciwndwc37e_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, 3018c2ecf20Sopenharmony_ci struct nv50_head_atom *asyh) 3028c2ecf20Sopenharmony_ci{ 3038c2ecf20Sopenharmony_ci return drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state, 3048c2ecf20Sopenharmony_ci DRM_PLANE_HELPER_NO_SCALING, 3058c2ecf20Sopenharmony_ci DRM_PLANE_HELPER_NO_SCALING, 3068c2ecf20Sopenharmony_ci true, true); 3078c2ecf20Sopenharmony_ci} 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_cistatic const u32 3108c2ecf20Sopenharmony_ciwndwc37e_format[] = { 3118c2ecf20Sopenharmony_ci DRM_FORMAT_C8, 3128c2ecf20Sopenharmony_ci DRM_FORMAT_YUYV, 3138c2ecf20Sopenharmony_ci DRM_FORMAT_UYVY, 3148c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB8888, 3158c2ecf20Sopenharmony_ci DRM_FORMAT_ARGB8888, 3168c2ecf20Sopenharmony_ci DRM_FORMAT_RGB565, 3178c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB1555, 3188c2ecf20Sopenharmony_ci DRM_FORMAT_ARGB1555, 3198c2ecf20Sopenharmony_ci DRM_FORMAT_XBGR2101010, 3208c2ecf20Sopenharmony_ci DRM_FORMAT_ABGR2101010, 3218c2ecf20Sopenharmony_ci DRM_FORMAT_XBGR8888, 3228c2ecf20Sopenharmony_ci DRM_FORMAT_ABGR8888, 3238c2ecf20Sopenharmony_ci DRM_FORMAT_XRGB2101010, 3248c2ecf20Sopenharmony_ci DRM_FORMAT_ARGB2101010, 3258c2ecf20Sopenharmony_ci DRM_FORMAT_XBGR16161616F, 3268c2ecf20Sopenharmony_ci DRM_FORMAT_ABGR16161616F, 3278c2ecf20Sopenharmony_ci 0 3288c2ecf20Sopenharmony_ci}; 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_cistatic const struct nv50_wndw_func 3318c2ecf20Sopenharmony_ciwndwc37e = { 3328c2ecf20Sopenharmony_ci .acquire = wndwc37e_acquire, 3338c2ecf20Sopenharmony_ci .release = wndwc37e_release, 3348c2ecf20Sopenharmony_ci .sema_set = wndwc37e_sema_set, 3358c2ecf20Sopenharmony_ci .sema_clr = wndwc37e_sema_clr, 3368c2ecf20Sopenharmony_ci .ntfy_set = wndwc37e_ntfy_set, 3378c2ecf20Sopenharmony_ci .ntfy_clr = wndwc37e_ntfy_clr, 3388c2ecf20Sopenharmony_ci .ntfy_reset = corec37d_ntfy_init, 3398c2ecf20Sopenharmony_ci .ntfy_wait_begun = base507c_ntfy_wait_begun, 3408c2ecf20Sopenharmony_ci .ilut = wndwc37e_ilut, 3418c2ecf20Sopenharmony_ci .ilut_size = 1024, 3428c2ecf20Sopenharmony_ci .xlut_set = wndwc37e_ilut_set, 3438c2ecf20Sopenharmony_ci .xlut_clr = wndwc37e_ilut_clr, 3448c2ecf20Sopenharmony_ci .csc = base907c_csc, 3458c2ecf20Sopenharmony_ci .csc_set = wndwc37e_csc_set, 3468c2ecf20Sopenharmony_ci .csc_clr = wndwc37e_csc_clr, 3478c2ecf20Sopenharmony_ci .image_set = wndwc37e_image_set, 3488c2ecf20Sopenharmony_ci .image_clr = wndwc37e_image_clr, 3498c2ecf20Sopenharmony_ci .blend_set = wndwc37e_blend_set, 3508c2ecf20Sopenharmony_ci .update = wndwc37e_update, 3518c2ecf20Sopenharmony_ci}; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ciint 3548c2ecf20Sopenharmony_ciwndwc37e_new_(const struct nv50_wndw_func *func, struct nouveau_drm *drm, 3558c2ecf20Sopenharmony_ci enum drm_plane_type type, int index, s32 oclass, u32 heads, 3568c2ecf20Sopenharmony_ci struct nv50_wndw **pwndw) 3578c2ecf20Sopenharmony_ci{ 3588c2ecf20Sopenharmony_ci struct nvc37e_window_channel_dma_v0 args = { 3598c2ecf20Sopenharmony_ci .pushbuf = 0xb0007e00 | index, 3608c2ecf20Sopenharmony_ci .index = index, 3618c2ecf20Sopenharmony_ci }; 3628c2ecf20Sopenharmony_ci struct nv50_disp *disp = nv50_disp(drm->dev); 3638c2ecf20Sopenharmony_ci struct nv50_wndw *wndw; 3648c2ecf20Sopenharmony_ci int ret; 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci ret = nv50_wndw_new_(func, drm->dev, type, "wndw", index, 3678c2ecf20Sopenharmony_ci wndwc37e_format, heads, NV50_DISP_INTERLOCK_WNDW, 3688c2ecf20Sopenharmony_ci BIT(index), &wndw); 3698c2ecf20Sopenharmony_ci if (*pwndw = wndw, ret) 3708c2ecf20Sopenharmony_ci return ret; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci ret = nv50_dmac_create(&drm->client.device, &disp->disp->object, 3738c2ecf20Sopenharmony_ci &oclass, 0, &args, sizeof(args), 3748c2ecf20Sopenharmony_ci disp->sync->offset, &wndw->wndw); 3758c2ecf20Sopenharmony_ci if (ret) { 3768c2ecf20Sopenharmony_ci NV_ERROR(drm, "qndw%04x allocation failed: %d\n", oclass, ret); 3778c2ecf20Sopenharmony_ci return ret; 3788c2ecf20Sopenharmony_ci } 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci wndw->ntfy = NV50_DISP_WNDW_NTFY(wndw->id); 3818c2ecf20Sopenharmony_ci wndw->sema = NV50_DISP_WNDW_SEM0(wndw->id); 3828c2ecf20Sopenharmony_ci wndw->data = 0x00000000; 3838c2ecf20Sopenharmony_ci return 0; 3848c2ecf20Sopenharmony_ci} 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ciint 3878c2ecf20Sopenharmony_ciwndwc37e_new(struct nouveau_drm *drm, enum drm_plane_type type, int index, 3888c2ecf20Sopenharmony_ci s32 oclass, struct nv50_wndw **pwndw) 3898c2ecf20Sopenharmony_ci{ 3908c2ecf20Sopenharmony_ci return wndwc37e_new_(&wndwc37e, drm, type, index, oclass, 3918c2ecf20Sopenharmony_ci BIT(index >> 1), pwndw); 3928c2ecf20Sopenharmony_ci} 393