Commit 6a17b4d1 authored by Pin-yen Lin's avatar Pin-yen Lin Committed by Douglas Anderson

drm/bridge: ps8640: Add a cache for EDID

When there are multiple EDID reads, the bridge will be repeatedly
enabled and disabled. Add a cache for EDID to speed this up.
Signed-off-by: default avatarPin-yen Lin <treapking@chromium.org>
Reviewed-by: default avatarRobert Foss <rfoss@kernel.org>
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230315035508.2874915-2-treapking@chromium.org
parent 845e730e
...@@ -105,6 +105,7 @@ struct ps8640 { ...@@ -105,6 +105,7 @@ struct ps8640 {
struct gpio_desc *gpio_reset; struct gpio_desc *gpio_reset;
struct gpio_desc *gpio_powerdown; struct gpio_desc *gpio_powerdown;
struct device_link *link; struct device_link *link;
struct edid *edid;
bool pre_enabled; bool pre_enabled;
bool need_post_hpd_delay; bool need_post_hpd_delay;
}; };
...@@ -543,8 +544,8 @@ static struct edid *ps8640_bridge_get_edid(struct drm_bridge *bridge, ...@@ -543,8 +544,8 @@ static struct edid *ps8640_bridge_get_edid(struct drm_bridge *bridge,
{ {
struct ps8640 *ps_bridge = bridge_to_ps8640(bridge); struct ps8640 *ps_bridge = bridge_to_ps8640(bridge);
bool poweroff = !ps_bridge->pre_enabled; bool poweroff = !ps_bridge->pre_enabled;
struct edid *edid;
if (!ps_bridge->edid) {
/* /*
* When we end calling get_edid() triggered by an ioctl, i.e * When we end calling get_edid() triggered by an ioctl, i.e
* *
...@@ -553,24 +554,27 @@ static struct edid *ps8640_bridge_get_edid(struct drm_bridge *bridge, ...@@ -553,24 +554,27 @@ static struct edid *ps8640_bridge_get_edid(struct drm_bridge *bridge,
* -> drm_bridge_connector_get_modes * -> drm_bridge_connector_get_modes
* -> ps8640_bridge_get_edid * -> ps8640_bridge_get_edid
* *
* We need to make sure that what we need is enabled before reading * We need to make sure that what we need is enabled before
* EDID, for this chip, we need to do a full poweron, otherwise it will * reading EDID, for this chip, we need to do a full poweron,
* fail. * otherwise it will fail.
*/ */
if (poweroff) if (poweroff)
drm_atomic_bridge_chain_pre_enable(bridge, connector->state->state); drm_atomic_bridge_chain_pre_enable(bridge,
connector->state->state);
edid = drm_get_edid(connector, ps_bridge->edid = drm_get_edid(connector,
ps_bridge->page[PAGE0_DP_CNTL]->adapter); ps_bridge->page[PAGE0_DP_CNTL]->adapter);
/* /*
* If we call the get_edid() function without having enabled the chip * If we call the get_edid() function without having enabled the
* before, return the chip to its original power state. * chip before, return the chip to its original power state.
*/ */
if (poweroff) if (poweroff)
drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); drm_atomic_bridge_chain_post_disable(bridge,
connector->state->state);
}
return edid; return drm_edid_duplicate(ps_bridge->edid);
} }
static void ps8640_runtime_disable(void *data) static void ps8640_runtime_disable(void *data)
...@@ -767,6 +771,13 @@ static int ps8640_probe(struct i2c_client *client) ...@@ -767,6 +771,13 @@ static int ps8640_probe(struct i2c_client *client)
return ret; return ret;
} }
static void ps8640_remove(struct i2c_client *client)
{
struct ps8640 *ps_bridge = i2c_get_clientdata(client);
kfree(ps_bridge->edid);
}
static const struct of_device_id ps8640_match[] = { static const struct of_device_id ps8640_match[] = {
{ .compatible = "parade,ps8640" }, { .compatible = "parade,ps8640" },
{ } { }
...@@ -775,6 +786,7 @@ MODULE_DEVICE_TABLE(of, ps8640_match); ...@@ -775,6 +786,7 @@ MODULE_DEVICE_TABLE(of, ps8640_match);
static struct i2c_driver ps8640_driver = { static struct i2c_driver ps8640_driver = {
.probe_new = ps8640_probe, .probe_new = ps8640_probe,
.remove = ps8640_remove,
.driver = { .driver = {
.name = "ps8640", .name = "ps8640",
.of_match_table = ps8640_match, .of_match_table = ps8640_match,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment