Skip to content

WIP: HDMI HPD debounce #5386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: rpi-6.1.y
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions drivers/gpu/drm/vc4/vc4_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2858,12 +2858,40 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)

}

static irqreturn_t vc4_hdmi_hpd_irq_thread(int irq, void *priv)
static void vc4_hdmi_hpd_con_wq(struct work_struct *work)
{
struct vc4_hdmi *vc4_hdmi = container_of(to_delayed_work(work),
struct vc4_hdmi,
hpd_con_work);
struct drm_connector *connector = &vc4_hdmi->connector;
struct drm_device *dev = connector->dev;

if (dev && dev->registered)
drm_connector_helper_hpd_irq_event(connector);
}

#define HPD_DEBOUNCE_DELAY_MS 2500
Copy link

Choose a reason for hiding this comment

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

Please dont put defines here instead place it near the top of the file

- #define HPD_DEBOUNCE_DELAY_MS 2500

You can put it near line 121

#define HSM_MIN_CLOCK_FREQ	120000000
#define CEC_CLOCK_FREQ 40000

#define HDMI_14_MAX_TMDS_CLK   (340 * 1000 * 1000)
+ #define HPD_DEBOUNCE_DELAY_MS 2500
/* bit field to force hotplug detection. bit0 = HDMI0 */
static int force_hotplug = 0;
module_param(force_hotplug, int, 0644);

Copy link
Contributor

Choose a reason for hiding this comment

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

Who are you?

Copy link

Choose a reason for hiding this comment

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

Why?

Copy link

Choose a reason for hiding this comment

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

I'm only suggesting changes.


static irqreturn_t vc4_hdmi_hpd_irq_con_thread(int irq, void *priv)
{
struct vc4_hdmi *vc4_hdmi = priv;
struct device *pdev = &vc4_hdmi->pdev->dev;

dev_err(pdev, "HPD IRQ status conn\n");
mod_delayed_work(system_wq, &vc4_hdmi->hpd_con_work,
msecs_to_jiffies(HPD_DEBOUNCE_DELAY_MS));

return IRQ_HANDLED;
}

static irqreturn_t vc4_hdmi_hpd_irq_disconn_thread(int irq, void *priv)
{
struct vc4_hdmi *vc4_hdmi = priv;
struct drm_connector *connector = &vc4_hdmi->connector;
struct drm_device *dev = connector->dev;
struct device *pdev = &vc4_hdmi->pdev->dev;

dev_err(pdev, "HPD IRQ status disconn\n");
if (dev && dev->registered)
drm_connector_helper_hpd_irq_event(connector);

Expand All @@ -2880,16 +2908,16 @@ static int vc4_hdmi_hotplug_init(struct vc4_hdmi *vc4_hdmi)
unsigned int hpd_con = platform_get_irq_byname(pdev, "hpd-connected");
unsigned int hpd_rm = platform_get_irq_byname(pdev, "hpd-removed");

ret = devm_request_threaded_irq(&pdev->dev, hpd_con,
NULL,
vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
ret = devm_request_threaded_irq(&pdev->dev, hpd_con, NULL,
vc4_hdmi_hpd_irq_con_thread,
IRQF_ONESHOT,
"vc4 hdmi hpd connected", vc4_hdmi);
if (ret)
return ret;

ret = devm_request_threaded_irq(&pdev->dev, hpd_rm,
NULL,
vc4_hdmi_hpd_irq_thread, IRQF_ONESHOT,
ret = devm_request_threaded_irq(&pdev->dev, hpd_rm, NULL,
vc4_hdmi_hpd_irq_disconn_thread,
IRQF_ONESHOT,
"vc4 hdmi hpd disconnected", vc4_hdmi);
if (ret)
return ret;
Expand Down Expand Up @@ -3714,6 +3742,7 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)

spin_lock_init(&vc4_hdmi->hw_lock);
INIT_DELAYED_WORK(&vc4_hdmi->scrambling_work, vc4_hdmi_scrambling_wq);
INIT_DELAYED_WORK(&vc4_hdmi->hpd_con_work, vc4_hdmi_hpd_con_wq);

dev_set_drvdata(dev, vc4_hdmi);
encoder = &vc4_hdmi->encoder.base;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/vc4/vc4_hdmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ struct vc4_hdmi {
struct drm_connector connector;

struct delayed_work scrambling_work;
struct delayed_work hpd_con_work;

struct drm_property *broadcast_rgb_property;
struct drm_property *output_format_property;
Expand Down