Skip to content

Commit 6800234

Browse files
committed
drm/vc4: hdmi: Convert to gpiod
The new gpiod interface takes care of parsing the GPIO flags and to return the logical value when accessing an active-low GPIO, so switching to it simplifies a lot the driver. Signed-off-by: Maxime Ripard <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e075a78 commit 6800234

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
166166
struct vc4_hdmi *vc4_hdmi = connector_to_vc4_hdmi(connector);
167167
bool connected = false;
168168

169-
if (vc4_hdmi->hpd_gpio) {
170-
if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^
171-
vc4_hdmi->hpd_active_low)
172-
connected = true;
169+
if (vc4_hdmi->hpd_gpio &&
170+
gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio)) {
171+
connected = true;
173172
} else if (drm_probe_ddc(vc4_hdmi->ddc)) {
174173
connected = true;
175174
} else if (HDMI_READ(HDMI_HOTPLUG) & VC4_HDMI_HOTPLUG_CONNECTED) {
@@ -2105,7 +2104,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
21052104
struct vc4_hdmi *vc4_hdmi;
21062105
struct drm_encoder *encoder;
21072106
struct device_node *ddc_node;
2108-
u32 value;
21092107
int ret;
21102108

21112109
vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL);
@@ -2144,18 +2142,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
21442142
/* Only use the GPIO HPD pin if present in the DT, otherwise
21452143
* we'll use the HDMI core's register.
21462144
*/
2147-
if (of_find_property(dev->of_node, "hpd-gpios", &value)) {
2148-
enum of_gpio_flags hpd_gpio_flags;
2149-
2150-
vc4_hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
2151-
"hpd-gpios", 0,
2152-
&hpd_gpio_flags);
2153-
if (vc4_hdmi->hpd_gpio < 0) {
2154-
ret = vc4_hdmi->hpd_gpio;
2155-
goto err_put_ddc;
2156-
}
2157-
2158-
vc4_hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
2145+
vc4_hdmi->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN);
2146+
if (IS_ERR(vc4_hdmi->hpd_gpio)) {
2147+
ret = PTR_ERR(vc4_hdmi->hpd_gpio);
2148+
goto err_put_ddc;
21592149
}
21602150

21612151
vc4_hdmi->disable_wifi_frequencies =

drivers/gpu/drm/vc4/vc4_hdmi.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ struct vc4_hdmi {
148148
/* VC5 Only */
149149
void __iomem *rm_regs;
150150

151-
int hpd_gpio;
152-
bool hpd_active_low;
151+
struct gpio_desc *hpd_gpio;
153152

154153
/*
155154
* On some systems (like the RPi4), some modes are in the same

0 commit comments

Comments
 (0)