summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i2c/adv7511.c
diff options
context:
space:
mode:
authorBlagovest Kolenichev <bkolenichev@codeaurora.org>2017-09-21 14:00:18 -0700
committerBlagovest Kolenichev <bkolenichev@codeaurora.org>2017-09-21 14:00:18 -0700
commit3e99b7f6eb0303ac4efec0ccff6e63e671ed8869 (patch)
tree073a1475b27c724427c0b564c3f7835de47071a7 /drivers/gpu/drm/i2c/adv7511.c
parentc988eaaeaf5f1194a7366ecfab9209d0fda13b0e (diff)
parent29d0b657c322a4bb7cd6bba644b74215be87277a (diff)
Merge android-4.4@29d0b65 (v4.4.88) into msm-4.4
* refs/heads/tmp-29d0b65 Linux 4.4.88 xfs: XFS_IS_REALTIME_INODE() should be false if no rt device present NFS: Fix 2 use after free issues in the I/O code ARM: 8692/1: mm: abort uaccess retries upon fatal signal Bluetooth: Properly check L2CAP config option output buffer length ALSA: msnd: Optimize / harden DSP and MIDI loops locktorture: Fix potential memory leak with rw lock test btrfs: resume qgroup rescan on rw remount drm/bridge: adv7511: Re-write the i2c address before EDID probing drm/bridge: adv7511: Switch to using drm_kms_helper_hotplug_event() drm/bridge: adv7511: Use work_struct to defer hotplug handing to out of irq context drm/bridge: adv7511: Fix mutex deadlock when interrupts are disabled drm: adv7511: really enable interrupts for EDID detection scsi: sg: recheck MMAP_IO request length with lock held scsi: sg: protect against races between mmap() and SG_SET_RESERVED_SIZE cs5536: add support for IDE controller variant workqueue: Fix flag collision drm/nouveau/pci/msi: disable MSI on big-endian platforms by default mwifiex: correct channel stat buffer overflows dlm: avoid double-free on error path in dlm_device_{register,unregister} Bluetooth: Add support of 13d3:3494 RTL8723BE device rtlwifi: rtl_pci_probe: Fix fail path of _rtl_pci_find_adapter Input: trackpoint - assume 3 buttons when buttons detection fails ath10k: fix memory leak in rx ring buffer allocation intel_th: pci: Add Cannon Lake PCH-LP support intel_th: pci: Add Cannon Lake PCH-H support driver core: bus: Fix a potential double free staging/rts5208: fix incorrect shift to extract upper nybble USB: core: Avoid race of async_completed() w/ usbdev_release() usb:xhci:Fix regression when ATI chipsets detected usb: Add device quirk for Logitech HD Pro Webcam C920-C USB: serial: option: add support for D-Link DWM-157 C1 usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard ANDROID: sdcardfs: Add missing break ANDROID: Sdcardfs: Move gid derivation under flag ANDROID: mnt: Fix freeing of mount data drivers: cpufreq: checks to avoid kernel crash in cpufreq_interactive ANDROID: Use sk_uid to replace uid get from socket file ANDROID: nf: xt_qtaguid: fix handling for cases where tunnels are used. Revert "ANDROID: Use sk_uid to replace uid get from socket file" ANDROID: fiq_debugger: Fix minor bug in code Conflicts: drivers/cpufreq/cpufreq_interactive.c drivers/net/wireless/ath/ath10k/core.c drivers/staging/android/fiq_debugger/fiq_debugger.c net/netfilter/xt_qtaguid.c Change-Id: I49c67ff84d4bee0799691cc1ee0a023e2dd13e66 Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
Diffstat (limited to 'drivers/gpu/drm/i2c/adv7511.c')
-rw-r--r--drivers/gpu/drm/i2c/adv7511.c71
1 files changed, 54 insertions, 17 deletions
diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index 00416f23b5cb..dba5c0ea0827 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -36,7 +36,10 @@ struct adv7511 {
bool edid_read;
wait_queue_head_t wq;
+ struct work_struct hpd_work;
+
struct drm_encoder *encoder;
+ struct drm_connector connector;
bool embedded_sync;
enum adv7511_sync_polarity vsync_polarity;
@@ -48,6 +51,10 @@ struct adv7511 {
struct gpio_desc *gpio_pd;
};
+static const int edid_i2c_addr = 0x7e;
+static const int packet_i2c_addr = 0x70;
+static const int cec_i2c_addr = 0x78;
+
static struct adv7511 *encoder_to_adv7511(struct drm_encoder *encoder)
{
return to_encoder_slave(encoder)->slave_priv;
@@ -362,12 +369,19 @@ static void adv7511_power_on(struct adv7511 *adv7511)
{
adv7511->current_edid_segment = -1;
- regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
- ADV7511_INT0_EDID_READY);
- regmap_write(adv7511->regmap, ADV7511_REG_INT(1),
- ADV7511_INT1_DDC_ERROR);
regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
ADV7511_POWER_POWER_DOWN, 0);
+ if (adv7511->i2c_main->irq) {
+ /*
+ * Documentation says the INT_ENABLE registers are reset in
+ * POWER_DOWN mode. My 7511w preserved the bits, however.
+ * Still, let's be safe and stick to the documentation.
+ */
+ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0),
+ ADV7511_INT0_EDID_READY);
+ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1),
+ ADV7511_INT1_DDC_ERROR);
+ }
/*
* Per spec it is allowed to pulse the HDP signal to indicate that the
@@ -422,7 +436,27 @@ static bool adv7511_hpd(struct adv7511 *adv7511)
return false;
}
-static int adv7511_irq_process(struct adv7511 *adv7511)
+static void adv7511_hpd_work(struct work_struct *work)
+{
+ struct adv7511 *adv7511 = container_of(work, struct adv7511, hpd_work);
+ enum drm_connector_status status;
+ unsigned int val;
+ int ret;
+ ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val);
+ if (ret < 0)
+ status = connector_status_disconnected;
+ else if (val & ADV7511_STATUS_HPD)
+ status = connector_status_connected;
+ else
+ status = connector_status_disconnected;
+
+ if (adv7511->connector.status != status) {
+ adv7511->connector.status = status;
+ drm_kms_helper_hotplug_event(adv7511->connector.dev);
+ }
+}
+
+static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
{
unsigned int irq0, irq1;
int ret;
@@ -438,8 +472,8 @@ static int adv7511_irq_process(struct adv7511 *adv7511)
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);
- if (irq0 & ADV7511_INT0_HDP && adv7511->encoder)
- drm_helper_hpd_irq_event(adv7511->encoder->dev);
+ if (process_hpd && irq0 & ADV7511_INT0_HDP && adv7511->encoder)
+ schedule_work(&adv7511->hpd_work);
if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
adv7511->edid_read = true;
@@ -456,7 +490,7 @@ static irqreturn_t adv7511_irq_handler(int irq, void *devid)
struct adv7511 *adv7511 = devid;
int ret;
- ret = adv7511_irq_process(adv7511);
+ ret = adv7511_irq_process(adv7511, true);
return ret < 0 ? IRQ_NONE : IRQ_HANDLED;
}
@@ -473,7 +507,7 @@ static int adv7511_wait_for_edid(struct adv7511 *adv7511, int timeout)
adv7511->edid_read, msecs_to_jiffies(timeout));
} else {
for (; timeout > 0; timeout -= 25) {
- ret = adv7511_irq_process(adv7511);
+ ret = adv7511_irq_process(adv7511, false);
if (ret < 0)
break;
@@ -567,13 +601,18 @@ static int adv7511_get_modes(struct drm_encoder *encoder,
/* Reading the EDID only works if the device is powered */
if (!adv7511->powered) {
- regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
- ADV7511_INT0_EDID_READY);
- regmap_write(adv7511->regmap, ADV7511_REG_INT(1),
- ADV7511_INT1_DDC_ERROR);
regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
ADV7511_POWER_POWER_DOWN, 0);
+ if (adv7511->i2c_main->irq) {
+ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(0),
+ ADV7511_INT0_EDID_READY);
+ regmap_write(adv7511->regmap, ADV7511_REG_INT_ENABLE(1),
+ ADV7511_INT1_DDC_ERROR);
+ }
adv7511->current_edid_segment = -1;
+ /* Reset the EDID_I2C_ADDR register as it might be cleared */
+ regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
+ edid_i2c_addr);
}
edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);
@@ -849,10 +888,6 @@ static int adv7511_parse_dt(struct device_node *np,
return 0;
}
-static const int edid_i2c_addr = 0x7e;
-static const int packet_i2c_addr = 0x70;
-static const int cec_i2c_addr = 0x78;
-
static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
struct adv7511_link_config link_config;
@@ -913,6 +948,8 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
if (!adv7511->i2c_edid)
return -ENOMEM;
+ INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work);
+
if (i2c->irq) {
init_waitqueue_head(&adv7511->wq);