1 /* SPDX-License-Identifier: MIT 2 * 3 * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. 4 */ 5 #include "engine.h" 6 #include <engine/nvenc.h> 7 8 static void * 9 nvkm_rm_nvenc_dtor(struct nvkm_engine *engine) 10 { 11 return container_of(engine, struct nvkm_nvenc, engine); 12 } 13 14 int 15 nvkm_rm_nvenc_new(struct nvkm_rm *rm, int inst) 16 { 17 struct nvkm_nvenc *nvenc; 18 int ret; 19 20 nvenc = kzalloc(sizeof(*nvenc), GFP_KERNEL); 21 if (!nvenc) 22 return -ENOMEM; 23 24 ret = nvkm_rm_engine_ctor(nvkm_rm_nvenc_dtor, rm, NVKM_ENGINE_NVENC, inst, 25 &rm->gpu->nvenc.class, 1, &nvenc->engine); 26 if (ret) { 27 kfree(nvenc); 28 return ret; 29 } 30 31 rm->device->nvenc[inst] = nvenc; 32 return 0; 33 } 34