Skip to content

Conversation

@asivery
Copy link

@asivery asivery commented Feb 26, 2025

The pen input device is flipped, and refreshes are slow, but other than that, it works :)

Summary by CodeRabbit

  • New Features

    • Added support for the reMarkable Paper Pro with updated screen and touch parameters.
    • Introduced dynamic screen scaling that adapts display dimensions based on device settings, enhancing refresh accuracy.
  • Bug Fixes

    • Removed deprecated ePaper support to streamline system initialization.
    • Adjusted display update methods for more consistent and responsive rendering.

These improvements provide a more reliable and visually optimized experience across different devices.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

📝 Walkthrough

Walkthrough

This pull request updates several components related to display and device settings. In the display server, the rectangle data used for GUI updates now comes from an auxiliary buffer rather than the main framebuffer, and framebuffer update methods have been simplified. The EPAPER feature has been removed from the main configuration. Additionally, dynamic screen dimensions are now used across multiple modules, and support for a new device type ("reMarkable Paper Pro") has been added. The ePaper library’s build configuration and EPFramebuffer API have been restructured to accommodate these changes.

Changes

File(s) Change Summary
applications/display-server/dbusinterface.cpp
applications/display-server/guithread.cpp
applications/display-server/main.cpp
Moved rectangle retrieval from main framebuffer to auxiliary buffer in GUI update methods; updated GUIThread’s framebuffer file descriptor initialization and simplified sendUpdate logic; removed EPAPER preprocessor directives from main.
applications/settings-manager/main.cpp Fixed meta type resolution by replacing the undefined variable type with the correct typeName when calling QMetaType::fromName().
applications/system-service/apibase.cpp
applications/system-service/screenapi.h
Replaced hardcoded framebuffer dimensions with dynamic values from deviceSettings.getScreenWidth() and getScreenHeight(), ensuring the image and screen definitions adapt to runtime device settings.
shared/epaper/epaper.pro
shared/epaper/epframebuffer.h
Restructured the ePaper library build configuration by changing the TEMPLATE type and modifying header installation steps; updated EPFramebuffer API by adding new buffer constants, methods (initialize(), sync()), and a new class (EPFramebufferFusion) to manage buffer operations across architectures.
shared/liboxide/devicesettings.cpp
shared/liboxide/devicesettings.h
Extended the DeviceSettings class with support for the new device type RMPP ("reMarkable Paper Pro") and added methods getScreenWidth() and getScreenHeight() to return dynamic screen dimensions.
shared/liboxide/eventfilter.cpp
shared/qpa/oxideeventfilter.cpp
shared/qpa/oxideintegration.cpp
Updated definitions of DISPLAYWIDTH and DISPLAYHEIGHT to dynamically use deviceSettings.getScreenWidth() and getScreenHeight(); adjusted the screen geometry in OxideIntegration to reflect runtime device dimensions.

Sequence Diagram(s)

sequenceDiagram
    participant DBusInterface
    participant GUIThread
    participant EPFramebuffer
    participant Driver

    %% Display update flow initiated from a DBus event
    DBusInterface->>GUIThread: Trigger exitExclusiveMode/exclusiveModeRepaint
    GUIThread->>EPFramebuffer: Retrieve auxBuffer rectangle data
    EPFramebuffer-->>GUIThread: Return rectangle dimensions
    GUIThread->>Driver: Call swapBuffers(Color, QualityMode, CompleteRefresh)
Loading

Poem

Oh, I hop with joy so light,
Auxiliary buffers make the update bright.
From main to aux, the pixels leap,
Dynamic screens no longer sleep.
In settings and code, the magic's spun—
A rabbit’s cheer: “Tech hops, fun’s begun!”
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@asivery asivery changed the title New libqgsepaper and initial rMPP support New libqsgepaper and initial rMPP support Feb 26, 2025
@Eeems
Copy link
Collaborator

Eeems commented Feb 26, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (7)
shared/liboxide/devicesettings.cpp (1)

167-172: Fix inconsistent indentation.

The indentation in the getTouchHeight() method is inconsistent after adding the RMPP case. The default: case and subsequent lines should be aligned with the other cases.

            case DeviceType::RMPP:
                return 2832;
-            default:
-                return 0;
-        }
-    }
+           default:
+               return 0;
+       }
+   }
shared/liboxide/eventfilter.cpp (1)

