Mentions légales du service

Skip to content
Snippets Groups Projects
Verified Commit 36c6fc9b authored by Mattéo Delabre's avatar Mattéo Delabre
Browse files

Add support for full screen updates

parent 9e93ad3c
No related branches found
No related tags found
No related merge requests found
#include "mxcfb.hpp"
#include "screen.hpp"
#include "mxcfb.hpp"
#include <cerrno>
#include <cstdint>
#include <system_error>
......@@ -74,7 +74,7 @@ screen::~screen()
this->framebuf_fd = -1;
}
void screen::update(int x, int y, int w, int h)
void screen::update(int x, int y, int w, int h, bool wait)
{
// Clip update region to screen bounds
if (x < 0)
......@@ -117,7 +117,28 @@ void screen::update(int x, int y, int w, int h)
update.temp = mxcfb::temps::normal;
update.update_mode = mxcfb::update_modes::partial;
update.flags = 0;
update.update_marker = 0;
this->send_update(update, wait);
}
void screen::update(bool wait)
{
mxcfb::update_data update{};
update.update_region.left = 0;
update.update_region.top = 0;
update.update_region.width = this->get_xres();
update.update_region.height = this->get_yres();
update.waveform_mode = mxcfb::waveform_modes::gc16;
update.temp = mxcfb::temps::normal;
update.update_mode = mxcfb::update_modes::full;
update.flags = 0;
this->send_update(update, wait);
}
void screen::send_update(mxcfb::update_data& update, bool wait)
{
update.update_marker = this->next_update_marker;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg): Use of C library
if (ioctl(this->framebuf_fd, mxcfb::send_update, &update) == -1)
......@@ -125,9 +146,37 @@ void screen::update(int x, int y, int w, int h)
throw std::system_error(
errno,
std::generic_category(),
"(rmioc::screen::update) Send update"
"(rmioc::screen::send_update) Screen update"
);
}
if (!wait)
{
return;
}
mxcfb::update_marker_data data{};
data.update_marker = this->next_update_marker;
data.collision_test = 0;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg): Use of C library
if (ioctl(this->framebuf_fd, mxcfb::wait_for_update_complete, &data) == -1)
{
throw std::system_error(
errno,
std::generic_category(),
"(rmioc::screen::send_update) Wait for update completion"
);
}
if (this->next_update_marker == rmioc::screen::max_update_marker)
{
this->next_update_marker = 1;
}
else
{
++this->next_update_marker;
}
}
auto screen::get_data() -> std::uint8_t*
......
......@@ -4,6 +4,8 @@
#include <cstdint>
#include <linux/fb.h>
namespace mxcfb { struct update_data; }
namespace rmioc
{
......@@ -17,14 +19,22 @@ public:
~screen();
/**
* Update the given region of the screen.
* Update a partial region of the screen.
*
* @param x Left bound of the region to update (in pixels).
* @param y Top bound of the region to update (in pixels).
* @param w Width of the region to update (in pixels).
* @param h Height of the region to update (in pixels).
* @param wait True to wait until update is complete.
*/
void update(int x, int y, int w, int h, bool wait = false);
/**
* Perform a full update of the screen (will flash).
*
* @param wait True to wait until update is complete.
*/
void update(int x, int y, int w, int h);
void update(bool wait = true);
/**
* Access the screen data buffer.
......@@ -74,7 +84,21 @@ private:
fb_fix_screeninfo framebuf_fixinfo{};
/** Pointer to the memory-mapped framebuffer. */
uint8_t* framebuf_ptr = nullptr;
std::uint8_t* framebuf_ptr = nullptr;
/**
* Send an update object to the framebuffer driver.
*
* @param update Update object to send.
* @param wait True to wait until update is complete.
*/
void send_update(mxcfb::update_data& update, bool wait);
/** Next value to be used as an update marker. */
std::uint32_t next_update_marker = 1;
/** Maximum value to use for update markers. */
static constexpr std::uint32_t max_update_marker = 255;
}; // class screen
} // namespace rmioc
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment