[PATCH] drm/amdgpu: update kernel-doc for some functions

2016-10-23 Thread Grazvydas Ignotas
The names were wrong.

Signed-off-by: Grazvydas Ignotas 
---
 drivers/gpu/drm/amd/scheduler/sched_fence.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/scheduler/sched_fence.c 
b/drivers/gpu/drm/amd/scheduler/sched_fence.c
index 6b63bea..3653b5a 100644
--- a/drivers/gpu/drm/amd/scheduler/sched_fence.c
+++ b/drivers/gpu/drm/amd/scheduler/sched_fence.c
@@ -103,7 +103,7 @@ static void amd_sched_fence_free(struct rcu_head *rcu)
 }

 /**
- * amd_sched_fence_release - callback that fence can be freed
+ * amd_sched_fence_release_scheduled - callback that fence can be freed
  *
  * @fence: fence
  *
@@ -118,7 +118,7 @@ static void amd_sched_fence_release_scheduled(struct fence 
*f)
 }

 /**
- * amd_sched_fence_release_scheduled - drop extra reference
+ * amd_sched_fence_release_finished - drop extra reference
  *
  * @f: fence
  *
-- 
2.7.4



[PATCH] drm/amdgpu: release parent fence reference

2016-10-23 Thread Grazvydas Ignotas
It's done in amd_sched_hw_job_reset(), but not in normal job processing.
Leak reported by CONFIG_SLUB_DEBUG.

Signed-off-by: Grazvydas Ignotas 
---
 CONFIG_SLUB_DEBUG reports more leaks related to ioctls,
 but I was unable to track them down...

 drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c 
b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
index 910b8d5..cfb686e 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@ -522,6 +522,8 @@ static void amd_sched_process_job(struct fence *f, struct 
fence_cb *cb)

trace_amd_sched_process_job(s_fence);
fence_put(_fence->finished);
+   fence_put(s_fence->parent);
+   s_fence->parent = NULL;
wake_up_interruptible(>wake_up_worker);
 }

-- 
2.7.4



[PATCH] drm/amdgpu: fix a vm_flush fence leak

2016-10-23 Thread Grazvydas Ignotas
Looks like .last_flush reference is left at teardown.
Leak reported by CONFIG_SLUB_DEBUG.

Fixes: 41d9eb2c5a2a ("drm/amdgpu: add a fence after the VM flush")
Signed-off-by: Grazvydas Ignotas 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index ded57dd..d6c2839 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1774,5 +1774,6 @@ void amdgpu_vm_manager_fini(struct amdgpu_device *adev)
fence_put(adev->vm_manager.ids[i].first);
amdgpu_sync_free(>vm_manager.ids[i].active);
fence_put(id->flushed_updates);
+   fence_put(id->last_flush);
}
 }
-- 
2.7.4



[PATCH] drm/amdgpu: fix sched fence slab teardown

2016-10-23 Thread Grazvydas Ignotas
To free fences, call_rcu() is used, which calls amd_sched_fence_free()
after a grace period. During teardown, there is no guarantee all
callbacks have finished, so sched_fence_slab may be destroyed before
all fences have been freed. If we are lucky, this results in some slab
warnings, if not, we get a crash in one of rcu threads because callback
is called after amdgpu has already been unloaded.

Fix it with a rcu_barrier().

Fixes: 189e0fb76304 ("drm/amdgpu: RCU protected amd_sched_fence_release")
Signed-off-by: Grazvydas Ignotas 
---
 drivers/gpu/drm/amd/scheduler/gpu_scheduler.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c 
b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
index 963a24d..910b8d5 100644
--- a/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
+++ b/drivers/gpu/drm/amd/scheduler/gpu_scheduler.c
@@ -645,6 +645,7 @@ void amd_sched_fini(struct amd_gpu_scheduler *sched)
 {
if (sched->thread)
kthread_stop(sched->thread);
+   rcu_barrier();
if (atomic_dec_and_test(_fence_slab_ref))
kmem_cache_destroy(sched_fence_slab);
 }
-- 
2.7.4



[PATCH] drm/amdgpu: fix fence slab teardown

2016-10-23 Thread Grazvydas Ignotas
To free fences, call_rcu() is used, which calls amdgpu_fence_free()
after a grace period. During teardown, there is no guarantee all
callbacks have finished, so amdgpu_fence_slab may be destroyed before
all fences have been freed. If we are lucky, this results in some slab
warnings, if not, we get a crash in one of rcu threads because callback
is called after amdgpu has already been unloaded.

Fix it with a rcu_barrier().

Fixes: b44135351a3a ("drm/amdgpu: RCU protected amdgpu_fence_release")
Signed-off-by: Grazvydas Ignotas 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 3a2e42f..77b34ec 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -68,6 +68,7 @@ int amdgpu_fence_slab_init(void)

 void amdgpu_fence_slab_fini(void)
 {
+   rcu_barrier();
kmem_cache_destroy(amdgpu_fence_slab);
 }
 /*
-- 
2.7.4



[PATCH RFC 10/10] drm/i2c: tda998x: switch to boolean is_on

2016-10-23 Thread Russell King
Rather than storing the DPMS mode (which will always be on or off) use a
boolean to store this instead.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 547cf99ac32d..1f9a25fe17f3 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -42,7 +42,7 @@ struct tda998x_priv {
struct mutex mutex;
u16 rev;
u8 current_page;
-   int dpms;
+   bool is_on;
bool is_hdmi_sink;
bool is_hdmi_config;
u8 vip_cntrl_0;
@@ -1150,16 +1150,15 @@ static int tda998x_connector_init(struct tda998x_priv 
*priv,
 static void tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
struct tda998x_priv *priv = enc_to_tda998x_priv(encoder);
+   bool on;

/* we only care about on or off: */
-   if (mode != DRM_MODE_DPMS_ON)
-   mode = DRM_MODE_DPMS_OFF;
+   on = mode == DRM_MODE_DPMS_ON;

-   if (mode == priv->dpms)
+   if (on == priv->is_on)
return;

-   switch (mode) {
-   case DRM_MODE_DPMS_ON:
+   if (on) {
/* enable video ports, audio will be enabled later */
reg_write(priv, REG_ENA_VP_0, 0xff);
reg_write(priv, REG_ENA_VP_1, 0xff);
@@ -1168,16 +1167,16 @@ static void tda998x_encoder_dpms(struct drm_encoder 
*encoder, int mode)
reg_write(priv, REG_VIP_CNTRL_0, priv->vip_cntrl_0);
reg_write(priv, REG_VIP_CNTRL_1, priv->vip_cntrl_1);
reg_write(priv, REG_VIP_CNTRL_2, priv->vip_cntrl_2);
-   break;
-   case DRM_MODE_DPMS_OFF:
+
+   priv->is_on = true;
+   } else {
/* disable video ports */
reg_write(priv, REG_ENA_VP_0, 0x00);
reg_write(priv, REG_ENA_VP_1, 0x00);
reg_write(priv, REG_ENA_VP_2, 0x00);
-   break;
-   }

-   priv->dpms = mode;
+   priv->is_on = false;
+   }
 }

 static void
-- 
2.1.0



