Skip to content

media: phytium: update phytium media controller driver support to 6.6.0.4#1702

Open
wangchenlu2236 wants to merge 3 commits into
deepin-community:linux-6.6.yfrom
wangchenlu2236:media-6.6.y
Open

media: phytium: update phytium media controller driver support to 6.6.0.4#1702
wangchenlu2236 wants to merge 3 commits into
deepin-community:linux-6.6.yfrom
wangchenlu2236:media-6.6.y

Conversation

@wangchenlu2236
Copy link
Copy Markdown

@wangchenlu2236 wangchenlu2236 commented May 14, 2026

This patches updates the support for phytium media controller driver.

1.media:phytium-jpeg: Redesign the feature of diplaying 'No Signal' on KVM
2.media: phytium-jpeg: Restricted adaptation platform for jpeg driver
3.media: phytium-jpeg: Reduce switch resolution latency

Summary by Sourcery

Improve Phytium JPEG media controller handling of input signal and host power state during resolution detection and switching.

Bug Fixes:

  • Fix incorrect reporting of input signal status when the host is powered off or there is no signal on KVM.

Enhancements:

  • Introduce a buffer-based marker and state flag to track host power and signal presence for more accurate resolution detection.
  • Reduce resolution change delay to lower latency when switching resolutions.
  • Initialize and restore JPEG controller signal state during driver init and resolution work to ensure consistent behavior across power and resolution changes.

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The BMC KVM Web UI must display a 'No Signal' status from the moment a
host is powered on until its VGA monitor is activated. As the previous
implementation did not perform reliably on certain platform, this new
solution has been adopted to resolve these known issues.

Mainline: Open-Source
Signed-off-by: Wang Min <wangmin@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by:Wang Chenlu <wangchenlu2236@phytium.com.cn>
This driver is exclusively for the PHYTIUM platform and is not
compatible with other SoCs. This restriction prevents errors
on unsupported platform.

Mainline: Open-Source
Signed-off-by: Wang Min <wangmin@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by:Wang Chenlu <wangchenlu2236@phytium.com.cn>
The previous delay is so long that it interferes with
the proper operation of the switch resolution. This
incorrect operation would occasionally cause the BMC
to hang.

Mainline: Open-Source
Signed-off-by: Wang Min <wangmin@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by: Wang Chenlu <wangchenlu2236@phytium.com.cn>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 14, 2026

Reviewer's Guide

Updates the Phytium JPEG media controller driver’s signal-detection and resolution-change handling by using a dedicated buffer register as a host power/signal state flag, adding host power-off tracking, and reducing resolution change latency, while removing an unnecessary power-off delay and performing small cleanups.

Sequence diagram for updated signal and resolution detection in Phytium JPEG driver

sequenceDiagram
    participant resolution_work as phytium_jpeg_resolution_work
    participant jpeg_dev as phytium_jpeg_dev
    participant BUF_LAST_reg as BUF_LIST_INDEX_ADDR_VB_BUF_LAST

    resolution_work->>jpeg_dev: phytium_jpeg_init_regs(jpeg_dev)
    resolution_work->>BUF_LAST_reg: phytium_jpeg_write(jpeg_dev, BUF_LIST_INDEX_ADDR(VB_BUF_LAST), HAVE_SIGNAL)
    resolution_work->>jpeg_dev: phytium_jpeg_get_resolution(jpeg_dev)

    activate jpeg_dev
    jpeg_dev->>BUF_LAST_reg: phytium_jpeg_read(jpeg_dev, BUF_LIST_INDEX_ADDR(VB_BUF_LAST))
    Note over jpeg_dev,BUF_LAST_reg: input_signal read from VB_BUF_LAST

    alt [input_signal == HOST_POWER_OFF]
        jpeg_dev-->jpeg_dev: once_poweroff = true
    else [jpeg_dev->once_poweroff == false]
        jpeg_dev->>BUF_LAST_reg: phytium_jpeg_write(jpeg_dev, BUF_LIST_INDEX_ADDR(VB_BUF_LAST), HAVE_SIGNAL)
        jpeg_dev-->jpeg_dev: v4l2_input_status may be cleared
    else [input_signal == HOST_POWER_ON]
        jpeg_dev-->jpeg_dev: v4l2_input_status = V4L2_IN_ST_NO_SIGNAL
    else [input_signal == HAVE_SIGNAL and width * height != 0]
        jpeg_dev-->jpeg_dev: detected_timings.width/height updated
        jpeg_dev-->jpeg_dev: v4l2_input_status = 0
    end
    deactivate jpeg_dev

    %% Query path using the same flag
    participant file as file
    file->>jpeg_dev: phytium_jpeg_query_dv_timings(file, priv, timings)
    activate jpeg_dev
    jpeg_dev->>BUF_LAST_reg: phytium_jpeg_read(jpeg_dev, BUF_LIST_INDEX_ADDR(VB_BUF_LAST))
    alt [input_signal != HAVE_SIGNAL]
        jpeg_dev-->jpeg_dev: v4l2_input_status = V4L2_IN_ST_NO_SIGNAL
    end
    jpeg_dev-->file: return (v4l2_input_status ? -ENOLINK : 0)
    deactivate jpeg_dev