14-15: Consider replacing macros with inline functions.
Using macros for DISPLAYWIDTH and DISPLAYHEIGHT can reduce type safety and hinder debugging. Inline functions or static constants can serve the same purpose while offering clearer semantics.

-#define DISPLAYWIDTH (deviceSettings.getScreenWidth())
-#define DISPLAYHEIGHT (deviceSettings.getScreenHeight())
+static inline int displayWidth() {
+    return deviceSettings.getScreenWidth();
+}
+static inline int displayHeight() {
+    return deviceSettings.getScreenHeight();
+}
applications/display-server/guithread.cpp (1)

76-78: Offer to help with memfd_create implementation.
The TODO suggests a plan to switch from /dev/null to a dynamically created file descriptor. Let me know if you'd like assistance implementing this feature.

shared/epaper/epframebuffer.h (4)

42-42: Factory-method pointer return.
Returning a raw pointer is typical in singletons/factory methods, but consider returning by reference or using a smart pointer if you need stronger lifetime guarantees.


47-48: Add documentation for newly introduced methods.
These initialize() and sync() methods are self-explanatory, but additional doc comments clarifying their usage and preconditions might help maintainability.


52-68: Check layout consistency in EPFramebufferAcep2.
This class relies on carefully placed buffers and the size of QImage. Changes in Qt versions or compilers may cause alignment or size-differences, leading to potential memory corruption.

If you’d like, I can provide a shell script to search for any references that might incorrectly cast or offset these buffer members.


70-85: Ensure robust handling of EPFramebufferFusion memory layout.
Similar to EPFramebufferAcep2, this class uses partially opaque data and members relying on specific offset sizes. Confirm that sizeof(QImage) is stable on ARM builds to avoid out-of-bounds access.

Would you like me to generate a web search query to investigate QImage size consistency across Qt builds?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d1f7f7f and 3de9444.