[PATCH RFC 09/10] drm/i2c: tda998x: remove complexity from tda998x_audio_get_eld()

2016-10-23 Thread Russell King
tda998x_audio_get_eld() is needlessly complex - the connector associated
with the encoder is always our own priv->connector.  Remove this
complexity, but ensure that there are no races when copying out the ELD.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 23 +--
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 6a7095b66a69..547cf99ac32d 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -911,21 +911,13 @@ static int tda998x_audio_get_eld(struct device *dev, void 
*data,
 uint8_t *buf, size_t len)
 {
struct tda998x_priv *priv = dev_get_drvdata(dev);
-   struct drm_mode_config *config = >encoder.dev->mode_config;
-   struct drm_connector *connector;
-   int ret = -ENODEV;
-
-   mutex_lock(>mutex);
-   list_for_each_entry(connector, >connector_list, head) {
-   if (>encoder == connector->encoder) {
-   memcpy(buf, connector->eld,
-  min(sizeof(connector->eld), len));
-   ret = 0;
-   }
-   }
-   mutex_unlock(>mutex);

-   return ret;
+   mutex_lock(>audio_mutex);
+   memcpy(buf, priv->connector.eld,
+  min(sizeof(priv->connector.eld), len));
+   mutex_unlock(>audio_mutex);
+
+   return 0;
 }

 static const struct hdmi_codec_ops audio_codec_ops = {
@@ -1082,7 +1074,10 @@ static int tda998x_connector_get_modes(struct 
drm_connector *connector)
drm_mode_connector_update_edid_property(connector, edid);
n = drm_add_edid_modes(connector, edid);
priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
+
+   mutex_lock(>audio_mutex);
drm_edid_to_eld(connector, edid);
+   mutex_unlock(>audio_mutex);

kfree(edid);

-- 
2.1.0



[PATCH RFC 08/10] drm/i2c: tda998x: group audio functions together

2016-10-23 Thread Russell King
Group the TDA998x audio functions together rather than split between
two different locations in the file, keeping like code together.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 278 +++---
 1 file changed, 140 insertions(+), 138 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 4379c6aa1c48..6a7095b66a69 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -702,6 +702,8 @@ tda998x_write_avi(struct tda998x_priv *priv, struct 
drm_display_mode *mode)
tda998x_write_if(priv, DIP_IF_FLAGS_IF2, REG_IF2_HB0, );
 }