Loading

File-Level Changes

Change Details Files
Redesigned signal/no-signal detection using a dedicated buffer index register to track host power state and KVM signal presence.
  • Introduce VB_BUF_LAST index and magic values HAVE_SIGNAL, HOST_POWER_ON, HOST_POWER_OFF to encode host/signal state in the buffer_list_address register.
  • Initialize the BUF_LIST_INDEX_ADDR(VB_BUF_LAST) register to HAVE_SIGNAL during JPEG init and expand dst_addrs to accommodate VB_BUF_LAST.
  • Add a once_poweroff boolean flag to the device state to track whether the host has been powered off since driver start.
  • Update phytium_jpeg_get_resolution to read/write the new power-state flag, distinguish host-power-off from KVM no-signal cases, and only clear v4l2_input_status when valid signal/resolution is present.
  • Change phytium_jpeg_query_dv_timings to base V4L2_IN_ST_NO_SIGNAL on the power-state flag instead of directly on source width/height.
drivers/media/platform/phytium/phytium_jpeg_core.c
drivers/media/platform/phytium/phytium_jpeg_core.h
Adjusted resolution-change handling to be faster and to restore signal state during resolution switching.
  • Reduce RESOLUTION_CHANGE_DELAY from 250 ms to 150 ms to decrease resolution switch latency.
  • In phytium_jpeg_resolution_work, restore BUF_LIST_INDEX_ADDR(VB_BUF_LAST) to HAVE_SIGNAL and reset once_poweroff before re-detecting resolution, assuming the host remains powered during a resolution switch.
  • Slightly refine resolution-change logging message punctuation for consistency.
drivers/media/platform/phytium/phytium_jpeg_core.c
drivers/media/platform/phytium/phytium_jpeg_core.h
Simplified power-off handling and tidied up minor code style issues.
  • Remove the fixed 50 ms mdelay from phytium_jpeg_off, relying on other mechanisms for safe power-down.
  • Align arguments in devm_request_irq call to match kernel coding style.
  • Initialize v4l2_input_status and once_poweroff during video setup to known default values.
drivers/media/platform/phytium/phytium_jpeg_core.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Copy Markdown

Hi @wangchenlu2236. Thanks for your PR.

I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Phytium JPEG media controller driver to better detect host power state and signal presence on KVM, reduce resolution switch latency, and restrict the driver to Phytium platforms.

Changes:

  • Use the last buffer-list address register as a marker to distinguish host-power-off, host-power-on/no-signal, and have-signal states; updates phytium_jpeg_get_resolution and phytium_jpeg_query_dv_timings accordingly.
  • Reduce RESOLUTION_CHANGE_DELAY from 250ms to 150ms and drop the 50ms delay in phytium_jpeg_off.
  • Add ARCH_PHYTIUM dependency in Kconfig.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
drivers/media/platform/phytium/phytium_jpeg_core.h New marker macros (HAVE_SIGNAL/HOST_POWER_ON/OFF, VB_BUF_LAST), reduced resolution change delay, new once_poweroff flag
drivers/media/platform/phytium/phytium_jpeg_core.c Power/signal detection via buffer-list register; init/restore signal marker; remove mdelay in jpeg_off
drivers/media/platform/phytium/Kconfig Restrict driver build to ARCH_PHYTIUM

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The new once_poweroff state is read/modified from both the resolution workqueue and the resolution/query paths; consider whether this needs explicit locking or atomic access to avoid races between host power transitions and signal detection.
  • Using BUF_LIST_INDEX_ADDR(VB_BUF_LAST) as an out-of-band host power/signal marker is subtle; it may be worth centralizing the marker read/write logic in small helper functions so future changes don’t accidentally reuse that buffer index for data.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `once_poweroff` state is read/modified from both the resolution workqueue and the resolution/query paths; consider whether this needs explicit locking or atomic access to avoid races between host power transitions and signal detection.
- Using `BUF_LIST_INDEX_ADDR(VB_BUF_LAST)` as an out-of-band host power/signal marker is subtle; it may be worth centralizing the marker read/write logic in small helper functions so future changes don’t accidentally reuse that buffer index for data.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Avenger-285714
Copy link
Copy Markdown
Member

/ok-to-test

@Avenger-285714
Copy link
Copy Markdown
Member

/approve

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Avenger-285714

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants