Skip to content

Commit

Permalink
platforms/atomic-kms: More simplification
Browse files Browse the repository at this point in the history
Since we're not waiting for DRM events, we don't need
`ThreadedDRMEventHandler`.
  • Loading branch information
RAOF committed Nov 14, 2024
1 parent 1473905 commit 65be255
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 61 deletions.
5 changes: 1 addition & 4 deletions src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include "atomic_kms_output.h"
#include "kms-utils/drm_event_handler.h"
#include "kms-utils/drm_mode_resources.h"
#include "kms_framebuffer.h"
#include "mir/graphics/display_configuration.h"
Expand Down Expand Up @@ -187,10 +186,8 @@ class mga::AtomicKMSOutput::PropertyBlob
*/
mga::AtomicKMSOutput::AtomicKMSOutput(
mir::Fd drm_master,
kms::DRMModeConnectorUPtr connector,
std::shared_ptr<kms::DRMEventHandler> event_handler)
kms::DRMModeConnectorUPtr connector)
: drm_fd_{drm_master},
event_handler{std::move(event_handler)},
configuration{
Configuration {
.connector = std::move(connector),
Expand Down
8 changes: 1 addition & 7 deletions src/platforms/atomic-kms/server/kms/atomic_kms_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ namespace mir
{
namespace graphics
{
namespace kms
{
class DRMEventHandler;
}
namespace atomic
{

Expand All @@ -43,8 +39,7 @@ class AtomicKMSOutput : public KMSOutput
public:
AtomicKMSOutput(
mir::Fd drm_master,
kms::DRMModeConnectorUPtr connector,
std::shared_ptr<kms::DRMEventHandler> event_handler);
kms::DRMModeConnectorUPtr connector);
~AtomicKMSOutput();

uint32_t id() const override;
Expand Down Expand Up @@ -92,7 +87,6 @@ class AtomicKMSOutput : public KMSOutput
void restore_saved_crtc();

mir::Fd const drm_fd_;
std::shared_ptr<kms::DRMEventHandler> const event_handler;

std::future<void> pending_page_flip;

Expand Down
6 changes: 1 addition & 5 deletions src/platforms/atomic-kms/server/kms/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

#include "display.h"
#include "kms-utils/threaded_drm_event_handler.h"
#include "kms/egl_helper.h"
#include "mir/graphics/platform.h"
#include "platform.h"
Expand Down Expand Up @@ -147,14 +146,12 @@ mga::Display::Display(
std::shared_ptr<DisplayConfigurationPolicy> const& initial_conf_policy,
std::shared_ptr<DisplayReport> const& listener)
: drm_fd{std::move(drm_fd)},
event_handler{std::make_shared<kms::ThreadedDRMEventHandler>(this->drm_fd)},
gbm{std::move(gbm)},
listener(listener),
monitor(mir::udev::Context()),
output_container{
std::make_shared<RealKMSOutputContainer>(
this->drm_fd,
event_handler)},
this->drm_fd)},
current_display_configuration{output_container},
dirty_configuration{false},
bypass_option(bypass_option)
Expand Down Expand Up @@ -366,7 +363,6 @@ void mga::Display::configure_locked(
auto db = std::make_unique<DisplaySink>(
drm_fd,
gbm,
event_handler,
bypass_option,
listener,
std::move(kms_output),
Expand Down
7 changes: 0 additions & 7 deletions src/platforms/atomic-kms/server/kms/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef MIR_GRAPHICS_GBM_ATOMIC_KMS_DISPLAY_H_
#define MIR_GRAPHICS_GBM_ATOMIC_KMS_DISPLAY_H_

#include "kms-utils/drm_event_handler.h"
#include "mir/graphics/display.h"
#include "mir/udev/wrapper.h"
#include "real_kms_output_container.h"
Expand All @@ -40,11 +39,6 @@ class DisplayConfigurationPolicy;
class EventHandlerRegister;
class GLConfig;

namespace kms
{
class DRMEventHandler;
}

namespace atomic
{

Expand Down Expand Up @@ -91,7 +85,6 @@ class Display : public graphics::Display

mutable std::mutex configuration_mutex;
mir::Fd const drm_fd;
std::shared_ptr<kms::DRMEventHandler> const event_handler;
std::shared_ptr<struct gbm_device> const gbm;
std::shared_ptr<DisplayReport> const listener;
mir::udev::Monitor monitor;
Expand Down
18 changes: 1 addition & 17 deletions src/platforms/atomic-kms/server/kms/display_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ namespace mgk = mir::graphics::kms;
mga::DisplaySink::DisplaySink(
mir::Fd drm_fd,
std::shared_ptr<struct gbm_device> gbm,
std::shared_ptr<mgk::DRMEventHandler> event_handler,
mga::BypassOption,
std::shared_ptr<DisplayReport> const& listener,
std::shared_ptr<KMSOutput> output,
Expand All @@ -59,7 +58,6 @@ mga::DisplaySink::DisplaySink(
: gbm{std::move(gbm)},
listener(listener),
output{std::move(output)},
event_handler{std::move(event_handler)},
area(area),
transform{transformation},
needs_set_crtc{false}
Expand Down Expand Up @@ -170,7 +168,7 @@ void mga::DisplaySink::post()
* Try to schedule a page flip as first preference to avoid tearing.
* We wait synchronously for this to complete.
*/
if (!needs_set_crtc && !schedule_page_flip(*scheduled_fb))
if (!needs_set_crtc && !output->schedule_page_flip(*scheduled_fb))
needs_set_crtc = true;

/*
Expand Down Expand Up @@ -208,20 +206,6 @@ std::chrono::milliseconds mga::DisplaySink::recommended_sleep() const
return recommend_sleep;
}

bool mga::DisplaySink::schedule_page_flip(FBHandle const& bufobj)
{
/*
* Schedule the current front buffer object for display. Note that
* the page flip is asynchronous and synchronized with vertical refresh.
*/
if (output->schedule_page_flip(bufobj))
{
page_flip_pending = true;
return true;
}
return false;
}

void mga::DisplaySink::schedule_set_crtc()
{
needs_set_crtc = true;
Expand Down
8 changes: 0 additions & 8 deletions src/platforms/atomic-kms/server/kms/display_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef MIR_GRAPHICS_GBM_ATOMIC_KMS_DISPLAY_SINK_H_
#define MIR_GRAPHICS_GBM_ATOMIC_KMS_DISPLAY_SINK_H_

#include "kms-utils/drm_event_handler.h"
#include "mir/graphics/display_sink.h"
#include "mir/graphics/display.h"
#include "display_helpers.h"
Expand Down Expand Up @@ -57,7 +56,6 @@ class DisplaySink : public graphics::DisplaySink,
DisplaySink(
mir::Fd drm_fd,
std::shared_ptr<struct gbm_device> gbm,
std::shared_ptr<kms::DRMEventHandler> event_handler,
BypassOption bypass_options,
std::shared_ptr<DisplayReport> const& listener,
std::shared_ptr<KMSOutput> output,
Expand Down Expand Up @@ -89,18 +87,12 @@ class DisplaySink : public graphics::DisplaySink,
auto maybe_create_allocator(DisplayAllocator::Tag const& type_tag) -> DisplayAllocator* override;

private:
bool schedule_page_flip(FBHandle const& bufobj);
void set_crtc(FBHandle const&);

std::shared_ptr<struct gbm_device> const gbm;
bool holding_client_buffers{false};
std::shared_ptr<FBHandle const> bypass_bufobj{nullptr};
std::shared_ptr<DisplayReport> const listener;

std::shared_ptr<KMSOutput> const output;
bool page_flip_pending{false};

std::shared_ptr<kms::DRMEventHandler> const event_handler;

std::shared_ptr<CPUAddressableDisplayAllocator> kms_allocator;
std::unique_ptr<GBMDisplayAllocator> gbm_allocator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
#include <algorithm>
#include "real_kms_output_container.h"
#include "atomic_kms_output.h"
#include "kms-utils/drm_event_handler.h"
#include "kms-utils/drm_mode_resources.h"

namespace mga = mir::graphics::atomic;

mga::RealKMSOutputContainer::RealKMSOutputContainer(
mir::Fd drm_fd,
std::shared_ptr<kms::DRMEventHandler> event_handler)
: drm_fd{std::move(drm_fd)},
event_handler{std::move(event_handler)}
mir::Fd drm_fd)
: drm_fd{std::move(drm_fd)}
{
}

Expand Down Expand Up @@ -69,8 +66,7 @@ void mga::RealKMSOutputContainer::update_from_hardware_state()
{
new_outputs.push_back(std::make_shared<AtomicKMSOutput>(
drm_fd,
std::move(connector),
event_handler));
std::move(connector)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,20 @@ namespace mir
{
namespace graphics
{
namespace kms
{
class DRMEventHandler;
}

namespace atomic
{

class RealKMSOutputContainer : public KMSOutputContainer
{
public:
RealKMSOutputContainer(mir::Fd drm_fd, std::shared_ptr<kms::DRMEventHandler> event_handler);
RealKMSOutputContainer(mir::Fd drm_fd);

void for_each_output(std::function<void(std::shared_ptr<KMSOutput> const&)> functor) const override;

void update_from_hardware_state() override;
private:
mir::Fd const drm_fd;
std::shared_ptr<kms::DRMEventHandler> const event_handler;
std::vector<std::shared_ptr<KMSOutput>> outputs;
};

Expand Down

0 comments on commit 65be255

Please sign in to comment.