123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- #ifndef __NV_DRM_RENDERER_H__
- #define __NV_DRM_RENDERER_H__
- #include "NvElement.h"
- #include <stdint.h>
- #include <pthread.h>
- #include <queue>
- #include <unordered_map>
- typedef struct _NvDrmBO {
- uint32_t bo_handle;
- int width;
- int height;
- int pitch;
- uint8_t* data;
- } NvDrmBO;
- typedef struct _NvDrmFB {
- uint32_t fb_id;
- int width;
- int height;
- int format;
- NvDrmBO bo[4];
- int num_buffers;
- } NvDrmFB;
- class NvDrmRenderer:public NvElement
- {
- public:
-
- static NvDrmRenderer *createDrmRenderer(const char *name, uint32_t width,
- uint32_t height, uint32_t w_x, uint32_t w_y,
- uint32_t connector, uint32_t crtc,
- struct drm_tegra_hdr_metadata_smpte_2086 metadata,
- bool streamHDR);
- ~NvDrmRenderer();
-
- int enqueBuffer(int fd);
-
- int dequeBuffer();
-
- int setFPS(float fps);
-
- bool enableUniversalPlanes(int enable);
-
- uint32_t createDumbFB(uint32_t width, uint32_t height, uint32_t drm_format, NvDrmFB *fb);
-
- int removeFB(uint32_t fb_id);
-
- int drmUtilCloseGemBo(int fd, uint32_t bo_handle);
-
- int setPlane(uint32_t pl_index,
- uint32_t fb_id,
- uint32_t crtc_x,
- uint32_t crtc_y,
- uint32_t crtc_w,
- uint32_t crtc_h,
- uint32_t src_x,
- uint32_t src_y,
- uint32_t src_w,
- uint32_t src_h);
-
- int getPlaneCount();
-
- int getPlaneIndex(uint32_t crtc_index,
- int32_t* plane_index);
-
- int getCrtcCount();
-
- int getEncoderCount();
-
- bool hdrSupported();
-
- int setHDRMetadataSmpte2086(struct drm_tegra_hdr_metadata_smpte_2086);
- private:
- struct timespec last_render_time;
- int drm_fd;
- int conn, crtc;
- uint32_t width, height;
- uint32_t drm_conn_id;
- uint32_t drm_enc_id;
- uint32_t drm_crtc_id;
- uint32_t last_fb;
- int activeFd;
- int flippedFd;
- bool flipPending;
- bool renderingStarted;
- bool is_nvidia_drm;
- uint32_t hdrBlobId;
- bool hdrBlobCreated;
- std::queue<int> freeBuffers;
- std::queue<int> pendingBuffers;
- std::unordered_map <int, int> map_list;
- bool stop_thread;
- pthread_t render_thread;
- pthread_mutex_t render_lock;
- pthread_cond_t render_cond;
- pthread_mutex_t enqueue_lock;
- pthread_cond_t enqueue_cond;
- pthread_mutex_t dequeue_lock;
- pthread_cond_t dequeue_cond;
- float fps;
- uint64_t render_time_sec;
- uint64_t render_time_nsec;
-
- NvDrmRenderer(const char *name, uint32_t width, uint32_t height,
- uint32_t w_x, uint32_t w_y, uint32_t connector, uint32_t crtc,
- struct drm_tegra_hdr_metadata_smpte_2086 metadata, bool streamHDR);
-
- static void * renderThread(void *arg);
- static void * renderThreadOrin(void *arg);
-
- static void page_flip_handler(int fd, unsigned int frame,
- unsigned int sec, unsigned int usec, void *data);
-
- int renderInternal(int fd);
-
- int createDumbBO(int w, int h, int bpp, NvDrmBO *bo);
- static const NvElementProfiler::ProfilerField valid_fields =
- NvElementProfiler::PROFILER_FIELD_TOTAL_UNITS |
- NvElementProfiler::PROFILER_FIELD_FPS |
- NvElementProfiler::PROFILER_FIELD_LATE_UNITS;
- };
- #endif
|