Skip to content

Commit f24b6ae

Browse files
author
Ben Skeggs
committed
drm/nouveau/disp: split part of OR allocation logic into a function
No logical changes here, this is just moving the code to make the changes in the next commit more obvious. Signed-off-by: Ben Skeggs <[email protected]>
1 parent 6f8dbcf commit f24b6ae

File tree

1 file changed

+37
-26
lines changed
  • drivers/gpu/drm/nouveau/nvkm/engine/disp

1 file changed

+37
-26
lines changed

drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.c

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,37 +111,18 @@ nvkm_outp_acquire_ior(struct nvkm_outp *outp, u8 user, struct nvkm_ior *ior)
111111
return 0;
112112
}
113113

114-
int
115-
nvkm_outp_acquire(struct nvkm_outp *outp, u8 user, bool hda)
114+
static inline int
115+
nvkm_outp_acquire_hda(struct nvkm_outp *outp, enum nvkm_ior_type type,
116+
u8 user, bool hda)
116117
{
117-
struct nvkm_ior *ior = outp->ior;
118-
enum nvkm_ior_proto proto;
119-
enum nvkm_ior_type type;
120-
121-
OUTP_TRACE(outp, "acquire %02x |= %02x %p", outp->acquired, user, ior);
122-
if (ior) {
123-
outp->acquired |= user;
124-
return 0;
125-
}
126-
127-
/* Lookup a compatible, and unused, OR to assign to the device. */
128-
proto = nvkm_outp_xlat(outp, &type);
129-
if (proto == UNKNOWN)
130-
return -ENOSYS;
131-
132-
/* Deal with panels requiring identity-mapped SOR assignment. */
133-
if (outp->identity) {
134-
ior = nvkm_ior_find(outp->disp, SOR, ffs(outp->info.or) - 1);
135-
if (WARN_ON(!ior))
136-
return -ENOSPC;
137-
return nvkm_outp_acquire_ior(outp, user, ior);
138-
}
118+
struct nvkm_ior *ior;
139119

140120
/* First preference is to reuse the OR that is currently armed
141121
* on HW, if any, in order to prevent unnecessary switching.
142122
*/
143123
list_for_each_entry(ior, &outp->disp->ior, head) {
144-
if (!ior->identity && !ior->asy.outp && ior->arm.outp == outp)
124+
if (!ior->identity &&
125+
!ior->asy.outp && ior->arm.outp == outp)
145126
return nvkm_outp_acquire_ior(outp, user, ior);
146127
}
147128

@@ -157,14 +138,44 @@ nvkm_outp_acquire(struct nvkm_outp *outp, u8 user, bool hda)
157138
* but will be released during the next modeset.
158139
*/
159140
list_for_each_entry(ior, &outp->disp->ior, head) {
160-
if (!ior->identity && !ior->asy.outp && ior->type == type &&
141+
if (!ior->identity &&
142+
!ior->asy.outp && ior->type == type &&
161143
(ior->func->route.set || ior->id == __ffs(outp->info.or)))
162144
return nvkm_outp_acquire_ior(outp, user, ior);
163145
}
164146

165147
return -ENOSPC;
166148
}
167149

150+
int
151+
nvkm_outp_acquire(struct nvkm_outp *outp, u8 user, bool hda)
152+
{
153+
struct nvkm_ior *ior = outp->ior;
154+
enum nvkm_ior_proto proto;
155+
enum nvkm_ior_type type;
156+
157+
OUTP_TRACE(outp, "acquire %02x |= %02x %p", outp->acquired, user, ior);
158+
if (ior) {
159+
outp->acquired |= user;
160+
return 0;
161+
}
162+
163+
/* Lookup a compatible, and unused, OR to assign to the device. */
164+
proto = nvkm_outp_xlat(outp, &type);
165+
if (proto == UNKNOWN)
166+
return -ENOSYS;
167+
168+
/* Deal with panels requiring identity-mapped SOR assignment. */
169+
if (outp->identity) {
170+
ior = nvkm_ior_find(outp->disp, SOR, ffs(outp->info.or) - 1);
171+
if (WARN_ON(!ior))
172+
return -ENOSPC;
173+
return nvkm_outp_acquire_ior(outp, user, ior);
174+
}
175+
176+
return nvkm_outp_acquire_hda(outp, type, user, true);
177+
}
178+
168179
void
169180
nvkm_outp_fini(struct nvkm_outp *outp)
170181
{

0 commit comments

Comments
 (0)