mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
kernel-open: implement standalone nvidia_rs_modeset and nvidia_rs_drm KMS/DRM modules
This commit is contained in:
@ -21,6 +21,11 @@ Where stock NVIDIA `580.178.04` avoids `#if LINUX_VERSION_CODE` guards altogethe
|
||||
| `fb_is_primary_device()` → `video_is_primary_device()` in `<asm/video.h>` | declaration in `asm/video.h` (**6.9**); before it `vga_default_device()` | `ga10x_adapter.c` (via `NV_RS_HAVE_VIDEO_IS_PRIMARY_DEVICE` from `kernel-open/Kbuild`) |
|
||||
| `pci_resize_resource(..., exclude_bars)` | declaration in `pci.h` (6.19, backported to 6.18 stable), else **6.19** / `UTS_UBUNTU_RELEASE_ABI` | `pci_adapter.c` ×2 (via `NV_RS_PCI_RESIZE_EXCLUDE_BARS` from `kernel-open/Kbuild`) |
|
||||
| `drm_driver.date` (field removed) | **6.14** | `nvidia-drm/nvidia_rs_drm.c` |
|
||||
| `<linux/aperture.h>` vs `<drm/drm_aperture.h>` (`aperture_remove_conflicting_pci_devices`) | **6.2** | `nvidia-drm/nvidia_rs_drm.c` (via `NV_RS_HAVE_LINUX_APERTURE_H` / `NV_RS_HAVE_DRM_APERTURE_H`) |
|
||||
| `drm_client_setup` (`<drm/clients/drm_client_setup.h>` / `<drm/drm_client_setup.h>` vs `drm_fbdev_ttm_setup` / `drm_fbdev_generic_setup`) | **6.12 / 6.13** | `nvidia-drm/nvidia_rs_drm.c` (via `NV_RS_HAVE_DRM_CLIENTS_CLIENT_SETUP_H`, etc.) |
|
||||
| `drm_mode_config_funcs.fb_create` & `drm_helper_mode_fill_fb_struct` `info` parameter | **6.17** | `nvidia-drm/nvidia_rs_drm.c` (via `NV_RS_HAVE_DRM_FB_CREATE_FORMAT_INFO`) |
|
||||
| `drm_gem_object_funcs.vmap` `struct iosys_map` | **5.18** | `nvidia-drm/nvidia_rs_drm.c` (via `NV_RS_HAVE_DRM_IOSYS_MAP`) |
|
||||
| `drm_edid_read_custom` / `drm_edid_connector_update` | **6.3** | `nvidia-drm/nvidia_rs_drm.c` (via `NV_RS_HAVE_DRM_EDID_READ_CUSTOM`) |
|
||||
|
||||
- Host-fixture builds (`NV_RS_*_HOST_FIXTURE`) do not pull `<linux/version.h>`. `tests/irq-mock/irq_mock.h` and `tests/rom-fw-mock/rom_fw_mock.h` define `LINUX_VERSION_CODE 0` and `KERNEL_VERSION(a,b,c)` so the guards preprocess cleanly on the host-fixture side.
|
||||
|
||||
|
||||
@ -34,12 +34,43 @@ NV_RS_DRM_DRV_H := $(srctree)/include/drm/drm_drv.h
|
||||
ifeq ($(shell grep -q 'const char \*date;' $(NV_RS_DRM_DRV_H) 2>/dev/null && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_DRIVER_DATE
|
||||
endif
|
||||
ifeq ($(shell test -f $(srctree)/include/linux/aperture.h && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_LINUX_APERTURE_H
|
||||
endif
|
||||
ifeq ($(shell test -f $(srctree)/include/drm/drm_aperture.h && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_APERTURE_H
|
||||
endif
|
||||
ifeq ($(shell test -f $(srctree)/include/drm/clients/drm_client_setup.h && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_CLIENTS_CLIENT_SETUP_H
|
||||
endif
|
||||
ifeq ($(shell test -f $(srctree)/include/drm/drm_client_setup.h && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_CLIENT_SETUP_H
|
||||
endif
|
||||
ifeq ($(shell test -f $(srctree)/include/drm/drm_fbdev_ttm.h && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_FBDEV_TTM_H
|
||||
endif
|
||||
ifeq ($(shell test -f $(srctree)/include/drm/drm_fbdev_generic.h && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_FBDEV_GENERIC_H
|
||||
endif
|
||||
NV_RS_DRM_MODE_CFG_H := $(srctree)/include/drm/drm_mode_config.h
|
||||
ifeq ($(shell grep -A4 '\*fb_create' $(NV_RS_DRM_MODE_CFG_H) 2>/dev/null | grep -q 'drm_format_info' && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_FB_CREATE_FORMAT_INFO
|
||||
endif
|
||||
NV_RS_DRM_GEM_H := $(srctree)/include/drm/drm_gem.h
|
||||
ifeq ($(shell grep -q 'struct iosys_map' $(NV_RS_DRM_GEM_H) 2>/dev/null && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_IOSYS_MAP
|
||||
endif
|
||||
NV_RS_DRM_EDID_H := $(srctree)/include/drm/drm_edid.h
|
||||
ifeq ($(shell grep -q 'drm_edid_read_custom' $(NV_RS_DRM_EDID_H) 2>/dev/null && echo y),y)
|
||||
ccflags-y += -DNV_RS_HAVE_DRM_EDID_READ_CUSTOM
|
||||
endif
|
||||
obj-m += nvidia_rs.o nvidia_rs_modeset.o nvidia_rs_peermem.o
|
||||
ifneq ($(CONFIG_DRM),)
|
||||
obj-m += nvidia_rs_drm.o
|
||||
endif
|
||||
nvidia_rs_modeset-y := nvidia-modeset/nvidia_rs_modeset.o
|
||||
nvidia_rs_drm-y := nvidia-drm/nvidia_rs_drm.o
|
||||
CFLAGS_nvidia-drm/nvidia_rs_drm.o := -I$(src)/nvidia-modeset
|
||||
nvidia_rs_peermem-y := nvidia-peermem/nvidia_rs_peermem.o
|
||||
nvidia_rs-y := nvidia/diagnostic.o nvidia/rmapi_node.o nvidia/uvm_node.o nvidia/uvm_iface_exports.o nvidia/modeset_iface_exports.o nvidia/pci_driver.o nvidia/gpu_owner.o nvidia/pci_adapter.o nvidia/ga10x_adapter.o nvidia/dma_adapter.o nvidia/dmabuf_p2p.o nvidia/hwmon_adapter.o nvidia/irq_adapter.o nvidia/clock_adapter.o nvidia/clock_store_adapter.o nvidia/registry_adapter.o nvidia/software_manager_adapter.o nvidia/nano_timer_adapter.o nvidia/event_work_adapter.o nvidia/scheduling_adapter.o nvidia/thread_adapter.o nvidia/thread_state_adapter.o nvidia/memory_copy.o nvidia/rom_buffer.o nvidia/rom_fw_adapter.o nvidia/rom_acpi_adapter.o nvidia/rust-core.o
|
||||
# Record Kbuild command metadata for modpost, as with shipped binary objects.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
239
kernel-open/nvidia-modeset/nv_rs_kms_abi.h
Normal file
239
kernel-open/nvidia-modeset/nv_rs_kms_abi.h
Normal file
@ -0,0 +1,239 @@
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Clean-room internal KAPI & NVKMS ABI shared between standalone
|
||||
* nvidia_rs_modeset.ko and nvidia_rs_drm.ko (matching NVIDIA 580.178.04).
|
||||
*/
|
||||
#ifndef _NV_RS_KMS_ABI_H_
|
||||
#define _NV_RS_KMS_ABI_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#define NV_RS_KMS_MAX_GPUS 32
|
||||
#define NV_RS_KMS_MAX_HEADS 4
|
||||
#define NV_RS_KMS_MAX_CONNECTORS 16
|
||||
#define NV_RS_KMS_EDID_MAX_BYTES 2048
|
||||
|
||||
/* Exact 580.178.04 /dev/nvidia-modeset ioctl wrapper (nvkms-ioctl.h). */
|
||||
struct nv_rs_nvkms_ioctl_params {
|
||||
u32 cmd;
|
||||
u32 size;
|
||||
u64 address __aligned(8);
|
||||
};
|
||||
|
||||
#define NV_RS_NVKMS_IOCTL_MAGIC 'm'
|
||||
#define NV_RS_NVKMS_IOCTL_CMD 0
|
||||
#define NV_RS_NVKMS_IOCTL_IOWR \
|
||||
_IOWR(NV_RS_NVKMS_IOCTL_MAGIC, NV_RS_NVKMS_IOCTL_CMD, \
|
||||
struct nv_rs_nvkms_ioctl_params)
|
||||
|
||||
/* Must match Rust #[repr(C)] NvRsKmsGpuCaps in src/nvidia/kernel/modeset_ffi.rs. */
|
||||
struct nv_rs_kms_gpu_caps {
|
||||
u32 gpu_id;
|
||||
u32 boot0;
|
||||
u32 arch_family;
|
||||
u8 display_present;
|
||||
u8 is_gsp_rm;
|
||||
u8 max_heads;
|
||||
u8 max_sors;
|
||||
u8 max_windows;
|
||||
u8 generic_page_kind;
|
||||
u8 page_kind_generation;
|
||||
u8 sector_layout;
|
||||
u32 disp_class;
|
||||
u32 sf_user_class;
|
||||
u32 core_channel_class;
|
||||
u32 window_channel_class;
|
||||
u32 window_imm_channel_class;
|
||||
u32 cursor_channel_class;
|
||||
u32 reserved;
|
||||
u64 bar0_phys;
|
||||
u64 bar0_size;
|
||||
u64 bar1_phys;
|
||||
u64 bar1_size;
|
||||
void *os_device_ptr;
|
||||
};
|
||||
|
||||
/* Must match nv_gpu_info_t / NvGpuInfo in src/nvidia/src/gpu/display.rs. */
|
||||
struct nv_rs_modeset_gpu_info {
|
||||
u32 gpu_id;
|
||||
struct {
|
||||
u32 domain;
|
||||
u8 bus;
|
||||
u8 slot;
|
||||
u8 function;
|
||||
} pci_info;
|
||||
u8 needs_numa_setup;
|
||||
void *os_device_ptr;
|
||||
};
|
||||
|
||||
struct nv_rs_modeset_callbacks {
|
||||
void (*suspend)(u32 gpu_id);
|
||||
void (*resume)(u32 gpu_id);
|
||||
void (*remove)(u32 gpu_id);
|
||||
void (*probe)(const struct nv_rs_modeset_gpu_info *gpu_info);
|
||||
};
|
||||
|
||||
/* Connector signal/protocol types mapped cleanly to DRM_MODE_CONNECTOR_*. */
|
||||
enum nv_rs_kms_connector_type {
|
||||
NV_RS_KMS_CONN_UNKNOWN = 0,
|
||||
NV_RS_KMS_CONN_DP = 1,
|
||||
NV_RS_KMS_CONN_HDMI = 2,
|
||||
NV_RS_KMS_CONN_EDP = 3,
|
||||
NV_RS_KMS_CONN_DVI = 4,
|
||||
NV_RS_KMS_CONN_VGA = 5,
|
||||
NV_RS_KMS_CONN_VIRTUAL = 6,
|
||||
};
|
||||
|
||||
struct nv_rs_kms_connector_info {
|
||||
u32 dpy_id; /* NV0073 display ID bitmask */
|
||||
u32 physical_index;
|
||||
u32 sor_index;
|
||||
u32 possible_heads; /* Bitmask of heads able to drive this connector */
|
||||
u32 type; /* enum nv_rs_kms_connector_type */
|
||||
u8 connected;
|
||||
u8 is_dp_mst;
|
||||
u8 internal;
|
||||
u8 pad;
|
||||
};
|
||||
|
||||
struct nv_rs_kms_mode_timings {
|
||||
u32 pixel_clock_khz;
|
||||
u32 hdisplay;
|
||||
u32 hsync_start;
|
||||
u32 hsync_end;
|
||||
u32 htotal;
|
||||
u32 vdisplay;
|
||||
u32 vsync_start;
|
||||
u32 vsync_end;
|
||||
u32 vtotal;
|
||||
u32 flags;
|
||||
};
|
||||
|
||||
/* Must match Rust #[repr(C)] NvRsModesetVramAlloc in src/nvidia/kernel/modeset_ffi.rs. */
|
||||
struct nv_rs_modeset_vram_alloc {
|
||||
u64 vram_offset;
|
||||
u64 bar1_phys;
|
||||
u64 size;
|
||||
u64 token;
|
||||
u8 pte_kind;
|
||||
u8 bar1_mappable;
|
||||
u8 pad[6];
|
||||
};
|
||||
|
||||
/* Must match modeset_iface_exports.c nv_rs_modeset_dma_alloc / dma_free. */
|
||||
struct nv_rs_modeset_dma_buf {
|
||||
void *cpu_va;
|
||||
u64 dma_addr;
|
||||
u64 size;
|
||||
void *os_handle;
|
||||
};
|
||||
|
||||
struct nv_rs_kms_memory {
|
||||
u64 handle_id;
|
||||
u64 size;
|
||||
u32 page_count;
|
||||
u8 block_linear;
|
||||
u8 compressible;
|
||||
u8 is_vidmem;
|
||||
u8 no_scanout;
|
||||
u64 vram_offset;
|
||||
u64 vram_token;
|
||||
u64 bar1_phys;
|
||||
u32 rm_mem_handle;
|
||||
u32 rm_ctxdma_handle;
|
||||
struct page **pages;
|
||||
void *kmap_addr;
|
||||
u32 refcount;
|
||||
};
|
||||
|
||||
struct nv_rs_kms_head_commit {
|
||||
u32 head;
|
||||
u32 dpy_id;
|
||||
u8 enable;
|
||||
u8 tearing;
|
||||
u8 pad[2];
|
||||
struct nv_rs_kms_mode_timings mode;
|
||||
struct nv_rs_kms_memory *primary_mem;
|
||||
u32 fb_width;
|
||||
u32 fb_height;
|
||||
u32 fb_pitch;
|
||||
u32 fb_format; /* DRM_FORMAT_* fourcc */
|
||||
u64 fb_modifier; /* DRM_FORMAT_MOD_* */
|
||||
u32 fb_offset;
|
||||
struct nv_rs_kms_memory *cursor_mem;
|
||||
s32 cursor_x;
|
||||
s32 cursor_y;
|
||||
u32 cursor_w;
|
||||
u32 cursor_h;
|
||||
};
|
||||
|
||||
struct nv_rs_kms_device;
|
||||
struct nv_rs_kms_semsurf;
|
||||
struct nv_rs_kms_semsurf_waiter;
|
||||
|
||||
typedef void (*nv_rs_kms_semsurf_cb_t)(void *ctx);
|
||||
|
||||
struct nv_rs_kms_drm_callbacks {
|
||||
void (*gpu_probe)(u32 gpu_id);
|
||||
void (*gpu_remove)(u32 gpu_id);
|
||||
void (*gpu_suspend)(u32 gpu_id);
|
||||
void (*gpu_resume)(u32 gpu_id);
|
||||
void (*hotplug)(u32 gpu_id, u32 dpy_mask);
|
||||
void (*vblank)(u32 gpu_id, u32 head);
|
||||
};
|
||||
|
||||
struct nv_rs_kms_ops {
|
||||
u32 (*enumerate_gpus)(u32 *gpu_ids, u32 max_gpus);
|
||||
int (*set_drm_callbacks)(const struct nv_rs_kms_drm_callbacks *cb);
|
||||
|
||||
int (*open_device)(u32 gpu_id, struct nv_rs_kms_device **out_dev);
|
||||
void (*close_device)(struct nv_rs_kms_device *dev);
|
||||
|
||||
int (*get_gpu_caps)(struct nv_rs_kms_device *dev,
|
||||
struct nv_rs_kms_gpu_caps *out_caps);
|
||||
int (*query_connectors)(struct nv_rs_kms_device *dev,
|
||||
struct nv_rs_kms_connector_info *out_conns,
|
||||
u32 max_conns, u32 *out_count);
|
||||
int (*get_edid)(struct nv_rs_kms_device *dev, u32 dpy_id,
|
||||
u8 *buf, u32 buf_len, u32 *out_len);
|
||||
|
||||
struct nv_rs_kms_memory *(*alloc_memory)(struct nv_rs_kms_device *dev,
|
||||
u64 size, u8 block_linear,
|
||||
u8 compressible, u32 flags);
|
||||
struct nv_rs_kms_memory *(*import_memory)(struct nv_rs_kms_device *dev,
|
||||
u64 handle_id, u64 size);
|
||||
int (*export_memory)(struct nv_rs_kms_device *dev,
|
||||
struct nv_rs_kms_memory *mem, u64 *out_handle_id);
|
||||
void (*free_memory)(struct nv_rs_kms_device *dev,
|
||||
struct nv_rs_kms_memory *mem);
|
||||
|
||||
int (*commit_head)(struct nv_rs_kms_device *dev,
|
||||
const struct nv_rs_kms_head_commit *commit);
|
||||
int (*enable_vblank)(struct nv_rs_kms_device *dev, u32 head);
|
||||
void (*disable_vblank)(struct nv_rs_kms_device *dev, u32 head);
|
||||
int (*get_crc32)(struct nv_rs_kms_device *dev, u32 head,
|
||||
u32 *comp_crc, u32 *rg_crc, u32 *out_crc);
|
||||
|
||||
struct nv_rs_kms_semsurf *(*semsurf_create)(struct nv_rs_kms_device *dev,
|
||||
u64 size);
|
||||
void (*semsurf_destroy)(struct nv_rs_kms_device *dev,
|
||||
struct nv_rs_kms_semsurf *ss);
|
||||
u64 (*semsurf_read)(struct nv_rs_kms_semsurf *ss, u64 index);
|
||||
int (*semsurf_signal)(struct nv_rs_kms_semsurf *ss, u64 index, u64 value);
|
||||
int (*semsurf_register_waiter)(struct nv_rs_kms_semsurf *ss,
|
||||
u64 index, u64 wait_value,
|
||||
nv_rs_kms_semsurf_cb_t cb, void *ctx,
|
||||
struct nv_rs_kms_semsurf_waiter **out_waiter);
|
||||
void (*semsurf_cancel_waiter)(struct nv_rs_kms_semsurf *ss,
|
||||
struct nv_rs_kms_semsurf_waiter *waiter);
|
||||
|
||||
int (*grant_permissions)(struct nv_rs_kms_device *dev,
|
||||
s32 fd, u32 dpy_id, u32 type);
|
||||
int (*revoke_permissions)(struct nv_rs_kms_device *dev,
|
||||
u32 dpy_id, u32 type);
|
||||
};
|
||||
|
||||
int nv_rs_kms_get_ops(struct nv_rs_kms_ops *out_ops);
|
||||
|
||||
#endif /* _NV_RS_KMS_ABI_H_ */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user