123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248 |
- #ifndef _AMDGPU_H_
- #define _AMDGPU_H_
- #include <stdint.h>
- #include <stdbool.h>
- struct drm_amdgpu_info_hw_ip;
- #define AMDGPU_CS_MAX_IBS_PER_SUBMIT 4
- #define AMDGPU_TIMEOUT_INFINITE 0xffffffffffffffffull
- #define AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE (1 << 0)
- enum amdgpu_bo_handle_type {
-
- amdgpu_bo_handle_type_gem_flink_name = 0,
-
- amdgpu_bo_handle_type_kms = 1,
-
- amdgpu_bo_handle_type_dma_buf_fd = 2
- };
- enum amdgpu_gpu_va_range
- {
-
- amdgpu_gpu_va_range_general = 0
- };
- typedef struct amdgpu_device *amdgpu_device_handle;
- typedef struct amdgpu_context *amdgpu_context_handle;
- typedef struct amdgpu_bo *amdgpu_bo_handle;
- typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
- typedef struct amdgpu_va *amdgpu_va_handle;
- typedef struct amdgpu_semaphore *amdgpu_semaphore_handle;
- struct amdgpu_bo_alloc_request {
-
- uint64_t alloc_size;
-
- uint64_t phys_alignment;
-
- uint32_t preferred_heap;
-
- uint64_t flags;
- };
- struct amdgpu_bo_metadata {
-
- uint64_t flags;
-
- uint64_t tiling_info;
-
- uint32_t size_metadata;
-
- uint32_t umd_metadata[64];
- };
- struct amdgpu_bo_info {
-
- uint64_t alloc_size;
-
- uint64_t phys_alignment;
-
- uint32_t preferred_heap;
-
- uint64_t alloc_flags;
-
- struct amdgpu_bo_metadata metadata;
- };
- struct amdgpu_bo_import_result {
-
- amdgpu_bo_handle buf_handle;
-
- uint64_t alloc_size;
- };
- struct amdgpu_gds_resource_info {
- uint32_t gds_gfx_partition_size;
- uint32_t compute_partition_size;
- uint32_t gds_total_size;
- uint32_t gws_per_gfx_partition;
- uint32_t gws_per_compute_partition;
- uint32_t oa_per_gfx_partition;
- uint32_t oa_per_compute_partition;
- };
- struct amdgpu_cs_fence {
-
- amdgpu_context_handle context;
-
- uint32_t ip_type;
-
- uint32_t ip_instance;
-
- uint32_t ring;
-
- uint64_t fence;
- };
- struct amdgpu_cs_ib_info {
-
- uint64_t flags;
-
- uint64_t ib_mc_address;
-
- uint32_t size;
- };
- struct amdgpu_cs_fence_info {
-
- amdgpu_bo_handle handle;
-
- uint64_t offset;
- };
- struct amdgpu_cs_request {
-
- uint64_t flags;
-
- unsigned ip_type;
-
- unsigned ip_instance;
-
- uint32_t ring;
-
- amdgpu_bo_list_handle resources;
-
- uint32_t number_of_dependencies;
-
- struct amdgpu_cs_fence *dependencies;
-
- uint32_t number_of_ibs;
-
- struct amdgpu_cs_ib_info *ibs;
-
- uint64_t seq_no;
-
- struct amdgpu_cs_fence_info fence_info;
- };
- struct amdgpu_buffer_size_alignments {
-
- uint64_t size_local;
-
- uint64_t size_remote;
- };
- struct amdgpu_heap_info {
-
- uint64_t heap_size;
-
- uint64_t heap_usage;
-
- uint64_t max_allocation;
- };
- struct amdgpu_gpu_info {
-
- uint32_t asic_id;
-
- uint32_t chip_rev;
-
- uint32_t chip_external_rev;
-
- uint32_t family_id;
-
- uint64_t ids_flags;
-
- uint64_t max_engine_clk;
-
- uint64_t max_memory_clk;
-
- uint32_t num_shader_engines;
-
- uint32_t num_shader_arrays_per_engine;
-
- uint32_t avail_quad_shader_pipes;
-
- uint32_t max_quad_shader_pipes;
-
- uint32_t cache_entries_per_quad_pipe;
-
- uint32_t num_hw_gfx_contexts;
-
- uint32_t rb_pipes;
-
- uint32_t enabled_rb_pipes_mask;
-
- uint32_t gpu_counter_freq;
-
- uint32_t backend_disable[4];
-
- uint32_t mc_arb_ramcfg;
-
- uint32_t gb_addr_cfg;
-
- uint32_t gb_tile_mode[32];
-
- uint32_t gb_macro_tile_mode[16];
-
- uint32_t pa_sc_raster_cfg[4];
-
- uint32_t pa_sc_raster_cfg1[4];
-
- uint32_t cu_active_number;
- uint32_t cu_ao_mask;
- uint32_t cu_bitmap[4][4];
-
- uint32_t vram_type;
-
- uint32_t vram_bit_width;
-
- uint32_t ce_ram_size;
-
- uint32_t vce_harvest_config;
-
- uint32_t pci_rev_id;
- };
- int amdgpu_device_initialize(int fd,
- uint32_t *major_version,
- uint32_t *minor_version,
- amdgpu_device_handle *device_handle);
- int amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
- int amdgpu_bo_alloc(amdgpu_device_handle dev,
- struct amdgpu_bo_alloc_request *alloc_buffer,
- amdgpu_bo_handle *buf_handle);
- int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle,
- struct amdgpu_bo_metadata *info);
- int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle,
- struct amdgpu_bo_info *info);
- int amdgpu_bo_export(amdgpu_bo_handle buf_handle,
- enum amdgpu_bo_handle_type type,
- uint32_t *shared_handle);
- int amdgpu_bo_import(amdgpu_device_handle dev,
- enum amdgpu_bo_handle_type type,
- uint32_t shared_handle,
- struct amdgpu_bo_import_result *output);
- int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
- void *cpu, uint64_t size,
- amdgpu_bo_handle *buf_handle);
- int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
- int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
- int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
- int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
- uint64_t timeout_ns,
- bool *buffer_busy);
- int amdgpu_bo_list_create(amdgpu_device_handle dev,
- uint32_t number_of_resources,
- amdgpu_bo_handle *resources,
- uint8_t *resource_prios,
- amdgpu_bo_list_handle *result);
- int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
- int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
- uint32_t number_of_resources,
- amdgpu_bo_handle *resources,
- uint8_t *resource_prios);
- int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
- amdgpu_context_handle *context);
- int amdgpu_cs_ctx_free(amdgpu_context_handle context);
- int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
- uint32_t *state, uint32_t *hangs);
- int amdgpu_cs_submit(amdgpu_context_handle context,
- uint64_t flags,
- struct amdgpu_cs_request *ibs_request,
- uint32_t number_of_requests);
- int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
- uint64_t timeout_ns,
- uint64_t flags,
- uint32_t *expired);
- int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev,
- struct amdgpu_buffer_size_alignments
- *info);
- int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
- unsigned ip_instance, unsigned index,
- uint32_t *version, uint32_t *feature);
- int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type,
- uint32_t *count);
- int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type,
- unsigned ip_instance,
- struct drm_amdgpu_info_hw_ip *info);
- int amdgpu_query_heap_info(amdgpu_device_handle dev, uint32_t heap,
- uint32_t flags, struct amdgpu_heap_info *info);
- int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id,
- int32_t *result);
- int amdgpu_query_gpu_info(amdgpu_device_handle dev,
- struct amdgpu_gpu_info *info);
- int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id,
- unsigned size, void *value);
- int amdgpu_query_gds_info(amdgpu_device_handle dev,
- struct amdgpu_gds_resource_info *gds_info);
- int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset,
- unsigned count, uint32_t instance, uint32_t flags,
- uint32_t *values);
- #define AMDGPU_VA_RANGE_32_BIT 0x1
- int amdgpu_va_range_alloc(amdgpu_device_handle dev,
- enum amdgpu_gpu_va_range va_range_type,
- uint64_t size,
- uint64_t va_base_alignment,
- uint64_t va_base_required,
- uint64_t *va_base_allocated,
- amdgpu_va_handle *va_range_handle,
- uint64_t flags);
- int amdgpu_va_range_free(amdgpu_va_handle va_range_handle);
- int amdgpu_va_range_query(amdgpu_device_handle dev,
- enum amdgpu_gpu_va_range type,
- uint64_t *start,
- uint64_t *end);
- int amdgpu_bo_va_op(amdgpu_bo_handle bo,
- uint64_t offset,
- uint64_t size,
- uint64_t addr,
- uint64_t flags,
- uint32_t ops);
- int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem);
- int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
- uint32_t ip_type,
- uint32_t ip_instance,
- uint32_t ring,
- amdgpu_semaphore_handle sem);
- int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
- uint32_t ip_type,
- uint32_t ip_instance,
- uint32_t ring,
- amdgpu_semaphore_handle sem);
- int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
- #endif
|