Skip to content

Commit 96591a4

Browse files
Laurent Pinchartsravnborg
authored andcommitted
drm: bridge: dw-hdmi: Pass private data pointer to .mode_valid()
Platform glue drivers for dw_hdmi may need to access device-specific data from their .mode_valid() implementation. They currently have no clean way to do so, and one driver hacks around it by accessing the dev_private data of the drm_device retrieved from the connector. Add a priv_data void pointer to the dw_hdmi_plat_data structure, and pass it to the .mode_valid() function. Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20200526011505.31884-12-laurent.pinchart+renesas@ideasonboard.com
1 parent 12c683e commit 96591a4

File tree

8 files changed

+32
-12
lines changed

8 files changed

+32
-12
lines changed

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,15 +2771,17 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
27712771
const struct drm_display_mode *mode)
27722772
{
27732773
struct dw_hdmi *hdmi = bridge->driver_private;
2774+
const struct dw_hdmi_plat_data *pdata = hdmi->plat_data;
27742775
struct drm_connector *connector = &hdmi->connector;
27752776
enum drm_mode_status mode_status = MODE_OK;
27762777

27772778
/* We don't support double-clocked modes */
27782779
if (mode->flags & DRM_MODE_FLAG_DBLCLK)
27792780
return MODE_BAD;
27802781

2781-
if (hdmi->plat_data->mode_valid)
2782-
mode_status = hdmi->plat_data->mode_valid(connector, mode);
2782+
if (pdata->mode_valid)
2783+
mode_status = pdata->mode_valid(hdmi, pdata->priv_data,
2784+
connector, mode);
27832785

27842786
return mode_status;
27852787
}

drivers/gpu/drm/imx/dw_hdmi-imx.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs =
145145
};
146146

147147
static enum drm_mode_status
148-
imx6q_hdmi_mode_valid(struct drm_connector *con,
148+
imx6q_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
149+
struct drm_connector *con,
149150
const struct drm_display_mode *mode)
150151
{
151152
if (mode->clock < 13500)
@@ -158,7 +159,8 @@ imx6q_hdmi_mode_valid(struct drm_connector *con,
158159
}
159160

160161
static enum drm_mode_status
161-
imx6dl_hdmi_mode_valid(struct drm_connector *con,
162+
imx6dl_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
163+
struct drm_connector *con,
162164
const struct drm_display_mode *mode)
163165
{
164166
if (mode->clock < 13500)

drivers/gpu/drm/meson/meson_dw_hdmi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,8 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id)
630630
}
631631

632632
static enum drm_mode_status
633-
dw_hdmi_mode_valid(struct drm_connector *connector,
633+
dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
634+
struct drm_connector *connector,
634635
const struct drm_display_mode *mode)
635636
{
636637
struct meson_drm *priv = connector->dev->dev_private;

drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ static const struct rcar_hdmi_phy_params rcar_hdmi_phy_params[] = {
3838
};
3939

4040
static enum drm_mode_status
41-
rcar_hdmi_mode_valid(struct drm_connector *connector,
41+
rcar_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
42+
struct drm_connector *connector,
4243
const struct drm_display_mode *mode)
4344
{
4445
/*

drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
220220
}
221221

222222
static enum drm_mode_status
223-
dw_hdmi_rockchip_mode_valid(struct drm_connector *connector,
223+
dw_hdmi_rockchip_mode_valid(struct dw_hdmi *hdmi, void *data,
224+
struct drm_connector *connector,
224225
const struct drm_display_mode *mode)
225226
{
226227
const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ sun8i_dw_hdmi_encoder_helper_funcs = {
3131
};
3232

3333
static enum drm_mode_status
34-
sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
34+
sun8i_dw_hdmi_mode_valid_a83t(struct dw_hdmi *hdmi, void *data,
35+
struct drm_connector *connector,
3536
const struct drm_display_mode *mode)
3637
{
3738
if (mode->clock > 297000)
@@ -41,7 +42,8 @@ sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
4142
}
4243

4344
static enum drm_mode_status
44-
sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
45+
sun8i_dw_hdmi_mode_valid_h6(struct dw_hdmi *hdmi, void *data,
46+
struct drm_connector *connector,
4547
const struct drm_display_mode *mode)
4648
{
4749
/*

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ struct sun8i_hdmi_phy {
176176
};
177177

178178
struct sun8i_dw_hdmi_quirks {
179-
enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
179+
enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
180+
struct drm_connector *connector,
180181
const struct drm_display_mode *mode);
181182
unsigned int set_rate : 1;
182183
unsigned int use_drm_infoframe : 1;

include/drm/bridge/dw_hdmi.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,23 @@ struct dw_hdmi_phy_ops {
124124

125125
struct dw_hdmi_plat_data {
126126
struct regmap *regm;
127-
enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
128-
const struct drm_display_mode *mode);
127+
129128
unsigned long input_bus_format;
130129
unsigned long input_bus_encoding;
131130
bool use_drm_infoframe;
132131
bool ycbcr_420_allowed;
133132

133+
/*
134+
* Private data passed to all the .mode_valid() and .configure_phy()
135+
* callback functions.
136+
*/
137+
void *priv_data;
138+
139+
/* Platform-specific mode validation (optional). */
140+
enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
141+
struct drm_connector *connector,
142+
const struct drm_display_mode *mode);
143+
134144
/* Vendor PHY support */
135145
const struct dw_hdmi_phy_ops *phy_ops;
136146
const char *phy_name;

0 commit comments

Comments
 (0)