⛔ Files ignored due to path filters (1)
  • shared/epaper/libqsgepaper.so is excluded by !**/*.so
📒 Files selected for processing (13)
  • applications/display-server/dbusinterface.cpp (2 hunks)
  • applications/display-server/guithread.cpp (5 hunks)
  • applications/display-server/main.cpp (0 hunks)
  • applications/settings-manager/main.cpp (1 hunks)
  • applications/system-service/apibase.cpp (1 hunks)
  • applications/system-service/screenapi.h (1 hunks)
  • shared/epaper/epaper.pro (1 hunks)
  • shared/epaper/epframebuffer.h (3 hunks)
  • shared/liboxide/devicesettings.cpp (4 hunks)
  • shared/liboxide/devicesettings.h (2 hunks)
  • shared/liboxide/eventfilter.cpp (1 hunks)
  • shared/qpa/oxideeventfilter.cpp (2 hunks)
  • shared/qpa/oxideintegration.cpp (1 hunks)
💤 Files with no reviewable changes (1)
  • applications/display-server/main.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (22)
shared/liboxide/devicesettings.h (2)

29-30: LGTM: Device type enum updated correctly.

The addition of the RMPP device type to the enum with proper documentation looks good.


78-87: LGTM: New screen dimension methods well documented.

The new methods for retrieving screen dimensions are properly documented and follow the existing code style pattern.

applications/system-service/screenapi.h (1)

20-23: Good improvement: Dynamic screen dimensions.

Replacing hardcoded screen dimensions with dynamic values from deviceSettings improves flexibility and allows for better support of different device types.

shared/qpa/oxideeventfilter.cpp (2)

9-9: LGTM: Required header added.

Adding the deviceSettings header is appropriate for accessing the screen dimension methods.


88-89: Good improvement: Dynamic screen dimensions.

Replacing hardcoded dimensions with dynamic values from deviceSettings enhances device compatibility and maintainability.

shared/liboxide/devicesettings.cpp (5)

128-129: LGTM: Device name added appropriately.

Adding the proper display name for the new device type is good.


154-155: LGTM: Touch dimensions added for new device.

Touch input dimensions added correctly for the RMPP device.


174-196: LGTM: Screen dimension methods implemented correctly.

The implementations for getScreenWidth() and getScreenHeight() look good, providing appropriate values for each device type.


106-110:

Details

❓ Verification inconclusive

Verify device identification method.

Using "reMarkable Ferrari" to identify the RMPP device seems like a development codename rather than a production identifier. Consider if this is the final identification string that will be used in production.


🏁 Script executed:

#!/bin/bash
# Check if there are any references to the final device name in the codebase
echo "Searching for references to reMarkable Ferrari and other device identifiers..."
rg -A 2 -B 2 "reMarkable Ferrari" --glob "!*.md"

Length of output: 563


Action: Confirm the Device Identifier

In shared/liboxide/devicesettings.cpp (lines 106–110), the code checks if the model name contains "reMarkable Ferrari". This string appears to be a development codename rather than a finalized production identifier for the RMPP device. Please verify whether "reMarkable Ferrari" is indeed the intended identifier for production or if it should be updated to reflect the correct final device name.


141-142:

Details

❓ Verification inconclusive

Verify touch environment setting for RMPP.

The RMPP device has an empty touch environment setting. Confirm if this is intentional or if specific settings are needed for proper touch input orientation.


🏁 Script executed:

#!/bin/bash
# Look for any rotation or inversion settings for RMPP elsewhere in the codebase
echo "Searching for touch orientation settings for RMPP..."
rg -A 3 -B 3 "RMPP.*rotate|rotate.*RMPP" --glob "!*.md"
rg -A 3 -B 3 "touchscreen.*orientation|orientation.*touchscreen" --glob "!*.md"

Length of output: 254


I'll need to gather a bit more context before finalizing the review comment. Could you please run an additional verification script to further search for any RMPP-specific touch or orientation configurations in the codebase? For example, a script that searches for general mentions of "RMPP" and entries that might involve "touch" or "orientation" might shed more light on whether the empty setting for RMPP is intentional.

Below is a proposed script for re-verification:

Once you have the output from this script, we can better determine if the empty touch environment setting for the RMPP device is deliberate or if further adjustments are needed.


🏁 Script executed:

[run_scripts]
#!/bin/bash
echo "Searching for any mention of RMPP in the codebase..."
rg "RMPP" --glob "!*.md"

echo "Searching for RMPP touch related settings..."
rg -A 5 -B 5 "RMPP.*touch" --glob "!*.md"

Length of output: 1060


Action Required: Verify RMPP Touch Configuration

After searching the codebase, we found several references to RMPP in shared/liboxide/devicesettings.cpp and shared/liboxide/devicesettings.h, but no evidence of any dedicated touch orientation or inversion settings for this device type. This suggests that returning an empty string for the RMPP touch environment might be intentional.

  • The code snippet in question:
                case DeviceType::RMPP:
                    return "";
  • Our searches for keywords like rotate, touch, and orientation in relation to RMPP did not reveal any additional configurations.
  • Next Step: Please verify against the product specifications or with the relevant stakeholders whether the empty touch environment setting for RMPP is by design or if specific parameters (e.g., rotation or inversion settings) should be applied.
shared/liboxide/eventfilter.cpp (1)

12-12: No issues with new include.
This header inclusion is necessary for accessing deviceSettings.

applications/display-server/guithread.cpp (4)

64-64: Validate auxiliary buffer geometry.
Before creating GUIThread with auxBuffer.rect(), consider handling edge cases where the auxiliary buffer might not be initialized or has a zero-size rectangle. This helps prevent potential runtime errors.


79-79: Ensure correct usage of /dev/null.
Opening /dev/null is likely a temporary placeholder and won't provide meaningful read/write operations for a framebuffer. Confirm that this usage is intentional and doesn't break any downstream logic.


179-185: Clear function logic looks consistent.
Clearing the auxiliary buffer with white and issuing a complete refresh appears correct. Verify whether additional error handling is needed for swapBuffers() failures.


230-230: Aux buffer usage confirmed.
Switching to auxBuffer is aligned with the new approach. No issues here.

shared/epaper/epaper.pro (4)

4-4: TEMPLATE changed to aux.
Switching from lib to aux is unorthodox. Ensure this aligns with the intended build artifacts and doesn't break downstream usage.


6-7: Copying .so and header together could be fragile.
Copying the library file in the same command as the header may cause unexpected issues if either path changes or if the shared object isn't built yet. Confirm build order or consider separate targets.


11-11: Installing multiple files.
Including both the header and the .so in epframebuffer_h_install.files broadens deployment scope. Double-check that this matches your packaging requirements and doesn't omit versioned library handling.


16-17: Review new dependencies and clean rules.
PRE_TARGETDEPS and QMAKE_CLEAN now include the raw_copy target. Ensure these additions align with your build steps and that cleaning removes all generated artifacts.

shared/epaper/epframebuffer.h (3)

11-13: Validate newly introduced macros for reMarkable 2.
These macros are derived from disassembly and may change in future library updates. Consider maintaining them in a single source of truth or verifying them dynamically to avoid misalignment.

If you’d like, I can provide a shell script or a web search query to confirm these offsets match the actual structure size.


15-19: Confirm architecture detection logic.
The definition of DEFAULT_EPFR_RETURN differs across __aarch64__ and the fallback. Ensure that reMarkable 2 builds consistently match the intended macro.


40-40: Signature looks good.
The revised parameter list and default argument appear consistent with usage patterns. No issues spotted.

return nullptr;
}
image = new QImage(data, 1404, 1872, stride, QImage::Format_RGB16);
image = new QImage(data, deviceSettings.getScreenWidth(), deviceSettings.getScreenHeight(), stride, QImage::Format_RGB16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace hardcoded dimensions with dynamic screen size

This change improves device compatibility by using dynamic screen dimensions from the device settings rather than hardcoded values. This is particularly important for supporting different device types with varying screen resolutions.

Comment on lines +415 to 416
EPFramebuffer::instance()->auxBuffer.rect(),
Blight::HighQualityGrayscale,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Switch from main framebuffer to auxiliary buffer

The code now uses the auxiliary buffer's rectangle data instead of the main framebuffer. This change is consistent with the broader refactoring of the display update system in this PR.

Verify that this change correctly coordinates with the rest of the framebuffer system changes to ensure proper rendering.

Comment on lines +432 to 433
EPFramebuffer::instance()->auxBuffer.rect(),
Blight::HighQualityGrayscale,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use auxiliary buffer for exclusive mode repaint

Similar to the previous change, this modification switches from using the main framebuffer to the auxiliary buffer for repaint operations in exclusive mode. This ensures consistency with the other display buffer changes in this PR.

Comment on lines +257 to +267
? EPScreenMode::QualityFull
: EPScreenMode::QualityFast;
auto flag = rect == m_screenRect
? EPFramebuffer::UpdateFlag::CompleteRefresh
: EPFramebuffer::UpdateFlag::NoRefresh;
EPFramebuffer::instance()->swapBuffers(
m_screenGeometry,
EPContentType::Mono,
mode,
flag
);
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Refine update modes for partial refresh.
Currently, partial updates always use EPScreenMode::QualityFast. This might lead to ghosting or performance trade-offs on ePaper devices. Consider a more granular approach or user-controlled waveforms to optimize refresh quality.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asivery with the c-abi changes, you should now have more information for what refresh mode was requested at this point, so you can use that instead of hardcoding a single refresh mode value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

return nullptr;
}
image = new QImage(data, 1404, 1872, stride, QImage::Format_RGB16);
image = new QImage(data, deviceSettings.getScreenWidth(), deviceSettings.getScreenHeight(), stride, QImage::Format_RGB16);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stride will need to take into account rMPP screen sizes here too


epframebuffer_h.target = epframebuffer.h
epframebuffer_h.commands = cp $$PWD/epframebuffer.h $$OUT_PWD
epframebuffer_h.target = raw_copy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see raw_copy defined here. Shouldn't it be what was here before?


linux-oe-g++{
epframebuffer_h_install.files = epframebuffer.h
epframebuffer_h_install.files = epframebuffer.h libqsgepaper.so
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libqsgepaper should be it's own install that places it in the correct location, right now this is placing it in /opt/include instead of /opt/lib/plugins/scenegraph

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to remove this from the repo and pull it from the toolchain instead.

_deviceType = DeviceType::RM2;
return;
}
if (modelName.contains("reMarkable Ferrari")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be startswith as Not reMarkable Ferrari should not match. You could also do direct comparisons assuming there are no newlines in the value.

@Eeems
Copy link
Collaborator

Eeems commented Apr 19, 2025

@asivery I just merged the c abi branch, luckily there are no conflicts!

@Eeems Eeems linked an issue Apr 20, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement new qgsepaper for all devices

2 participants