feat: enable the configuration for 8K preview.#502
Conversation
Use the DConfig mechanism to enable the configuration for 8K preview. 使用DConfig机制,开放8K预览功能,同时8K不支持录像。 代码来自xiwo分支。 pick form: b5c2d8e Bug: https://pms.uniontech.com/bug-view-349401.html
Reviewer's GuideThis PR adds a DConfig-controlled 8K preview capability, relaxes resolution validation when enabled, and conditionally hides recording UI at 8K while wiring the flag through DataManager and v4l2core; it also adds minor UI helper methods. Sequence diagram for DConfig-controlled 8K preview and UI behaviorsequenceDiagram
participant AppMain as main
participant DConfig as DConfig
participant DataManager as DataManager
participant V4L2 as v4l2_formats.c
participant UI as CMainWindow
AppMain->>DConfig: keyList()
DConfig-->>AppMain: contains enable8kPreview
AppMain->>DConfig: value(enable8kPreview)
DConfig-->>AppMain: bool enable
AppMain->>DataManager: setEnable8kPreview(enable)
AppMain->>V4L2: set_enable_8k_preview(enable ? 1 : 0)
UI->>V4L2: is_valid_resolution(width, height)
alt enable_8k_preview == 1
V4L2-->>UI: allow width%16==0 && height%4==0
else enable_8k_preview == 0
V4L2-->>UI: enforce MAX_WIDTH_LIMIT, MAX_HEIGHT_LIMIT
end
UI->>V4L2: v4l2core_get_frame_width(fd)
UI->>V4L2: v4l2core_get_frame_height(fd)
UI->>UI: checkResolutionTooHigh()
alt resolution too high (e.g. 8K)
UI->>UI: showChildWidget()
UI->>UI: showWidget(m_modeSwitchBox, false)
else resolution normal
UI->>UI: showChildWidget()
UI->>UI: showWidget(m_modeSwitchBox, true)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:98分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // libcam/libcam_v4l2core/v4l2_formats.c
#include <pthread.h>
static int enable_8k_preview = 0;
static pthread_mutex_t preview_mutex = PTHREAD_MUTEX_INITIALIZER;
int is_valid_resolution(int width, int height)
{
int current_enable_8k;
pthread_mutex_lock(&preview_mutex);
current_enable_8k = enable_8k_preview;
pthread_mutex_unlock(&preview_mutex);
if (current_enable_8k) {
return (width > 0 && height > 0)
&& (width % 16 == 0 && height % 4 == 0);
}
return (width > 0 && height > 0)
&& (width <= MAX_WIDTH_LIMIT && height <= MAX_HEIGHT_LIMIT)
&& (width % 16 == 0 && height % 8 == 0);
}
void set_enable_8k_preview(int enable)
{
pthread_mutex_lock(&preview_mutex);
enable_8k_preview = enable;
pthread_mutex_unlock(&preview_mutex);
}
int is_enable_8k_preview()
{
int current_enable_8k;
pthread_mutex_lock(&preview_mutex);
current_enable_8k = enable_8k_preview;
pthread_mutex_unlock(&preview_mutex);
return current_enable_8k;
} |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The 8K preview enable state is now tracked both in
DataManager::m_enable8kPreviewand the globalenable_8k_previewinv4l2_formats.c; consider centralizing this into a single source of truth (e.g., one getter/setter that updates both layers) to avoid future divergence. checkResolutionTooHigh()hides the mode switch UI based purely onMAX_WIDTH_LIMIT/MAX_HEIGHT_LIMIT, whileis_valid_resolution()changes its constraints when 8K is enabled; it may be clearer and safer to base the UI behavior on the 8K-enable flag (or a shared helper) so resolution/feature gating logic stays consistent between core and UI.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The 8K preview enable state is now tracked both in `DataManager::m_enable8kPreview` and the global `enable_8k_preview` in `v4l2_formats.c`; consider centralizing this into a single source of truth (e.g., one getter/setter that updates both layers) to avoid future divergence.
- `checkResolutionTooHigh()` hides the mode switch UI based purely on `MAX_WIDTH_LIMIT`/`MAX_HEIGHT_LIMIT`, while `is_valid_resolution()` changes its constraints when 8K is enabled; it may be clearer and safer to base the UI behavior on the 8K-enable flag (or a shared helper) so resolution/feature gating logic stays consistent between core and UI.
## Individual Comments
### Comment 1
<location path="libcam/libcam_v4l2core/v4l2_formats.h" line_range="136" />
<code_context>
+ * returns: TRUE(1) if enabled
+ * FALSE(0) if not
+ */
+int is_enable_8k_preview();
+
#endif
</code_context>
<issue_to_address>
**nitpick:** Use an explicit void parameter list for the C API to avoid old-style function declarations.
Declare this as `int is_enable_8k_preview(void);` and update the definition accordingly. Using `void` avoids the old-style "unspecified parameters" meaning of `()` and lets the compiler catch signature mismatches.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| * returns: TRUE(1) if enabled | ||
| * FALSE(0) if not | ||
| */ | ||
| int is_enable_8k_preview(); |
There was a problem hiding this comment.
nitpick: Use an explicit void parameter list for the C API to avoid old-style function declarations.
Declare this as int is_enable_8k_preview(void); and update the definition accordingly. Using void avoids the old-style "unspecified parameters" meaning of () and lets the compiler catch signature mismatches.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Use the DConfig mechanism to enable the configuration for 8K preview. 使用DConfig机制,开放8K预览功能,同时8K不支持录像。
代码来自xiwo分支。
pick form: b5c2d8e
Bug: https://pms.uniontech.com/bug-view-349401.html
Summary by Sourcery
Enable an optional 8K preview mode controlled by configuration, relaxing resolution limits when active while disabling recording at unsupported high resolutions and wiring the setting through the application and camera core.
New Features:
Enhancements: