diff options
Diffstat (limited to 'kms++util/inc')
-rw-r--r-- | kms++util/inc/kms++util/color.h | 9 | ||||
-rw-r--r-- | kms++util/inc/kms++util/cpuframebuffer.h | 8 | ||||
-rw-r--r-- | kms++util/inc/kms++util/extcpuframebuffer.h | 5 | ||||
-rw-r--r-- | kms++util/inc/kms++util/kms++util.h | 43 | ||||
-rw-r--r-- | kms++util/inc/kms++util/opts.h | 1 | ||||
-rw-r--r-- | kms++util/inc/kms++util/resourcemanager.h | 9 | ||||
-rw-r--r-- | kms++util/inc/kms++util/strhelpers.h | 4 | ||||
-rw-r--r-- | kms++util/inc/kms++util/videodevice.h | 8 |
8 files changed, 45 insertions, 42 deletions
diff --git a/kms++util/inc/kms++util/color.h b/kms++util/inc/kms++util/color.h index 2bf6e66..5232b37 100644 --- a/kms++util/inc/kms++util/color.h +++ b/kms++util/inc/kms++util/color.h @@ -14,8 +14,7 @@ enum class YUVType { MAX, }; -struct RGB -{ +struct RGB { RGB(); RGB(uint8_t r, uint8_t g, uint8_t b); RGB(uint8_t a, uint8_t r, uint8_t g, uint8_t b); @@ -34,6 +33,7 @@ struct RGB uint32_t rgba1010102() const; uint32_t bgra1010102() const; + uint8_t rgb332() const; uint16_t rgb565() const; uint16_t bgr565() const; uint16_t argb4444() const; @@ -46,8 +46,7 @@ struct RGB uint8_t a; }; -struct YUV -{ +struct YUV { YUV(); YUV(uint8_t y, uint8_t u, uint8_t v); YUV(const RGB& rgb, YUVType type = YUVType::BT601_Lim); @@ -57,4 +56,4 @@ struct YUV uint8_t y; uint8_t a; }; -} +} // namespace kms diff --git a/kms++util/inc/kms++util/cpuframebuffer.h b/kms++util/inc/kms++util/cpuframebuffer.h index 4273e0d..e4de150 100644 --- a/kms++util/inc/kms++util/cpuframebuffer.h +++ b/kms++util/inc/kms++util/cpuframebuffer.h @@ -4,8 +4,8 @@ namespace kms { - -class CPUFramebuffer : public IFramebuffer { +class CPUFramebuffer : public IFramebuffer +{ public: CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat format); @@ -30,7 +30,7 @@ private: uint32_t size; uint32_t stride; uint32_t offset; - uint8_t *map; + uint8_t* map; }; uint32_t m_width; @@ -41,4 +41,4 @@ private: struct FramebufferPlane m_planes[4]; }; -} +} // namespace kms diff --git a/kms++util/inc/kms++util/extcpuframebuffer.h b/kms++util/inc/kms++util/extcpuframebuffer.h index 92ca43a..29a06c0 100644 --- a/kms++util/inc/kms++util/extcpuframebuffer.h +++ b/kms++util/inc/kms++util/extcpuframebuffer.h @@ -4,7 +4,6 @@ namespace kms { - class ExtCPUFramebuffer : public IFramebuffer { public: @@ -30,7 +29,7 @@ private: uint32_t size; uint32_t stride; uint32_t offset; - uint8_t *map; + uint8_t* map; }; uint32_t m_width; @@ -40,4 +39,4 @@ private: unsigned m_num_planes; struct FramebufferPlane m_planes[4]; }; -} +} // namespace kms diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h index 62ec663..52b6ce9 100644 --- a/kms++util/inc/kms++util/kms++util.h +++ b/kms++util/inc/kms++util/kms++util.h @@ -18,17 +18,18 @@ namespace kms class IFramebuffer; void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color); +void draw_yuv444_pixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv); void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2); void draw_yuv420_macropixel(IFramebuffer& buf, unsigned x, unsigned y, - YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4); -void draw_rect(IFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color); + YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4); +void draw_rect(IFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color); void draw_circle(IFramebuffer& fb, int32_t xCenter, int32_t yCenter, int32_t radius, RGB color); void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const std::string& str, RGB color); void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width); -void draw_test_pattern(IFramebuffer &fb, YUVType yuvt = YUVType::BT601_Lim); -} +void draw_test_pattern(IFramebuffer& fb, YUVType yuvt = YUVType::BT601_Lim); +} // namespace kms #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -41,32 +42,32 @@ void draw_test_pattern(IFramebuffer &fb, YUVType yuvt = YUVType::BT601_Lim); #define __STRING(x) #x #endif -#define ASSERT(x) \ - if (unlikely(!(x))) { \ +#define ASSERT(x) \ + if (unlikely(!(x))) { \ fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, __STRING(x)); \ - abort(); \ + abort(); \ } -#define FAIL(fmt, ...) \ - do { \ +#define FAIL(fmt, ...) \ + do { \ fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \ - abort(); \ - } while(0) + abort(); \ + } while (0) -#define FAIL_IF(x, fmt, ...) \ - if (unlikely(x)) { \ +#define FAIL_IF(x, fmt, ...) \ + if (unlikely(x)) { \ fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \ - abort(); \ + abort(); \ } -#define EXIT(fmt, ...) \ - do { \ +#define EXIT(fmt, ...) \ + do { \ fprintf(stderr, fmt "\n", ##__VA_ARGS__); \ - exit(-1); \ - } while(0) + exit(-1); \ + } while (0) -#define EXIT_IF(x, fmt, ...) \ - if (unlikely(x)) { \ +#define EXIT_IF(x, fmt, ...) \ + if (unlikely(x)) { \ fprintf(stderr, fmt "\n", ##__VA_ARGS__); \ - exit(-1); \ + exit(-1); \ } diff --git a/kms++util/inc/kms++util/opts.h b/kms++util/inc/kms++util/opts.h index 1b0fd22..6058b27 100644 --- a/kms++util/inc/kms++util/opts.h +++ b/kms++util/inc/kms++util/opts.h @@ -7,6 +7,7 @@ class Option { friend class OptionSet; + public: Option(const std::string& str, std::function<void()> func); Option(const std::string& str, std::function<void(const std::string)> func); diff --git a/kms++util/inc/kms++util/resourcemanager.h b/kms++util/inc/kms++util/resourcemanager.h index 1b5cf21..11c11b3 100644 --- a/kms++util/inc/kms++util/resourcemanager.h +++ b/kms++util/inc/kms++util/resourcemanager.h @@ -2,8 +2,8 @@ #include <set> #include <string> -namespace kms { - +namespace kms +{ class ResourceManager { public: @@ -14,13 +14,16 @@ public: Card& card() const { return m_card; } Connector* reserve_connector(const std::string& name = ""); Connector* reserve_connector(Connector* conn); + void release_connector(Connector* conn); Crtc* reserve_crtc(Connector* conn); Crtc* reserve_crtc(Crtc* crtc); + void release_crtc(Crtc* crtc); Plane* reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format = PixelFormat::Undefined); Plane* reserve_plane(Plane* plane); Plane* reserve_generic_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined); Plane* reserve_primary_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined); Plane* reserve_overlay_plane(Crtc* crtc, PixelFormat format = PixelFormat::Undefined); + void release_plane(Plane* plane); private: Card& m_card; @@ -29,4 +32,4 @@ private: std::set<Plane*> m_reserved_planes; }; -} +} // namespace kms diff --git a/kms++util/inc/kms++util/strhelpers.h b/kms++util/inc/kms++util/strhelpers.h index 2d35e93..c4032d7 100644 --- a/kms++util/inc/kms++util/strhelpers.h +++ b/kms++util/inc/kms++util/strhelpers.h @@ -5,7 +5,7 @@ std::string to_lower(const std::string& str); -template <typename T> +template<typename T> std::string join(const T& values, const std::string& delim) { std::ostringstream ss; @@ -17,7 +17,7 @@ std::string join(const T& values, const std::string& delim) return ss.str(); } -template <typename T> +template<typename T> std::string join(const std::vector<T>& values, const std::string& delim, std::function<std::string(T)> func) { std::ostringstream ss; diff --git a/kms++util/inc/kms++util/videodevice.h b/kms++util/inc/kms++util/videodevice.h index e089bcd..3bce4a9 100644 --- a/kms++util/inc/kms++util/videodevice.h +++ b/kms++util/inc/kms++util/videodevice.h @@ -1,6 +1,7 @@ #pragma once #include <string> +#include <memory> #include <kms++/kms++.h> class VideoStreamer; @@ -8,8 +9,7 @@ class VideoStreamer; class VideoDevice { public: - struct VideoFrameSize - { + struct VideoFrameSize { uint32_t min_w, max_w, step_w; uint32_t min_h, max_h, step_h; }; @@ -50,8 +50,8 @@ private: std::vector<kms::DumbFramebuffer*> m_capture_fbs; std::vector<kms::DumbFramebuffer*> m_output_fbs; - VideoStreamer* m_capture_streamer; - VideoStreamer* m_output_streamer; + std::unique_ptr<VideoStreamer> m_capture_streamer; + std::unique_ptr<VideoStreamer> m_output_streamer; }; class VideoStreamer |