+/* Audio support */
+
 static void tda998x_audio_mute(struct tda998x_priv *priv, bool on)
 {
if (on) {
@@ -820,6 +822,144 @@ tda998x_configure_audio(struct tda998x_priv *priv,
return tda998x_write_aif(priv, >cea);
 }

+static int tda998x_audio_hw_params(struct device *dev, void *data,
+  struct hdmi_codec_daifmt *daifmt,
+  struct hdmi_codec_params *params)
+{
+   struct tda998x_priv *priv = dev_get_drvdata(dev);
+   int i, ret;
+   struct tda998x_audio_params audio = {
+   .sample_width = params->sample_width,
+   .sample_rate = params->sample_rate,
+   .cea = params->cea,
+   };
+
+   memcpy(audio.status, params->iec.status,
+  min(sizeof(audio.status), sizeof(params->iec.status)));
+
+   switch (daifmt->fmt) {
+   case HDMI_I2S:
+   if (daifmt->bit_clk_inv || daifmt->frame_clk_inv ||
+   daifmt->bit_clk_master || daifmt->frame_clk_master) {
+   dev_err(dev, "%s: Bad flags %d %d %d %d\n", __func__,
+   daifmt->bit_clk_inv, daifmt->frame_clk_inv,
+   daifmt->bit_clk_master,
+   daifmt->frame_clk_master);
+   return -EINVAL;
+   }
+   for (i = 0; i < ARRAY_SIZE(priv->audio_port); i++)
+   if (priv->audio_port[i].format == AFMT_I2S)
+   audio.config = priv->audio_port[i].config;
+   audio.format = AFMT_I2S;
+   break;
+   case HDMI_SPDIF:
+   for (i = 0; i < ARRAY_SIZE(priv->audio_port); i++)
+   if (priv->audio_port[i].format == AFMT_SPDIF)
+   audio.config = priv->audio_port[i].config;
+   audio.format = AFMT_SPDIF;
+   break;
+   default:
+   dev_err(dev, "%s: Invalid format %d\n", __func__, daifmt->fmt);
+   return -EINVAL;
+   }
+
+   if (audio.config == 0) {
+   dev_err(dev, "%s: No audio configutation found\n", __func__);
+   return -EINVAL;
+   }
+
+   mutex_lock(>audio_mutex);
+   /* We must not program the TDA998x for audio if the sink is DVI. */
+   if (priv->is_hdmi_config)
+   ret = tda998x_configure_audio(priv, );
+   else
+   ret = 0;
+
+   if (ret == 0)
+   priv->audio_params = audio;
+   mutex_unlock(>audio_mutex);
+
+   return ret;
+}
+
+static void tda998x_audio_shutdown(struct device *dev, void *data)
+{
+   struct tda998x_priv *priv = dev_get_drvdata(dev);
+
+   mutex_lock(>audio_mutex);
+
+   reg_write(priv, REG_ENA_AP, 0);
+
+   priv->audio_params.format = AFMT_UNUSED;
+
+   mutex_unlock(>audio_mutex);
+}
+
+int tda998x_audio_digital_mute(struct device *dev, void *data, bool enable)
+{
+   struct tda998x_priv *priv = dev_get_drvdata(dev);
+
+   mutex_lock(>audio_mutex);
+
+   tda998x_audio_mute(priv, enable);
+
+   mutex_unlock(>audio_mutex);
+   return 0;
+}
+
+static int tda998x_audio_get_eld(struct device *dev, void *data,
+uint8_t *buf, size_t len)
+{
+   struct tda998x_priv *priv = dev_get_drvdata(dev);
+   struct drm_mode_config *config = >encoder.dev->mode_config;
+   struct drm_connector *connector;
+   int ret = -ENODEV;
+
+   mutex_lock(>mutex);
+   list_for_each_entry(connector, >connector_list, head) {
+   if (>encoder == connector->encoder) {
+   memcpy(buf, connector->eld,
+  min(sizeof(connector->eld), len));
+   ret = 0;
+   }
+   }
+   mutex_unlock(>mutex);
+
+   return ret;
+}
+
+static const struct hdmi_codec_ops audio_codec_ops = {
+   .hw_params = tda998x_audio_hw_params,
+   .audio_shutdown = tda998x_audio_shutdown,
+   .digital_mute = tda998x_audio_digital_mute,
+   .get_eld = tda998x_audio_get_eld,
+};
+
+static int tda998x_audio_codec_init(struct tda998x_priv *priv,
+   struct device *dev)
+{
+   struct 

[PATCH RFC 07/10] drm/i2c: tda998x: separate connector initialisation

2016-10-23 Thread Russell King
Separate out the connector initialisation from the rest of the drivers
initialisation.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 58 +--
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index bb5389fbd059..4379c6aa1c48 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -979,6 +979,37 @@ const struct drm_connector_helper_funcs 
tda998x_connector_helper_funcs = {
.best_encoder = tda998x_connector_best_encoder,
 };

+static int tda998x_connector_init(struct tda998x_priv *priv,
+ struct drm_device *drm)
+{
+   struct drm_connector *connector = >connector;
+   int ret;
+
+   connector->interlace_allowed = 1;
+
+   if (priv->hdmi->irq)
+   connector->polled = DRM_CONNECTOR_POLL_HPD;
+   else
+   connector->polled = DRM_CONNECTOR_POLL_CONNECT |
+   DRM_CONNECTOR_POLL_DISCONNECT;
+
+   drm_connector_helper_add(connector, _connector_helper_funcs);
+   ret = drm_connector_init(drm, connector, _connector_funcs,
+DRM_MODE_CONNECTOR_HDMIA);
+   if (ret)
+   return ret;
+
+   ret = drm_connector_register(>connector);
+   if (ret) {
+   drm_connector_cleanup(>connector);
+   return ret;
+   }
+
+   drm_mode_connector_attach_encoder(>connector, >encoder);
+
+   return 0;
+}
+
 /* DRM encoder functions */

 static void tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)
@@ -1212,16 +1243,6 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,
mutex_unlock(>audio_mutex);
 }

-static void tda998x_encoder_set_polling(struct tda998x_priv *priv,
-   struct drm_connector *connector)
-{
-   if (priv->hdmi->irq)
-   connector->polled = DRM_CONNECTOR_POLL_HPD;
-   else
-   connector->polled = DRM_CONNECTOR_POLL_CONNECT |
-   DRM_CONNECTOR_POLL_DISCONNECT;
-}
-
 static void tda998x_destroy(struct tda998x_priv *priv)
 {
/* disable all IRQs and free the IRQ handler */
@@ -1634,7 +1655,6 @@ static int tda998x_bind(struct device *dev, struct device 
*master, void *data)
crtcs = 1 << 0;
}

-   priv->connector.interlace_allowed = 1;
priv->encoder.possible_crtcs = crtcs;

ret = tda998x_create(client, priv);
@@ -1644,32 +1664,18 @@ static int tda998x_bind(struct device *dev, struct 
device *master, void *data)
if (!dev->of_node && params)
tda998x_set_config(priv, params);

-   tda998x_encoder_set_polling(priv, >connector);
-
drm_encoder_helper_add(>encoder, _encoder_helper_funcs);
ret = drm_encoder_init(drm, >encoder, _encoder_funcs,
   DRM_MODE_ENCODER_TMDS, NULL);
if (ret)
goto err_encoder;

-   drm_connector_helper_add(>connector,
-_connector_helper_funcs);
-   ret = drm_connector_init(drm, >connector,
-_connector_funcs,
-DRM_MODE_CONNECTOR_HDMIA);
+   ret = tda998x_connector_init(priv, drm);
if (ret)
goto err_connector;

-   ret = drm_connector_register(>connector);
-   if (ret)
-   goto err_sysfs;
-
-   drm_mode_connector_attach_encoder(>connector, >encoder);
-
return 0;

-err_sysfs:
-   drm_connector_cleanup(>connector);
 err_connector:
drm_encoder_cleanup(>encoder);
 err_encoder:
-- 
2.1.0



[PATCH RFC 06/10] drm/i2c: tda998x: group connector functions and funcs together

2016-10-23 Thread Russell King
Group the TDA998x connector functions and funcs structures together
before the encoder support, rather than scattered amongst the rest of
the file.  This keeps like code together.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 316 +++---
 1 file changed, 159 insertions(+), 157 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index d3951aee2b09..bb5389fbd059 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -820,6 +820,165 @@ tda998x_configure_audio(struct tda998x_priv *priv,
return tda998x_write_aif(priv, >cea);
 }

+/* DRM connector functions */
+
+static int tda998x_connector_dpms(struct drm_connector *connector, int mode)
+{
+   if (drm_core_check_feature(connector->dev, DRIVER_ATOMIC))
+   return drm_atomic_helper_connector_dpms(connector, mode);
+   else
+   return drm_helper_connector_dpms(connector, mode);
+}
+
+static enum drm_connector_status
+tda998x_connector_detect(struct drm_connector *connector, bool force)
+{
+   struct tda998x_priv *priv = conn_to_tda998x_priv(connector);
+   u8 val = cec_read(priv, REG_CEC_RXSHPDLEV);
+
+   return (val & CEC_RXSHPDLEV_HPD) ? connector_status_connected :
+   connector_status_disconnected;
+}
+
+static void tda998x_connector_destroy(struct drm_connector *connector)
+{
+   drm_connector_unregister(connector);
+   drm_connector_cleanup(connector);
+}
+
+static const struct drm_connector_funcs tda998x_connector_funcs = {
+   .dpms = tda998x_connector_dpms,
+   .reset = drm_atomic_helper_connector_reset,
+   .fill_modes = drm_helper_probe_single_connector_modes,
+   .detect = tda998x_connector_detect,
+   .destroy = tda998x_connector_destroy,
+   .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
+};
+
+static int read_edid_block(void *data, u8 *buf, unsigned int blk, size_t 
length)
+{
+   struct tda998x_priv *priv = data;
+   u8 offset, segptr;
+   int ret, i;
+
+   offset = (blk & 1) ? 128 : 0;
+   segptr = blk / 2;
+
+   reg_write(priv, REG_DDC_ADDR, 0xa0);
+   reg_write(priv, REG_DDC_OFFS, offset);
+   reg_write(priv, REG_DDC_SEGM_ADDR, 0x60);
+   reg_write(priv, REG_DDC_SEGM, segptr);
+
+   /* enable reading EDID: */
+   priv->wq_edid_wait = 1;
+   reg_write(priv, REG_EDID_CTRL, 0x1);
+
+   /* flag must be cleared by sw: */
+   reg_write(priv, REG_EDID_CTRL, 0x0);
+
+   /* wait for block read to complete: */
+   if (priv->hdmi->irq) {
+   i = wait_event_timeout(priv->wq_edid,
+   !priv->wq_edid_wait,
+   msecs_to_jiffies(100));
+   if (i < 0) {
+   dev_err(>hdmi->dev, "read edid wait err %d\n", i);
+   return i;
+   }
+   } else {
+   for (i = 100; i > 0; i--) {
+   msleep(1);
+   ret = reg_read(priv, REG_INT_FLAGS_2);
+   if (ret < 0)
+   return ret;
+   if (ret & INT_FLAGS_2_EDID_BLK_RD)
+   break;
+   }
+   }
+
+   if (i == 0) {
+   dev_err(>hdmi->dev, "read edid timeout\n");
+   return -ETIMEDOUT;
+   }
+
+   ret = reg_read_range(priv, REG_EDID_DATA_0, buf, length);
+   if (ret != length) {
+   dev_err(>hdmi->dev, "failed to read edid block %d: %d\n",
+   blk, ret);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int tda998x_connector_get_modes(struct drm_connector *connector)
+{
+   struct tda998x_priv *priv = conn_to_tda998x_priv(connector);
+   struct edid *edid;
+   int n;
+
+   /*
+* If we get killed while waiting for the HPD timeout, return
+* no modes found: we are not in a restartable path, so we
+* can't handle signals gracefully.
+*/
+   if (tda998x_edid_delay_wait(priv))
+   return 0;
+
+   if (priv->rev == TDA19988)
+   reg_clear(priv, REG_TX4, TX4_PD_RAM);
+
+   edid = drm_do_get_edid(connector, read_edid_block, priv);
+
+   if (priv->rev == TDA19988)
+   reg_set(priv, REG_TX4, TX4_PD_RAM);
+
+   if (!edid) {
+   dev_warn(>hdmi->dev, "failed to read EDID\n");
+   return 0;
+   }
+
+   drm_mode_connector_update_edid_property(connector, edid);
+   n = drm_add_edid_modes(connector, edid);
+   priv->is_hdmi_sink = drm_detect_hdmi_monitor(edid);
+   drm_edid_to_eld(connector, edid);
+
+   kfree(edid);
+
+   return n;
+}
+
+static int 

[PATCH RFC 05/10] drm/i2c: tda998x: move and rename tda998x_encoder_set_config()

2016-10-23 Thread Russell King
The naming of tda998x_encoder_set_config() is a left-over from when
TDA998x was a slave encoder.  Since this is part of the initialisation,
drop the _encoder from the name, and move it near tda998x_bind().

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 40 +++
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 134cd3f26a07..d3951aee2b09 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -822,25 +822,6 @@ tda998x_configure_audio(struct tda998x_priv *priv,

 /* DRM encoder functions */

-static void tda998x_encoder_set_config(struct tda998x_priv *priv,
-  const struct tda998x_encoder_params *p)
-{
-   priv->vip_cntrl_0 = VIP_CNTRL_0_SWAP_A(p->swap_a) |
-   (p->mirr_a ? VIP_CNTRL_0_MIRR_A : 0) |
-   VIP_CNTRL_0_SWAP_B(p->swap_b) |
-   (p->mirr_b ? VIP_CNTRL_0_MIRR_B : 0);
-   priv->vip_cntrl_1 = VIP_CNTRL_1_SWAP_C(p->swap_c) |
-   (p->mirr_c ? VIP_CNTRL_1_MIRR_C : 0) |
-   VIP_CNTRL_1_SWAP_D(p->swap_d) |
-   (p->mirr_d ? VIP_CNTRL_1_MIRR_D : 0);
-   priv->vip_cntrl_2 = VIP_CNTRL_2_SWAP_E(p->swap_e) |
-   (p->mirr_e ? VIP_CNTRL_2_MIRR_E : 0) |
-   VIP_CNTRL_2_SWAP_F(p->swap_f) |
-   (p->mirr_f ? VIP_CNTRL_2_MIRR_F : 0);
-
-   priv->audio_params = p->audio_params;
-}
-
 static void tda998x_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
struct tda998x_priv *priv = enc_to_tda998x_priv(encoder);
@@ -1608,6 +1589,25 @@ static const struct drm_connector_funcs 
tda998x_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };

+static void tda998x_set_config(struct tda998x_priv *priv,
+  const struct tda998x_encoder_params *p)
+{
+   priv->vip_cntrl_0 = VIP_CNTRL_0_SWAP_A(p->swap_a) |
+   (p->mirr_a ? VIP_CNTRL_0_MIRR_A : 0) |
+   VIP_CNTRL_0_SWAP_B(p->swap_b) |
+   (p->mirr_b ? VIP_CNTRL_0_MIRR_B : 0);
+   priv->vip_cntrl_1 = VIP_CNTRL_1_SWAP_C(p->swap_c) |
+   (p->mirr_c ? VIP_CNTRL_1_MIRR_C : 0) |
+   VIP_CNTRL_1_SWAP_D(p->swap_d) |
+   (p->mirr_d ? VIP_CNTRL_1_MIRR_D : 0);
+   priv->vip_cntrl_2 = VIP_CNTRL_2_SWAP_E(p->swap_e) |
+   (p->mirr_e ? VIP_CNTRL_2_MIRR_E : 0) |
+   VIP_CNTRL_2_SWAP_F(p->swap_f) |
+   (p->mirr_f ? VIP_CNTRL_2_MIRR_F : 0);
+
+   priv->audio_params = p->audio_params;
+}
+
 static int tda998x_bind(struct device *dev, struct device *master, void *data)
 {
struct tda998x_encoder_params *params = dev->platform_data;
@@ -1640,7 +1640,7 @@ static int tda998x_bind(struct device *dev, struct device 
*master, void *data)
return ret;

if (!dev->of_node && params)
-   tda998x_encoder_set_config(priv, params);
+   tda998x_set_config(priv, params);

tda998x_encoder_set_polling(priv, >connector);

-- 
2.1.0



[PATCH RFC 04/10] drm/i2c: tda998x: correct function name in comments

2016-10-23 Thread Russell King
Correct two references to tda998x_connector_get_modes() which were
incorrectly referring to tda998x_encoder_get_modes().

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 858237f7f4d6..134cd3f26a07 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -581,9 +581,9 @@ tda998x_reset(struct tda998x_priv *priv)
  * HPD assertion: it needs a delay of 100ms to avoid timing out while
  * trying to read EDID data.
  *
- * However, tda998x_encoder_get_modes() may be called at any moment
+ * However, tda998x_connector_get_modes() may be called at any moment
  * after tda998x_connector_detect() indicates that we are connected, so
- * we need to delay probing modes in tda998x_encoder_get_modes() after
+ * we need to delay probing modes in tda998x_connector_get_modes() after
  * we have seen a HPD inactive->active transition.  This code implements
  * that delay.
  */
-- 
2.1.0



[PATCH RFC 03/10] drm/i2c: tda998x: avoid racy access to mode clock

2016-10-23 Thread Russell King
Avoid a racy access to the mode clock by storing the current mode clock
during a mode set under the audio mutex.  This allows us to access it
from the audio path in a safe way.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 495ee3fed661..858237f7f4d6 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -48,6 +48,7 @@ struct tda998x_priv {
u8 vip_cntrl_0;
u8 vip_cntrl_1;
u8 vip_cntrl_2;
+   unsigned long tdms_clock;
struct tda998x_audio_params audio_params;

struct platform_device *audio_pdev;
@@ -714,8 +715,7 @@ static void tda998x_audio_mute(struct tda998x_priv *priv, 
bool on)

 static int
 tda998x_configure_audio(struct tda998x_priv *priv,
-   struct tda998x_audio_params *params,
-   unsigned mode_clock)
+   struct tda998x_audio_params *params)
 {
u8 buf[6], clksel_aip, clksel_fs, cts_n, adiv;
u32 n;
@@ -772,7 +772,7 @@ tda998x_configure_audio(struct tda998x_priv *priv,
 * assume 100MHz requires larger divider.
 */
adiv = AUDIO_DIV_SERCLK_8;
-   if (mode_clock > 10)
+   if (priv->tdms_clock > 10)
adiv++; /* AUDIO_DIV_SERCLK_16 */

/* S/PDIF asks for a larger divider */
@@ -1077,10 +1077,10 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,

tda998x_write_avi(priv, adjusted_mode);

+   priv->tdms_clock = adjusted_mode->clock;
+
if (priv->audio_params.format != AFMT_UNUSED)
-   tda998x_configure_audio(priv,
-   >audio_params,
-   adjusted_mode->clock);
+   tda998x_configure_audio(priv, >audio_params);
}

priv->is_hdmi_config = priv->is_hdmi_sink;
@@ -1230,9 +1230,6 @@ static int tda998x_audio_hw_params(struct device *dev, 
void *data,
.cea = params->cea,
};

-   if (!priv->encoder.crtc)
-   return -ENODEV;
-
memcpy(audio.status, params->iec.status,
   min(sizeof(audio.status), sizeof(params->iec.status)));

@@ -1270,8 +1267,7 @@ static int tda998x_audio_hw_params(struct device *dev, 
void *data,
mutex_lock(>audio_mutex);
/* We must not program the TDA998x for audio if the sink is DVI. */
if (priv->is_hdmi_config)
-   ret = tda998x_configure_audio(priv, ,
- priv->encoder.crtc->hwmode.clock);
+   ret = tda998x_configure_audio(priv, );
else
ret = 0;

-- 
2.1.0



[PATCH RFC 02/10] drm/i2c: tda998x: avoid configuring audio for DVI mode

2016-10-23 Thread Russell King
We must not configure the audio path when the sink is a DVI device, as
DVI has no capability to receive HDMI audio.  HDMI audio is a HDMI only
feature, requiring HDMI infoframes.

There's a question concerning how to handle a DVI connected device when
the audio device is opened - we save the audio configuration, so that if
a HDMI device is hotplugged, audio will then work.  This seems a
reasonable expectation.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index d72bc30a3bce..495ee3fed661 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -44,6 +44,7 @@ struct tda998x_priv {
u8 current_page;
int dpms;
bool is_hdmi_sink;
+   bool is_hdmi_config;
u8 vip_cntrl_0;
u8 vip_cntrl_1;
u8 vip_cntrl_2;
@@ -971,6 +972,8 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,
div = 3;
}

+   mutex_lock(>audio_mutex);
+
/* mute the audio FIFO: */
reg_set(priv, REG_AIP_CNTRL_0, AIP_CNTRL_0_RST_FIFO);

@@ -1074,13 +1077,14 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,

tda998x_write_avi(priv, adjusted_mode);

-   mutex_lock(>audio_mutex);
if (priv->audio_params.format != AFMT_UNUSED)
tda998x_configure_audio(priv,
>audio_params,
adjusted_mode->clock);
-   mutex_unlock(>audio_mutex);
}
+
+   priv->is_hdmi_config = priv->is_hdmi_sink;
+   mutex_unlock(>audio_mutex);
 }

 static enum drm_connector_status
@@ -1264,9 +1268,12 @@ static int tda998x_audio_hw_params(struct device *dev, 
void *data,
}

mutex_lock(>audio_mutex);
-   ret = tda998x_configure_audio(priv,
- ,
- priv->encoder.crtc->hwmode.clock);
+   /* We must not program the TDA998x for audio if the sink is DVI. */
+   if (priv->is_hdmi_config)
+   ret = tda998x_configure_audio(priv, ,
+ priv->encoder.crtc->hwmode.clock);
+   else
+   ret = 0;

if (ret == 0)
priv->audio_params = audio;
-- 
2.1.0



[PATCH RFC 01/10] drm/i2c: tda998x: avoid race in tda998x_encoder_mode_set()

2016-10-23 Thread Russell King
As priv->audio_params can now be changed at run time, we need to be more
careful about how we deal with a mode set.  We must take the audio lock
while checking if there's a valid audio configuration.

However, it's slightly worse than that - during mode set, we mute the
audio, and it must not be unmuted until we have finished the mode set.
It is possible that the audio side may start while a mode set is in
progress, so take the audio_mutex lock around the whole mode setting
procedure.

Signed-off-by: Russell King 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index 9798d400d817..d72bc30a3bce 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1074,13 +1074,12 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,

tda998x_write_avi(priv, adjusted_mode);

-   if (priv->audio_params.format != AFMT_UNUSED) {
-   mutex_lock(>audio_mutex);
+   mutex_lock(>audio_mutex);
+   if (priv->audio_params.format != AFMT_UNUSED)
tda998x_configure_audio(priv,
>audio_params,
adjusted_mode->clock);
-   mutex_unlock(>audio_mutex);
-   }
+   mutex_unlock(>audio_mutex);
}
 }

-- 
2.1.0



[PATCH RFC 0/10] tda998x initial cleanups from bridge conversion

2016-10-23 Thread Russell King - ARM Linux
As part of the discussion about converting tda998x to a bridge, here's
some preparatory work for that, which includes a bunch of fixes.  I'm
sending this out _early_ as I'm not going to be working on any kernel
stuff next week (it's likely I won't even be reading email.)  So it may
be a little rough around the edges.

Essentially, this is a series of cleanups, complexity removal, and
avoiding races with the newly introduced audio support.  Even without
the bridge conversion, I think all these are still worthwhile to have.

This series of changes can also be found in my drm-tda998x-devel branch
as an unstable series of commits (iow, I'm going to rebase/rework these
at some point, so the commit IDs are not stable, so do not merge this.)

 git://git.armlinux.org.uk/~rmk/linux-arm.git drm-tda998x-devel

 drivers/gpu/drm/i2c/tda998x_drv.c | 782 +++---
 1 file changed, 394 insertions(+), 388 deletions(-)

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.


[Bug 92555] GPU lockup crashing the system on Cayman with HyperZ

2016-10-23 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=92555

--- Comment #9 from Marek Olšák  ---
This might help:
https://cgit.freedesktop.org/mesa/mesa/commit/?id=d4d9ec55c589156df4edc227a86b4a8c41048d58

Although it's an unrelated feature, it changes the allocation function from
pipe_buffer_create to r600_aligned_buffer_create. I believe that can fix HyperZ
hangs on big GPU.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20161023/44f384cb/attachment.html>


[PATCH 1/1] drm/i915/dsi: silence a warning about uninitialized return value

2016-10-23 Thread Nicolas Iooss
Hello,

I sent the patch below a few weeks ago. I got some comments (cf. [1])
which looked good, but the patch has not been merged in linux-next yet.
Do I need to fix something (like rewrite the commit message) in order to
get it merged?

Thanks,
Nicolas

[1] https://patchwork.freedesktop.org/patch/108941/

On 04/09/16 20:58, Nicolas Iooss wrote:
> When building the kernel with clang and some warning flags, the compiler
> reports that the return value of dcs_get_backlight() may be
> uninitialized:
> 
> drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c:53:2: error: variable
> 'data' is used uninitialized whenever 'for' loop exits because its
> condition is false [-Werror,-Wsometimes-uninitialized]
> for_each_dsi_port(port, intel_dsi->dcs_backlight_ports) {
> ^~~
> drivers/gpu/drm/i915/intel_dsi.h:126:49: note: expanded from macro
> 'for_each_dsi_port'
> #define for_each_dsi_port(__port, __ports_mask)
> for_each_port_masked(__port, __ports_mask)
> ^~
> drivers/gpu/drm/i915/i915_drv.h:322:26: note: expanded from macro
> 'for_each_port_masked'
> for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)  \
> ^
> drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c:60:9: note:
> uninitialized use occurs here
> return data;
>^~~~
> 
> As intel_dsi->dcs_backlight_ports seems to be always initialized to a
> non-null value, the content of the for loop is always executed and there
> is no bug in the current code. Nevertheless the compiler has no way of
> knowing that assumption, so initialize variable 'data' to silence the
> warning here.
> 
> Signed-off-by: Nicolas Iooss 
> ---
>  drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c 
> b/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
> index ac7c6020c443..eec45856f910 100644
> --- a/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
> +++ b/drivers/gpu/drm/i915/intel_dsi_dcs_backlight.c
> @@ -46,7 +46,7 @@ static u32 dcs_get_backlight(struct intel_connector 
> *connector)
>   struct intel_encoder *encoder = connector->encoder;
>   struct intel_dsi *intel_dsi = enc_to_intel_dsi(>base);
>   struct mipi_dsi_device *dsi_device;
> - u8 data;
> + u8 data = 0;
>   enum port port;
>  
>   /* FIXME: Need to take care of 16 bit brightness level */
> 



[Intel-gfx] [PATCH 1/1] drm/i915/dsi: silence a warning about uninitialized return value

2016-10-23 Thread Chris Wilson
On Sun, Oct 23, 2016 at 06:55:58PM +0200, Nicolas Iooss wrote:
> Hello,
> 
> I sent the patch below a few weeks ago. I got some comments (cf. [1])
> which looked good, but the patch has not been merged in linux-next yet.
> Do I need to fix something (like rewrite the commit message) in order to
> get it merged?

It basically boils down to that you said it doesn't fix a bug, but shuts
up a non-default compiler using custom warning flags.

But there is a bug in that code, as mipi_dsi_dcs_read() may return an
error value, which may just be ENOMEM, but if it did we would return the
garbage. Not only should we fix the error handling here, but you also
need to fix the error handling in drivers/video/backlight/backlight.c as
despite many callees returning an error, it assumes that
bd->ops->get_brightness() never returns an error...
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[Bug 98162] gpu hangs with unigine heaven on drm-next-4.9-wip

2016-10-23 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=98162

--- Comment #6 from Christoph Haag  ---
Created attachment 127496
  --> https://bugs.freedesktop.org/attachment.cgi?id=127496=edit
wine+nine csgo gpu fault and hang amd-staging-4.7

Wait, this amd-staging-4.7 revision doesn't work well either. Tried with csgo
nine and it fails too.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20161023/299f5621/attachment.html>


[Bug 98238] witcher 2: objects are black when changing lod

2016-10-23 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=98238

--- Comment #1 from Arek Ruśniak  ---
Hi, i am pretty sure few months ago worked as it should. i've tried to bisected
but it not easy or maybe it's almost impossible find good one
kernel/LLVM/mesa/libdrm/xorg/glamor..
So i installed fresh debian 8:
kernel 3.16
LLVM 3.5
mesa 10.6 (IIRC)
xorg 1.16.x
and issue still here, maybe this is game bug not mesa or i've got blind
i have this issue on steam, i can test gog version later. 
And there is beta_public_linux on steam so can be worth to test as well 

i965 & r600 works good
Tested on verde, juniper and haswell.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20161023/6c8a4009/attachment.html>


[linux-sunxi] [PATCH v5 4/7] ASoC: sunxi: Add sun8i I2S driver

2016-10-23 Thread Jean-Francois Moine
On Sun, 23 Oct 2016 09:33:16 +0800
Chen-Yu Tsai  wrote:

> > Note: This driver is closed to the sun4i-i2s except that:
> > - it handles the H3
> 
> If it's close to sun4i-i2s, you should probably rework that one to support
> the newer SoCs.
> 
> > - it creates the sound card (with sun4i-i2s, the sound card is created
> >   by the CODECs)
> 
> I think this is wrong. I2S is only the DAI. You typically have a separate
> platform driver for the whole card, or just use simple-card.

An other device is not needed. The layout is simple:
I2S_controller (CPU DAI) <-> HDMI_CODEC (CODEC DAI)
The HDMI CODEC is supported by the HDMI video driver (only one device),
so, it cannot be the card device.
ASoC does not use the CPU DAI device (I2S_controller), so, it is
natural to use it to handle the card.
Otherwise, the simple-card asks for a node definition in the DT and
this node is a pure Linux software entity. On the other side, the
simple-graph-card from Kuninori is not useful for this simple case.

-- 
Ken ar c'hentañ| ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/


[linux-sunxi] [PATCH v5 0/7] ARM: ASoC: drm: sun8i: Add DE2 HDMI audio and video

2016-10-23 Thread Chen-Yu Tsai
On Sat, Oct 22, 2016 at 9:28 PM, Jean-Francois Moine  wrote:
> This patchset series adds HDMI audio and video support to the Allwinner
> sun8i SoCs which include the display engine 2 (DE2).
>
> A first submission in January for video on the H3 could not enter into
> the mainline kernel due to the lack of license headers in Allwinner's
> sources.
>
> Recently, an announce about Tina OS for the R series
> https://www.youtube.com/watch?v=h7KD-6HblAU
> was followed by the upload of a new linux-3.4 source tree
> https://github.com/tinalinux/linux-3.4
> with files containing GPL headers.
>
> Well, I don't know if these sources are really from Allwinner, but
> anyway, this is the opportunity to propose a new version of my DRM
> HDMI driver.

Could you clarify about this bit? Did you just clean up Allwinner's
existing drivers? Or just use them as reference? Either way I think
this deserves some mention in all your copyright headers.

Otherwise what difference does the new release make?

Regards
ChenYu


>
> v5:
> - add overlay plane
> - add audio support
> - add support for the A83T
> - add back the HDMI driver
> - many bug fixes
> v4:
> - drivers/clk/sunxi/Makefile was missing (Emil Velikov)
> v3:
> - add the hardware cursor
> - simplify and fix the DE2 init sequences
> - generation for all SUNXI SoCs (Andre Przywara)
> v2:
> - remove the HDMI driver
> - remarks from Chen-Yu Tsai and Russell King
> - DT documentation added
>
> Jean-Francois Moine (7):
>   drm: sunxi: Add a basic DRM driver for Allwinner DE2
>   ASoC: sunxi: Add a simple HDMI CODEC
>   drm: sunxi: add DE2 HDMI support
>   ASoC: sunxi: Add sun8i I2S driver
>   ARM: dts: sun8i-h3: add HDMI audio and video nodes
>   ARM: dts: sun8i-h3: Add HDMI audio and video to the Banana Pi M2+
>   ARM: dts: sun8i-h3: Add HDMI audio and video to the Orange PI 2
>
>  .../devicetree/bindings/display/sunxi/hdmi.txt |  52 ++
>  .../bindings/display/sunxi/sunxi-de2.txt   |  83 ++
>  .../devicetree/bindings/sound/sun4i-i2s.txt|  38 +-
>  arch/arm/boot/dts/sun8i-h3-bananapi-m2-plus.dts|  17 +
>  arch/arm/boot/dts/sun8i-h3-orangepi-2.dts  |  17 +
>  arch/arm/boot/dts/sun8i-h3.dtsi|  67 ++
>  drivers/gpu/drm/Kconfig|   2 +
>  drivers/gpu/drm/Makefile   |   1 +
>  drivers/gpu/drm/sunxi/Kconfig  |  29 +
>  drivers/gpu/drm/sunxi/Makefile |   9 +
>  drivers/gpu/drm/sunxi/de2_crtc.c   | 475 +++
>  drivers/gpu/drm/sunxi/de2_crtc.h   |  63 ++
>  drivers/gpu/drm/sunxi/de2_de.c | 591 +
>  drivers/gpu/drm/sunxi/de2_drm.h|  47 ++
>  drivers/gpu/drm/sunxi/de2_drv.c| 378 +
>  drivers/gpu/drm/sunxi/de2_hdmi.c   | 396 +
>  drivers/gpu/drm/sunxi/de2_hdmi.h   |  40 +
>  drivers/gpu/drm/sunxi/de2_hdmi_io.c| 927 
> +
>  drivers/gpu/drm/sunxi/de2_hdmi_io.h|  25 +
>  drivers/gpu/drm/sunxi/de2_plane.c  | 119 +++
>  include/sound/sunxi_hdmi.h |  23 +
>  sound/soc/codecs/Kconfig   |   9 +
>  sound/soc/codecs/Makefile  |   2 +
>  sound/soc/codecs/sunxi-hdmi.c  | 106 +++
>  sound/soc/sunxi/Kconfig|   8 +
>  sound/soc/sunxi/Makefile   |   3 +
>  sound/soc/sunxi/sun8i-i2s.c| 700 
>  27 files changed, 4222 insertions(+), 5 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/display/sunxi/hdmi.txt
>  create mode 100644 
> Documentation/devicetree/bindings/display/sunxi/sunxi-de2.txt
>  create mode 100644 drivers/gpu/drm/sunxi/Kconfig
>  create mode 100644 drivers/gpu/drm/sunxi/Makefile
>  create mode 100644 drivers/gpu/drm/sunxi/de2_crtc.c
>  create mode 100644 drivers/gpu/drm/sunxi/de2_crtc.h
>  create mode 100644 drivers/gpu/drm/sunxi/de2_de.c
>  create mode 100644 drivers/gpu/drm/sunxi/de2_drm.h
>  create mode 100644 drivers/gpu/drm/sunxi/de2_drv.c
>  create mode 100644 drivers/gpu/drm/sunxi/de2_hdmi.c
>  create mode 100644 drivers/gpu/drm/sunxi/de2_hdmi.h
>  create mode 100644 drivers/gpu/drm/sunxi/de2_hdmi_io.c
>  create mode 100644 drivers/gpu/drm/sunxi/de2_hdmi_io.h
>  create mode 100644 drivers/gpu/drm/sunxi/de2_plane.c
>  create mode 100644 include/sound/sunxi_hdmi.h
>  create mode 100644 sound/soc/codecs/sunxi-hdmi.c
>  create mode 100644 sound/soc/sunxi/sun8i-i2s.c
>
> --
> 2.10.1
>
> --
> You received this message because you are subscribed to the Google Groups 
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to linux-sunxi+unsubscribe at googlegroups.com.
> 

[linux-sunxi] [PATCH v5 0/7] ARM: ASoC: drm: sun8i: Add DE2 HDMI audio and video

2016-10-23 Thread Jean-Francois Moine
On Sun, 23 Oct 2016 09:38:04 +0800
Chen-Yu Tsai  wrote:

> > Recently, an announce about Tina OS for the R series
> > https://www.youtube.com/watch?v=h7KD-6HblAU
> > was followed by the upload of a new linux-3.4 source tree
> > https://github.com/tinalinux/linux-3.4
> > with files containing GPL headers.
> >
> > Well, I don't know if these sources are really from Allwinner, but
> > anyway, this is the opportunity to propose a new version of my DRM
> > HDMI driver.
> 
> Could you clarify about this bit? Did you just clean up Allwinner's
> existing drivers? Or just use them as reference? Either way I think
> this deserves some mention in all your copyright headers.
> 
> Otherwise what difference does the new release make?

- Allwinner's video driver is not DRM.
- their driver has no hardware cursor nor video overlay.
- I wrote the video DRM driver from the document
Allwinner_H3_Datasheet_V1.2.pdf
  and the structures defined in
linux-3.4/drivers/video/sunxi/disp2/disp/de/lowlevel_sun8iw7/de_rtmx.h
  Reading Allwinner's code helped me to understand how the DE2
  is working.
- my lowlevel HDMI is just a cleanup of theirs with explanations
  about the registers. Magic constants remain due to the lack of
  knowledge about the PHYs.
- the mention of Allwinner in the copyright headers is needed to
  indicate the source of the structures (DE2) and code (HDMI).

The main difference is the DRM interface and the use of the EDID,
permitting dynamic video resolution change with xrandr.

-- 
Ken ar c'hentañ| ** Breizh ha Linux atav! **
Jef |   http://moinejf.free.fr/


[linux-sunxi] [PATCH v5 4/7] ASoC: sunxi: Add sun8i I2S driver

2016-10-23 Thread Chen-Yu Tsai
Hi,

On Fri, Oct 21, 2016 at 4:36 PM, Jean-Francois Moine  wrote:
> This patch adds I2S support to sun8i SoCs as the A83T and H3.
>
> Signed-off-by: Jean-Francois Moine 
> ---
> Note: This driver is closed to the sun4i-i2s except that:
> - it handles the H3

If it's close to sun4i-i2s, you should probably rework that one to support
the newer SoCs.

> - it creates the sound card (with sun4i-i2s, the sound card is created
>   by the CODECs)

I think this is wrong. I2S is only the DAI. You typically have a separate
platform driver for the whole card, or just use simple-card.

> ---
>  .../devicetree/bindings/sound/sun4i-i2s.txt|  38 +-
>  sound/soc/sunxi/Kconfig|   8 +
>  sound/soc/sunxi/Makefile   |   3 +
>  sound/soc/sunxi/sun8i-i2s.c| 700 
> +
>  4 files changed, 744 insertions(+), 5 deletions(-)
>  create mode 100644 sound/soc/sunxi/sun8i-i2s.c
>
> diff --git a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt 
> b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
> index 7b526ec..2fb0a7a 100644
> --- a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
> +++ b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt
> @@ -1,4 +1,4 @@
> -* Allwinner A10 I2S controller
> +* Allwinner A10/A38T/H3 I2S controller
>
>  The I2S bus (Inter-IC sound bus) is a serial link for digital
>  audio data transfer between devices in the system.
> @@ -6,20 +6,30 @@ audio data transfer between devices in the system.
>  Required properties:
>
>  - compatible: should be one of the followings
> -   - "allwinner,sun4i-a10-i2s"
> +  - "allwinner,sun4i-a10-i2s"
> +   "allwinner,sun8i-a83t-i2s"
> +   "allwinner,sun8i-h3-i2s"
>  - reg: physical base address of the controller and length of memory mapped
>region.
> -- interrupts: should contain the I2S interrupt.
>  - dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
> Documentation/devicetree/bindings/dma/dma.txt
> -- dma-names: should include "tx" and "rx".
> +- dma-names: must include "tx" and/or "rx".
>  - clocks: a list of phandle + clock-specifer pairs, one for each entry in 
> clock-names.
>  - clock-names: should contain followings:
> - "apb" : clock for the I2S bus interface
> - "mod" : module clock for the I2S controller
>  - #sound-dai-cells : Must be equal to 0
>
> -Example:
> +Optional properties:
> +
> +- interrupts: I2S interrupt
> +- resets: phandle to the reset of the device
> +
> +Required nodes:
> +
> + - port: link to the associated CODEC (DAC, HDMI...)

Note here you are changing an existing binding, adding a required node.
If it were truely different, you probably should've started a new binding.

Regards
ChenYu

> +
> +Example 1:
>
>  i2s0: i2s at 01c22400 {
> #sound-dai-cells = <0>;
> @@ -32,3 +42,21 @@ i2s0: i2s at 01c22400 {
>< SUN4I_DMA_NORMAL 3>;
> dma-names = "rx", "tx";
>  };
> +
> +Example 2:
> +
> +i2s2: i2s at 1c22800 {
> +   compatible = "allwinner,sun8i-a83t-i2s";
> +   reg = <0x01c22800 0x60>;
> +   clocks = < CLK_BUS_I2S2>, < CLK_I2S2>;
> +   clock-names = "apb", "mod";
> +   resets = < RST_I2S2>;
> +   dmas = < 27>;
> +   dma-names = "tx";
> +   status = "disabled";
> +   port {
> +   i2s2_hdmi: endpoint {
> +   remote-endpoint = <_i2s2>;
> +   };
> +   };
> +};


[Bug 98170] [vdpau] Error when calling vdp_output_surface_create

2016-10-23 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=98170

--- Comment #4 from Branko  ---
I have cloned mesa-git and i'm trying to do it, but i get only this output:

$ git bisect start mesa-12.0.1 mesa-11.2.2
Previous HEAD position was 4cd5e5b... nouveau: update the Makefile.sources list
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Bisecting: a merge base must be tested
[4cd5e5b48e24a8b8ff7255022208d3e5fe6557d8] nouveau: update the Makefile.sources
list

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20161023/5083354d/attachment.html>


[PATCH] drm/rockchip: analogix_dp: add supports for regulators in edp IP

2016-10-23 Thread Randy Li
I found if eDP_AVDD_1V0 and eDP_AVDD_1V8 are not been power at
RK3288, once trying to enable the pclk clock, the kernel would dead.
This patch would try to enable them first. The eDP_AVDD_1V8 more
likely to be applied to eDP phy, but I have no time to confirmed
it yet.

Signed-off-by: Randy Li 
---
 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c 
b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 8548e82..6bf0441 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 

@@ -70,6 +71,7 @@ struct rockchip_dp_device {
struct clk   *grfclk;
struct regmap*grf;
struct reset_control *rst;
+   struct regulator_bulk_data supplies[2];

struct work_struct   psr_work;
spinlock_t   psr_lock;
@@ -146,6 +148,13 @@ static int rockchip_dp_poweron(struct 
analogix_dp_plat_data *plat_data)

cancel_work_sync(>psr_work);

+   ret = regulator_bulk_enable(ARRAY_SIZE(dp->supplies),
+   dp->supplies);
+   if (ret) {
+   dev_err(dp->dev, "failed to enable vdd supply %d\n", ret);
+   return ret;
+   }
+
ret = clk_prepare_enable(dp->pclk);
if (ret < 0) {
dev_err(dp->dev, "failed to enable pclk %d\n", ret);
@@ -168,6 +177,9 @@ static int rockchip_dp_powerdown(struct 
analogix_dp_plat_data *plat_data)

clk_disable_unprepare(dp->pclk);

+   regulator_bulk_disable(ARRAY_SIZE(dp->supplies),
+   dp->supplies);
+
return 0;
 }

@@ -323,6 +335,19 @@ static int rockchip_dp_init(struct rockchip_dp_device *dp)
return PTR_ERR(dp->rst);
}

+   dp->supplies[0].supply = "vcc";
+   dp->supplies[1].supply = "vccio";
+   ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dp->supplies),
+   dp->supplies);
+   if (ret < 0) {
+   dev_err(dev, "failed to get regulators: %d\n", ret);
+   }
+   ret = regulator_bulk_enable(ARRAY_SIZE(dp->supplies),
+   dp->supplies);
+   if (ret < 0) {
+   dev_err(dev, "failed to enable regulators: %d\n", ret);
+   }
+
ret = clk_prepare_enable(dp->pclk);
if (ret < 0) {
dev_err(dp->dev, "failed to enable pclk %d\n", ret);
-- 
2.7.4



[PATCH] drm/radeon/pm: autoswitch power state when in balanced mode

2016-10-23 Thread Lucas Stach
The current default of always using the performance power state leads
to increased power consumption of mobile devices, which have a dedicated
battery power state. Switch between the performance and battery power
state automatically, dpending on the current AC power status, when the
user asked for the balanced power state.

The user can still override this logic by asking for the performance
or battery power state explicitly.

Signed-off-by: Lucas Stach 
---
This saves about 1.2W on my Richland based laptop, whithout me having
to remember to ask for the battery state or have userspace set up in
a way to do this.
---
 drivers/gpu/drm/radeon/radeon_pm.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_pm.c 
b/drivers/gpu/drm/radeon/radeon_pm.c
index 4b65425..326ad06 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -47,6 +47,7 @@ static bool radeon_pm_in_vbl(struct radeon_device *rdev);
 static bool radeon_pm_debug_check_in_vbl(struct radeon_device *rdev, bool 
finish);
 static void radeon_pm_update_profile(struct radeon_device *rdev);
 static void radeon_pm_set_clocks(struct radeon_device *rdev);
+static void radeon_pm_compute_clocks_dpm(struct radeon_device *rdev);

 int radeon_pm_get_type_index(struct radeon_device *rdev,
 enum radeon_pm_state_type ps_type,
@@ -79,6 +80,8 @@ void radeon_pm_acpi_event_handler(struct radeon_device *rdev)
radeon_dpm_enable_bapm(rdev, 
rdev->pm.dpm.ac_power);
}
mutex_unlock(>pm.mutex);
+   /* allow new DPM state to be picked */
+   radeon_pm_compute_clocks_dpm(rdev);
} else if (rdev->pm.pm_method == PM_METHOD_PROFILE) {
if (rdev->pm.profile == PM_PROFILE_AUTO) {
mutex_lock(>pm.mutex);
@@ -882,7 +885,8 @@ static struct radeon_ps *radeon_dpm_pick_power_state(struct 
radeon_device *rdev,
dpm_state = POWER_STATE_TYPE_INTERNAL_3DPERF;
/* balanced states don't exist at the moment */
if (dpm_state == POWER_STATE_TYPE_BALANCED)
-   dpm_state = POWER_STATE_TYPE_PERFORMANCE;
+   dpm_state = rdev->pm.dpm.ac_power ?
+   POWER_STATE_TYPE_PERFORMANCE : POWER_STATE_TYPE_BATTERY;

 restart_search:
/* Pick the best power state based on current conditions */
-- 
2.7.4