File Index
Files and directories
Sign in
FILE

corec37d.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/nouveau/dispnv50/corec37d.c C
  1/*
  2 * Copyright 2018 Red Hat Inc.
  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
  9 * Software is furnished to do so, subject to the following conditions:
 10 *
 11 * The above copyright notice and this permission notice shall be included in
 12 * all copies or substantial portions of the Software.
 13 *
 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 20 * OTHER DEALINGS IN THE SOFTWARE.
 21 */
 22#include "core.h"
 23#include "head.h"
 24
 25#include <nvif/class.h>
 26#include <nvif/pushc37b.h>
 27#include <nvif/timer.h>
 28
 29#include <nvhw/class/clc37d.h>
 30
 31#include <nouveau_bo.h>
 32
 33int
 34corec37d_wndw_owner(struct nv50_core *core)
 35{
 36	struct nvif_push *push = &core->chan.push;
 37	const u32 windows = 8; /*XXX*/
 38	int ret, i;
 39
 40	if ((ret = PUSH_WAIT(push, windows * 2)))
 41		return ret;
 42
 43	for (i = 0; i < windows; i++) {
 44		PUSH_MTHD(push, NVC37D, WINDOW_SET_CONTROL(i),
 45			  NVDEF(NVC37D, WINDOW_SET_CONTROL, OWNER, HEAD(i >> 1)));
 46	}
 47
 48	return 0;
 49}
 50
 51int
 52corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
 53{
 54	struct nvif_push *push = &core->chan.push;
 55	int ret;
 56
 57	if ((ret = PUSH_WAIT(push, (ntfy ? 2 * 2 : 0) + 5)))
 58		return ret;
 59
 60	if (ntfy) {
 61		PUSH_MTHD(push, NVC37D, SET_NOTIFIER_CONTROL,
 62			  NVDEF(NVC37D, SET_NOTIFIER_CONTROL, MODE, WRITE) |
 63			  NVVAL(NVC37D, SET_NOTIFIER_CONTROL, OFFSET, NV50_DISP_CORE_NTFY >> 4) |
 64			  NVDEF(NVC37D, SET_NOTIFIER_CONTROL, NOTIFY, ENABLE));
 65	}
 66
 67	PUSH_MTHD(push, NVC37D, SET_INTERLOCK_FLAGS, interlock[NV50_DISP_INTERLOCK_CURS],
 68				SET_WINDOW_INTERLOCK_FLAGS, interlock[NV50_DISP_INTERLOCK_WNDW]);
 69	PUSH_MTHD(push, NVC37D, UPDATE, 0x00000001 |
 70		  NVDEF(NVC37D, UPDATE, SPECIAL_HANDLING, NONE) |
 71		  NVDEF(NVC37D, UPDATE, INHIBIT_INTERRUPTS, FALSE));
 72
 73	if (ntfy) {
 74		PUSH_MTHD(push, NVC37D, SET_NOTIFIER_CONTROL,
 75			  NVDEF(NVC37D, SET_NOTIFIER_CONTROL, NOTIFY, DISABLE));
 76	}
 77
 78	return PUSH_KICK(push);
 79}
 80
 81int
 82corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset,
 83			struct nvif_device *device)
 84{
 85	s64 time = nvif_msec(device, 2000ULL,
 86		if (NVBO_TD32(bo, offset, NV_DISP_NOTIFIER, _0, STATUS, ==, FINISHED))
 87			break;
 88		usleep_range(1, 2);
 89	);
 90	return time < 0 ? time : 0;
 91}
 92
 93void
 94corec37d_ntfy_init(struct nouveau_bo *bo, u32 offset)
 95{
 96	NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _0,
 97			NVDEF(NV_DISP_NOTIFIER, _0, STATUS, NOT_BEGUN));
 98	NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _1, 0);
 99	NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _2, 0);
100	NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _3, 0);
101}
102
103int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
104{
105	int ret;
106
107	ret = nvif_object_ctor(&disp->disp->object, "dispCaps", 0,
108			       disp->core->func->caps_class, NULL, 0, &disp->caps);
109	if (ret) {
110		NV_ERROR(drm,
111			 "Failed to init notifier caps region: %d\n",
112			 ret);
113		return ret;
114	}
115
116	ret = nvif_object_map(&disp->caps, NULL, 0);
117	if (ret) {
118		NV_ERROR(drm,
119			 "Failed to map notifier caps region: %d\n",
120			 ret);
121		return ret;
122	}
123
124	return 0;
125}
126
127static int
128corec37d_init(struct nv50_core *core)
129{
130	struct nvif_push *push = &core->chan.push;
131	const u32 windows = 8; /*XXX*/
132	int ret, i;
133
134	if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
135		return ret;
136
137	PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
138
139	for (i = 0; i < windows; i++) {
140		PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
141			  NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED1BPP, TRUE) |
142			  NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED2BPP, TRUE) |
143			  NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED4BPP, TRUE) |
144			  NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED8BPP, TRUE) |
145			  NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, YUV_PACKED422, TRUE),
146
147					WINDOW_SET_WINDOW_ROTATED_FORMAT_USAGE_BOUNDS(i), 0x00000000);
148
149		PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS(i),
150			  NVVAL(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, MAX_PIXELS_FETCHED_PER_LINE, 0x7fff) |
151			  NVDEF(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, INPUT_LUT, USAGE_1025) |
152			  NVDEF(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, INPUT_SCALER_TAPS, TAPS_2) |
153			  NVDEF(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, UPSCALING_ALLOWED, FALSE));
154	}
155
156	core->assign_windows = true;
157	return PUSH_KICK(push);
158}
159
160static const struct nv50_core_func
161corec37d = {
162	.init = corec37d_init,
163	.ntfy_init = corec37d_ntfy_init,
164	.caps_init = corec37d_caps_init,
165	.caps_class = GV100_DISP_CAPS,
166	.ntfy_wait_done = corec37d_ntfy_wait_done,
167	.update = corec37d_update,
168	.wndw.owner = corec37d_wndw_owner,
169	.head = &headc37d,
170	.sor = &sorc37d,
171#if IS_ENABLED(CONFIG_DEBUG_FS)
172	.crc = &crcc37d,
173#endif
174};
175
176int
177corec37d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
178{
179	return core507d_new_(&corec37d, drm, oclass, pcore);
180}
~/ Read-only file preview.