Re: [PATCH] drm/bridge: Centralize error message when bridge attach fails

2021-04-15 Thread Jyri Sarha

On 2021-04-15 4:47, Laurent Pinchart wrote:

Being informed of a failure to attach a bridge is useful, and many
drivers prints an error message in that case. Move the message to
drm_bridge_attach() to avoid code duplication.

Suggested-by: Stephen Boyd 
Signed-off-by: Laurent Pinchart 



Reviewed-by: Jyri Sarha 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/tilcdc: fix LCD pixel clock setting

2021-03-19 Thread Jyri Sarha

On 2021-03-18 23:47, Dario Binacchi wrote:

Il 17/03/2021 09:19 Tomi Valkeinen  ha scritto:


On 14/03/2021 17:13, Dario Binacchi wrote:
> As reported by TI spruh73x RM, the LCD pixel clock (LCD_PCLK) frequency
> is obtained by dividing LCD_CLK, the LCD controller reference clock,
> for CLKDIV:
>
> LCD_PCLK = LCD_CLK / CLKDIV
>
> where CLKDIV must be greater than 1.
>
> Therefore LCD_CLK must be set to 'req_rate * CLKDIV' instead of req_rate

The above doesn't make sense, the code already sets LCD_CLK to 
'req_rate

* clkdiv', not req_rate.

> and the real LCD_CLK rate must be compared with 'req_rate * CLKDIV' and
> not with req_rate.

This is true, the code looks at the wrong value.

> Passing req_rate instead of 'req_rate * CLKDIV' to the tilcdc_pclk_diff
> routine caused it to fail even if LCD_CLK was properly set.
>
> Signed-off-by: Dario Binacchi 
>
> ---
>
>   drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 9 +
>   1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> index 30213708fc99..02f56c9a5da5 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> @@ -203,7 +203,7 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
>struct drm_device *dev = crtc->dev;
>struct tilcdc_drm_private *priv = dev->dev_private;
>struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
> -  unsigned long clk_rate, real_rate, req_rate;
> +  unsigned long clk_rate, real_rate, req_rate, clk_div_rate;
>unsigned int clkdiv;
>int ret;
>
> @@ -211,10 +211,11 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc)
>
>/* mode.clock is in KHz, set_rate wants parameter in Hz */
>req_rate = crtc->mode.clock * 1000;
> -
> -  ret = clk_set_rate(priv->clk, req_rate * clkdiv);
> +  /* LCD clock divisor input rate */
> +  clk_div_rate = req_rate * clkdiv;

"clk_div_rate" sounds a bit odd to me. Why not lcd_fck_rate, as that's
the name used later? Or lcd_clk_rate. Or maybe lcd_clk_req_rate...


I prefer lcd_clk_rate.

How about adding an additional patch that changes the variable names to 
make

the code more readable?

req_rate -> lcd_pclk_rate
clk_rate -> real_lcd_clk_rate

And add a comment to the function which highlights the relationship
LCD_CLK = LCD_PCLK * CLDIV ?



What about renaming current req_rate to pclk_rate (for pixel clock 
rate), and calling pclk_rate * clkdiv = req_rate, as that is the rate we 
need to request from the input clock? Adding lcd to local variable names 
here is quite redundant after all. In any case req_rate is bit 
misleading name here and probably part of the reason why the bug exists 
in the first place.


Best regards,
Jyri





> +  ret = clk_set_rate(priv->clk, clk_div_rate);
>clk_rate = clk_get_rate(priv->clk);
> -  if (ret < 0 || tilcdc_pclk_diff(req_rate, clk_rate) > 5) {
> +  if (ret < 0 || tilcdc_pclk_diff(clk_div_rate, clk_rate) > 5) {
>/*
> * If we fail to set the clock rate (some architectures don't
> * use the common clock framework yet and may not implement
>

I think this fix is fine, but looking at the current code, it's 
calling

tilcdc_pclk_diff(), but doesn't actually provide pixel clocks to the
function, but fclk.


Yes, I agree.

Thanks and regards,
Dario



  Tomi

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 0/3] drm/tilcdc: fix LCD pixel clock setting

2021-03-21 Thread Jyri Sarha

On 2021-03-21 10:31, Dario Binacchi wrote:

The series was born from a patch to fix the LCD pixel clock setting.
Two additional patches have been added to this. One renames a 
misleading
variable name that was probably the cause of the bug and the other 
fixes

a warning message.



Thanks you,

I think this looks good now.

Reviewed-by: Jyri Sarha 

For the series.

I'll wait a day or two if Tomi has something more to say and merge this 
to drm-misc-next.


Best regards,
Jyri



Changes in v2:
- The patch has been added in version 2.
- Rename clk_div_rate to real_pclk_rate.
- Provide pixel clock rate to tilcdc_pclk_diff().
- The patch has been added in version 2.

Dario Binacchi (3):
  drm/tilcdc: rename req_rate to pclk_rate
  drm/tilcdc: fix LCD pixel clock setting
  drm/tilcdc: fix pixel clock setting warning message

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/tilcdc: panel: fix platform_no_drv_owner.cocci warnings

2021-03-21 Thread Jyri Sarha

On 2021-03-03 11:04, Yang Li wrote:

./drivers/gpu/drm/tilcdc/tilcdc_panel.c:402:3-8: No need to set .owner
here. The core will do it.

Remove .owner field if calls are used which set it automatically

Reported-by: Abaci Robot 
Signed-off-by: Yang Li 


Reviewed-by: Jyri Sarha 

I'll merge this soon to drm-misc-next.

Best regards,
Jyri


---
 drivers/gpu/drm/tilcdc/tilcdc_panel.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
index 00efc30..4235780 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_panel.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_panel.c
@@ -399,7 +399,6 @@ static int panel_remove(struct platform_device 
*pdev)

.probe = panel_probe,
.remove = panel_remove,
.driver = {
-   .owner = THIS_MODULE,
.name = "tilcdc-panel",
.of_match_table = panel_of_match,
},

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 0/3] drm/tilcdc: fix LCD pixel clock setting

2021-03-23 Thread Jyri Sarha

Thanks,

Reviewed-by: Jyri Sarha 
for the series.

I'll merge these later today.

Best regards,
Jyri

On 2021-03-22 23:33, Dario Binacchi wrote:

The series was born from a patch to fix the LCD pixel clock setting.
Two additional patches have been added to this. One renames a 
misleading
variable name that was probably the cause of the bug and the other 
fixes

a warning message.


Changes in v3:
- Replace calculated with requested in the warning message.
- Swap the positions of the real_pclk_rate, and pclk_rate parameters
  in the warning message.

Changes in v2:
- The patch has been added in version 2.
- Rename clk_div_rate to real_pclk_rate.
- Provide pixel clock rate to tilcdc_pclk_diff().
- The patch has been added in version 2.

Dario Binacchi (3):
  drm/tilcdc: rename req_rate to pclk_rate
  drm/tilcdc: fix LCD pixel clock setting
  drm/tilcdc: fix pixel clock setting warning message

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/tilcdc: send vblank event when disabling crtc

2021-02-09 Thread Jyri Sarha

On 2021-02-09 5:09, quanyang.wang wrote:

Ping.



Could you resend the original patch (I have not received it) so I can 
easily test and merge it?


I'll find some time to do it soon.

Best regards,
Jyri


On 1/29/21 3:58 PM, Tomi Valkeinen wrote:

Dropped the @ti.com addresses and added the new ones.

  Tomi

On 29/01/2021 07:58, quanyang.w...@windriver.com wrote:

From: Quanyang Wang 

When run xrandr to change resolution on Beaglebone Black board, it 
will

print the error information:

root@beaglebone:~# xrandr -display :0 --output HDMI-1 --mode 720x400
[drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [CRTC:32:tilcdc 
crtc] commit wait timed out

[drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* 
[CONNECTOR:34:HDMI-A-1] commit wait timed out

[drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* 
[PLANE:31:plane-0] commit wait timed out

tilcdc 4830e000.lcdc: already pending page flip!

This is because there is operation sequence as below:

drm_atomic_connector_commit_dpms(mode is DRM_MODE_DPMS_OFF):
 ...
 drm_atomic_helper_setup_commit <- 
init_completion(commit_A->flip_done)

 drm_atomic_helper_commit_tail
 tilcdc_crtc_atomic_disable
 tilcdc_plane_atomic_update <- drm_crtc_send_vblank_event in 
tilcdc_crtc_irq
   is skipped since 
tilcdc_crtc->enabled is 0
 tilcdc_crtc_atomic_flush   <- drm_crtc_send_vblank_event is 
skipped since
   crtc->state->event is set to 
be NULL in

   tilcdc_plane_atomic_update
drm_mode_setcrtc:
 ...
 drm_atomic_helper_setup_commit <- 
init_completion(commit_B->flip_done)

 drm_atomic_helper_wait_for_dependencies
 drm_crtc_commit_wait   <- wait for commit_A->flip_done 
completing


Just as shown above, the steps which could complete 
commit_A->flip_done
are all skipped and commit_A->flip_done will never be completed. This 
will
result a time-out ERROR when drm_crtc_commit_wait check the 
commit_A->flip_done.

So add drm_crtc_send_vblank_event in tilcdc_crtc_atomic_disable to
complete commit_A->flip_done.

Fixes: cb345decb4d2 ("drm/tilcdc: Use standard 
drm_atomic_helper_commit")

Signed-off-by: Quanyang Wang 
---
  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 9 +
  1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c

index 30213708fc99..d99afd19ca08 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -515,6 +515,15 @@ static void tilcdc_crtc_off(struct drm_crtc 
*crtc, bool shutdown)

drm_crtc_vblank_off(crtc);
  + spin_lock_irq(&crtc->dev->event_lock);
+
+   if (crtc->state->event) {
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   }
+
+   spin_unlock_irq(&crtc->dev->event_lock);
+
tilcdc_crtc_disable_irqs(dev);
pm_runtime_put_sync(dev->dev);


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RESEND][PATCH] drm/tilcdc: send vblank event when disabling crtc

2021-02-09 Thread Jyri Sarha

On 2021-02-09 10:24, quanyang.w...@windriver.com wrote:

From: Quanyang Wang 

When run xrandr to change resolution on Beaglebone Black board, it will
print the error information:

root@beaglebone:~# xrandr -display :0 --output HDMI-1 --mode 720x400
[drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR* [CRTC:32:tilcdc
crtc] commit wait timed out
[drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR*
[CONNECTOR:34:HDMI-A-1] commit wait timed out
[drm:drm_crtc_commit_wait] *ERROR* flip_done timed out
[drm:drm_atomic_helper_wait_for_dependencies] *ERROR*
[PLANE:31:plane-0] commit wait timed out
tilcdc 4830e000.lcdc: already pending page flip!

This is because there is operation sequence as below:

drm_atomic_connector_commit_dpms(mode is DRM_MODE_DPMS_OFF):
...
drm_atomic_helper_setup_commit <- 
init_completion(commit_A->flip_done)

drm_atomic_helper_commit_tail
tilcdc_crtc_atomic_disable
tilcdc_plane_atomic_update <- drm_crtc_send_vblank_event in
tilcdc_crtc_irq
  is skipped since 
tilcdc_crtc->enabled is 0

tilcdc_crtc_atomic_flush   <- drm_crtc_send_vblank_event is
skipped since
  crtc->state->event is set to be 
NULL in

  tilcdc_plane_atomic_update
drm_mode_setcrtc:
...
drm_atomic_helper_setup_commit <- 
init_completion(commit_B->flip_done)

drm_atomic_helper_wait_for_dependencies
drm_crtc_commit_wait   <- wait for commit_A->flip_done 
completing


Just as shown above, the steps which could complete commit_A->flip_done
are all skipped and commit_A->flip_done will never be completed. This 
will
result a time-out ERROR when drm_crtc_commit_wait check the 
commit_A->flip_done.

So add drm_crtc_send_vblank_event in tilcdc_crtc_atomic_disable to
complete commit_A->flip_done.

Fixes: cb345decb4d2 ("drm/tilcdc: Use standard 
drm_atomic_helper_commit")

Signed-off-by: Quanyang Wang 


Reviewed-by: Jyri Sarha 
Tested-by: Jyri Sarha 

Thanks a lot! I think I have bumbed into this once or twice, but latelu 
I have had time to look into this. I'll merge this to drm-misc-next 
soon.


Best regards,
Jyri


---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 30213708fc99..d99afd19ca08 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -515,6 +515,15 @@ static void tilcdc_crtc_off(struct drm_crtc
*crtc, bool shutdown)

drm_crtc_vblank_off(crtc);

+   spin_lock_irq(&crtc->dev->event_lock);
+
+   if (crtc->state->event) {
+   drm_crtc_send_vblank_event(crtc, crtc->state->event);
+   crtc->state->event = NULL;
+   }
+
+   spin_unlock_irq(&crtc->dev->event_lock);
+
tilcdc_crtc_disable_irqs(dev);

pm_runtime_put_sync(dev->dev);

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/tilcdc: replace spin_lock_irqsave by spin_lock in hard IRQ

2021-02-18 Thread Jyri Sarha

On 2021-02-08 4:32, Tian Tao wrote:

The code has been in a irq-disabled context since it is hard IRQ. There
is no necessity to do it again.

Signed-off-by: Tian Tao 


Reviewed-by: Jyri Sarha 
Tested-by: Jyri Sarha 

I merge to this drm-misc-next soon.

Best regards,
Jyri


---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 3021370..b3e38e9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -904,13 +904,12 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc 
*crtc)

tilcdc_clear_irqstatus(dev, stat);

if (stat & LCDC_END_OF_FRAME0) {
-   unsigned long flags;
bool skip_event = false;
ktime_t now;

now = ktime_get();

-   spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
+   spin_lock(&tilcdc_crtc->irq_lock);

tilcdc_crtc->last_vblank = now;

@@ -920,21 +919,21 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc 
*crtc)

skip_event = true;
}

-   spin_unlock_irqrestore(&tilcdc_crtc->irq_lock, flags);
+   spin_unlock(&tilcdc_crtc->irq_lock);

drm_crtc_handle_vblank(crtc);

if (!skip_event) {
struct drm_pending_vblank_event *event;

-   spin_lock_irqsave(&dev->event_lock, flags);
+   spin_lock(&dev->event_lock);

event = tilcdc_crtc->event;
tilcdc_crtc->event = NULL;
if (event)
drm_crtc_send_vblank_event(crtc, event);

-   spin_unlock_irqrestore(&dev->event_lock, flags);
+   spin_unlock(&dev->event_lock);
}

if (tilcdc_crtc->frame_intact)

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RESEND PATCH] drm/tilcdc: fix raster control register setting

2021-02-18 Thread Jyri Sarha

On 2021-02-16 22:22, Dario Binacchi wrote:

The fdd property of the tilcdc_panel_info structure must set the reqdly
bit field  (bit 12 to 19) of the raster control register. The previous
statement set the least significant bit instead.

Signed-off-by: Dario Binacchi 


Reviewed-by: Jyri Sarha 
Tested-by: Jyri Sarha 

Thanks for a good catch. I'll merge to this drm-misc-next soon.

Best regards,
Jyri



---

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 30213708fc99..238068e28729 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -393,7 +393,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc 
*crtc)

return;
}
}
-   reg |= info->fdd < 12;
+   reg |= info->fdd << 12;
tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg);

if (info->invert_pxl_clk)

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator

2022-03-27 Thread Jyri Sarha

On 2022-03-27 9:15, Xiaomeng Tong wrote:

The bug is here:
if (!encoder) {

The list iterator value 'encoder' will *always* be set and non-NULL
by list_for_each_entry(), so it is incorrect to assume that the
iterator value will be NULL if the list is empty or no element
is found.

To fix the bug, use a new variable 'iter' as the list iterator,
while use the original variable 'encoder' as a dedicated pointer
to point to the found element.

Cc: sta...@vger.kernel.org
Fixes: ec9eab097a500 ("drm/tilcdc: Add drm bridge support for
attaching drm bridge drivers")
Signed-off-by: Xiaomeng Tong 


Thanks for the patch. Good catch.

Reviewed-by: Jyri Sarha 
Tested-by: Jyri Sarha 

I'll apply this to drm-misc-next in couple of days.

Best regards,
Jyri


---
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c
b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 7594cf6e186e..3b86d002ef62 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -60,11 +60,13 @@ struct drm_connector
*tilcdc_encoder_find_connector(struct drm_device *ddev,
 int tilcdc_add_component_encoder(struct drm_device *ddev)
 {
struct tilcdc_drm_private *priv = ddev->dev_private;
-   struct drm_encoder *encoder;
+   struct drm_encoder *encoder = NULL, *iter;

-   list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head)
-   if (encoder->possible_crtcs & (1 << priv->crtc->index))
+   list_for_each_entry(iter, &ddev->mode_config.encoder_list, head)
+   if (iter->possible_crtcs & (1 << priv->crtc->index)) {
+   encoder = iter;
break;
+   }

if (!encoder) {
dev_err(ddev->dev, "%s: No suitable encoder found\n", __func__);


Re: [PATCH] drm: Remove redundant 'flush_workqueue()' calls

2021-10-12 Thread Jyri Sarha

On 2021-10-10 16:59, Christophe JAILLET wrote:

'destroy_workqueue()' already drains the queue before destroying it, so
there is no need to flush it explicitly.

Remove the redundant 'flush_workqueue()' calls.

This was generated with coccinelle:

@@
expression E;
@@
-   flush_workqueue(E);
destroy_workqueue(E);

Signed-off-by: Christophe JAILLET 


For tilcdc
Acked-by: Jyri Sarha 

Thanks,
Jyri


---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 1 -
 drivers/gpu/drm/msm/dsi/dsi_host.c| 1 -
 drivers/gpu/drm/msm/edp/edp_ctrl.c| 1 -
 drivers/gpu/drm/msm/hdmi/hdmi.c   | 4 +---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c   | 4 +---
 drivers/gpu/drm/vmwgfx/ttm_memory.c   | 1 -
 6 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 789acae37f55..06bde46df451 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1733,7 +1733,6 @@ static void etnaviv_gpu_unbind(struct device
*dev, struct device *master,

DBG("%s", dev_name(gpu->dev));

-   flush_workqueue(gpu->wq);
destroy_workqueue(gpu->wq);

etnaviv_sched_fini(gpu);
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index c86b5090fae6..462ea65ebf89 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1925,7 +1925,6 @@ void msm_dsi_host_destroy(struct mipi_dsi_host 
*host)

DBG("");
dsi_tx_buf_free(msm_host);
if (msm_host->workqueue) {
-   flush_workqueue(msm_host->workqueue);
destroy_workqueue(msm_host->workqueue);
msm_host->workqueue = NULL;
}
diff --git a/drivers/gpu/drm/msm/edp/edp_ctrl.c
b/drivers/gpu/drm/msm/edp/edp_ctrl.c
index fe1366b4c49f..07129a6e5dbb 100644
--- a/drivers/gpu/drm/msm/edp/edp_ctrl.c
+++ b/drivers/gpu/drm/msm/edp/edp_ctrl.c
@@ -1190,7 +1190,6 @@ void msm_edp_ctrl_destroy(struct edp_ctrl *ctrl)
return;

if (ctrl->workqueue) {
-   flush_workqueue(ctrl->workqueue);
destroy_workqueue(ctrl->workqueue);
ctrl->workqueue = NULL;
}
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c 
b/drivers/gpu/drm/msm/hdmi/hdmi.c

index 737453b6e596..5ba7c8f28419 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
@@ -61,10 +61,8 @@ static void msm_hdmi_destroy(struct hdmi *hdmi)
 * at this point, hpd has been disabled,
 * after flush workq, it's safe to deinit hdcp
 */
-   if (hdmi->workq) {
-   flush_workqueue(hdmi->workq);
+   if (hdmi->workq)
destroy_workqueue(hdmi->workq);
-   }
msm_hdmi_hdcp_destroy(hdmi);

if (hdmi->phy_dev) {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 6b03f89a98d4..3ddb7c710a3d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -186,10 +186,8 @@ static void tilcdc_fini(struct drm_device *dev)
if (priv->mmio)
iounmap(priv->mmio);

-   if (priv->wq) {
-   flush_workqueue(priv->wq);
+   if (priv->wq)
destroy_workqueue(priv->wq);
-   }

dev->dev_private = NULL;

diff --git a/drivers/gpu/drm/vmwgfx/ttm_memory.c
b/drivers/gpu/drm/vmwgfx/ttm_memory.c
index edd17c30d5a5..7f7fe35fc21d 100644
--- a/drivers/gpu/drm/vmwgfx/ttm_memory.c
+++ b/drivers/gpu/drm/vmwgfx/ttm_memory.c
@@ -468,7 +468,6 @@ void ttm_mem_global_release(struct ttm_mem_global 
*glob)

struct ttm_mem_zone *zone;
unsigned int i;

-   flush_workqueue(glob->swap_queue);
destroy_workqueue(glob->swap_queue);
glob->swap_queue = NULL;
for (i = 0; i < glob->num_zones; ++i) {


Re: [PATCH v3 24/34] drm/tilcdc: Migrate to aggregate driver

2021-11-01 Thread Jyri Sarha

On 2021-10-26 3:00, Stephen Boyd wrote:

Use an aggregate driver instead of component ops so that we can get
proper driver probe ordering of the aggregate device with respect to 
all

the component devices that make up the aggregate device.

Cc: Jyri Sarha 
Cc: Tomi Valkeinen 
Cc: Daniel Vetter 
Cc: "Rafael J. Wysocki" 
Cc: Rob Clark 
Cc: Russell King 
Cc: Saravana Kannan 
Signed-off-by: Stephen Boyd 
---


Tested-by: Jyri Sarha 

Thanks,
Jyri


 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 6b03f89a98d4..d5c6567eec8d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -531,13 +531,16 @@ static const struct dev_pm_ops tilcdc_pm_ops = {
 /*
  * Platform driver:
  */
-static int tilcdc_bind(struct device *dev)
+static int tilcdc_bind(struct aggregate_device *adev)
 {
+   struct device *dev = adev->parent;
+
return tilcdc_init(&tilcdc_driver, dev);
 }

-static void tilcdc_unbind(struct device *dev)
+static void tilcdc_unbind(struct aggregate_device *adev)
 {
+   struct device *dev = adev->parent;
struct drm_device *ddev = dev_get_drvdata(dev);

/* Check if a subcomponent has already triggered the unloading. */
@@ -547,9 +550,13 @@ static void tilcdc_unbind(struct device *dev)
tilcdc_fini(dev_get_drvdata(dev));
 }

-static const struct component_master_ops tilcdc_comp_ops = {
-   .bind = tilcdc_bind,
-   .unbind = tilcdc_unbind,
+static struct aggregate_driver tilcdc_aggregate_driver = {
+   .probe = tilcdc_bind,
+   .remove = tilcdc_unbind,
+   .driver = {
+   .name = "tilcdc_drm",
+   .owner = THIS_MODULE,
+   },
 };

 static int tilcdc_pdev_probe(struct platform_device *pdev)
@@ -566,12 +573,9 @@ static int tilcdc_pdev_probe(struct 
platform_device *pdev)

ret = tilcdc_get_external_components(&pdev->dev, &match);
if (ret < 0)
return ret;
-   else if (ret == 0)
+   if (ret == 0)
return tilcdc_init(&tilcdc_driver, &pdev->dev);
-   else
-   return component_master_add_with_match(&pdev->dev,
-  &tilcdc_comp_ops,
-  match);
+   return component_aggregate_register(&pdev->dev,
&tilcdc_aggregate_driver, match);
 }

 static int tilcdc_pdev_remove(struct platform_device *pdev)
@@ -581,10 +585,10 @@ static int tilcdc_pdev_remove(struct
platform_device *pdev)
ret = tilcdc_get_external_components(&pdev->dev, NULL);
if (ret < 0)
return ret;
-   else if (ret == 0)
+   if (ret == 0)
tilcdc_fini(platform_get_drvdata(pdev));
else
-   component_master_del(&pdev->dev, &tilcdc_comp_ops);
+		component_aggregate_unregister(&pdev->dev, 
&tilcdc_aggregate_driver);


return 0;
 }


Re: [PATCH] MAINTAINERS: Update addresses for TI display drivers

2020-12-16 Thread Jyri Sarha

On 2020-12-16 9:59, Tomi Valkeinen wrote:

Update the maintainer email addresses for TI display drivers.

Signed-off-by: Tomi Valkeinen 


Acked-by: Jyri Sarha 


---
 MAINTAINERS | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 281de213ef47..c21471497a18 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5932,8 +5932,8 @@
F:  Documentation/devicetree/bindings/display/st,stm32-ltdc.yaml
 F: drivers/gpu/drm/stm

 DRM DRIVERS FOR TI KEYSTONE
-M: Jyri Sarha 
-M: Tomi Valkeinen 
+M: Jyri Sarha 
+M: Tomi Valkeinen 
 L: dri-devel@lists.freedesktop.org
 S: Maintained
 T: git git://anongit.freedesktop.org/drm/drm-misc
@@ -5943,15 +5943,15 @@
F:  Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
 F: drivers/gpu/drm/tidss/

 DRM DRIVERS FOR TI LCDC
-M: Jyri Sarha 
-R: Tomi Valkeinen 
+M: Jyri Sarha 
+R: Tomi Valkeinen 
 L: dri-devel@lists.freedesktop.org
 S: Maintained
 F: Documentation/devicetree/bindings/display/tilcdc/
 F: drivers/gpu/drm/tilcdc/

 DRM DRIVERS FOR TI OMAP
-M: Tomi Valkeinen 
+M: Tomi Valkeinen 
 L: dri-devel@lists.freedesktop.org
 S: Maintained
 F: Documentation/devicetree/bindings/display/ti/

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/tilcdc: add const to of_device_id

2021-12-16 Thread Jyri Sarha
Please fix the bellow error and I will review and merge this. But in 
future, please at least compile test you changes with relevant 
configurations or alldefconfig before sending them to upstream!


Best regards,
Jyri

On 2021-12-15 22:35, kernel test robot wrote:

Hi Xiang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v5.16-rc5 next-20211214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Xiang-wangx/drm-tilcdc-add-const-to-of_device_id/20211216-002326
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: arm-randconfig-c002-20211214
(https://download.01.org/0day-ci/archive/20211216/202112160411.snrselay-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross
-O ~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/0day-ci/linux/commit/5698eadb76d94a4fc5298f5bea88b839399ddef0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review
Xiang-wangx/drm-tilcdc-add-const-to-of_device_id/20211216-002326
git checkout 5698eadb76d94a4fc5298f5bea88b839399ddef0
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0
make.cross O=build_dir ARCH=arm SHELL=/bin/bash
drivers/gpu/drm/tilcdc/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

drivers/gpu/drm/tilcdc/tilcdc_drv.c:590:34: error: conflicting types 
for 'tilcdc_of_match'; have 'const struct of_device_id[]'

 590 | static const struct of_device_id tilcdc_of_match[] = {
 |  ^~~
   drivers/gpu/drm/tilcdc/tilcdc_drv.c:63:28: note: previous
declaration of 'tilcdc_of_match' with type 'struct of_device_id[]'
  63 | static struct of_device_id tilcdc_of_match[];
 |^~~
   drivers/gpu/drm/tilcdc/tilcdc_drv.c:63:28: error: array
'tilcdc_of_match' assumed to have one element [-Werror]
drivers/gpu/drm/tilcdc/tilcdc_drv.c:63:28: error: 'tilcdc_of_match' 
defined but not used [-Werror=unused-variable]

   cc1: all warnings being treated as errors


vim +590 drivers/gpu/drm/tilcdc/tilcdc_drv.c

   589
 > 590   static const struct of_device_id tilcdc_of_match[] = {
   591  { .compatible = "ti,am33xx-tilcdc", },
   592  { .compatible = "ti,da850-tilcdc", },
   593  { },
   594  };
   595  MODULE_DEVICE_TABLE(of, tilcdc_of_match);
   596

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


Re: [PATCH v2] drm/tilcdc: add const to of_device_id

2021-12-16 Thread Jyri Sarha

On 2021-12-16 11:44, Joe Perches wrote:

On Thu, 2021-12-16 at 17:26 +0800, Xiang wangx wrote:

struct of_device_id should normally be const.

[]
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c

[]
@@ -60,7 +60,7 @@ void tilcdc_module_cleanup(struct tilcdc_module 
*mod)

list_del(&mod->list);
 }

-static struct of_device_id tilcdc_of_match[];
+static const struct of_device_id tilcdc_of_match[];


This line could likely be removed instead.

$ git grep -w -n tilcdc_of_match
drivers/gpu/drm/tilcdc/tilcdc_drv.c:63:static struct of_device_id
tilcdc_of_match[];
drivers/gpu/drm/tilcdc/tilcdc_drv.c:590:static struct of_device_id
tilcdc_of_match[] = {
drivers/gpu/drm/tilcdc/tilcdc_drv.c:595:MODULE_DEVICE_TABLE(of,
tilcdc_of_match);
drivers/gpu/drm/tilcdc/tilcdc_drv.c:603:
.of_match_table = tilcdc_of_match,



Oh yes. It appears to have been there from day one and even then it was 
bogus.


Xiang Wang, could you produce one more version of the patch with the 
declaration removed.


Best regards,
Jyri

@@ -587,7 +587,7 @@ static int tilcdc_pdev_remove(struct 
platform_device *pdev)

return 0;
 }

-static struct of_device_id tilcdc_of_match[] = {
+static const struct of_device_id tilcdc_of_match[] = {
{ .compatible = "ti,am33xx-tilcdc", },
{ .compatible = "ti,da850-tilcdc", },
{ },


Re: [PATCH v3] drm/tilcdc: add const to of_device_id

2021-12-16 Thread Jyri Sarha

On 2021-12-16 11:55, Xiang wangx wrote:

struct of_device_id should normally be const.

Signed-off-by: Xiang wangx 


Reviewed-by: Jyri Sarha 

Thanks,
Jyri


---

Changes since v1
* add const in line 63

Changes since v2
* removed line 63

 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3ddb7c710a3d..cc567c87057d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -60,8 +60,6 @@ void tilcdc_module_cleanup(struct tilcdc_module *mod)
list_del(&mod->list);
 }

-static struct of_device_id tilcdc_of_match[];
-
 static int tilcdc_atomic_check(struct drm_device *dev,
   struct drm_atomic_state *state)
 {
@@ -587,7 +585,7 @@ static int tilcdc_pdev_remove(struct 
platform_device *pdev)

return 0;
 }

-static struct of_device_id tilcdc_of_match[] = {
+static const struct of_device_id tilcdc_of_match[] = {
{ .compatible = "ti,am33xx-tilcdc", },
{ .compatible = "ti,da850-tilcdc", },
{ },


Re: [PATCH v2 36/37] drm/tilcdc: Add support for the nomodeset kernel parameter

2021-12-17 Thread Jyri Sarha

On 2021-12-17 2:37, Javier Martinez Canillas wrote:
According to disable Documentation/admin-guide/kernel-parameters.txt, 
this

parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated 
rendering

and only the system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this 
driver

to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 


Acked-by: Jyri Sarha 


---

(no changes since v1)

 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index cc567c87057d..eee3c447fbac 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -604,6 +604,9 @@ static struct platform_driver 
tilcdc_platform_driver = {


 static int __init tilcdc_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
DBG("init");
tilcdc_panel_init();
return platform_driver_register(&tilcdc_platform_driver);


[PATCH 0/3] drm/i2c: tda998x ASoC hdmi-codec support + BeagleBoneBlack audio support

2016-08-02 Thread Jyri Sarha
These patches are just a rebase of the same patches from my "[PATCH
v4 0/7] Implement generic ASoC HDMI codec and use it in tda998x"
-patch series. I have only made updates required by efc9194bcff8
("ASoC: hdmi-codec: callback function will be called with private
data") -patch.

The first patch changes tda998x pdata, so if there are any out of tree
users of tda998x-driver the out of tree code needs to be updated.

Jyri Sarha (3):
  drm/i2c: tda998x: Improve tda998x_configure_audio() audio related
pdata
  drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding
  ARM: dts: am335x-boneblack: Add HDMI audio support

 .../devicetree/bindings/display/bridge/tda998x.txt |  18 ++
 arch/arm/boot/dts/am335x-boneblack.dts |  71 +-
 drivers/gpu/drm/i2c/Kconfig|   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c  | 276 ++---
 include/drm/i2c/tda998x.h  |  24 +-
 include/dt-bindings/display/tda998x.h  |   7 +
 6 files changed, 342 insertions(+), 55 deletions(-)
 create mode 100644 include/dt-bindings/display/tda998x.h

-- 
1.9.1



[PATCH 1/3] drm/i2c: tda998x: Improve tda998x_configure_audio() audio related pdata

2016-08-02 Thread Jyri Sarha
Define struct tda998x_audio_params in include/drm/i2c/tda998x.h and
use it in pdata and for tda998x_configure_audio() parameters. Also
updates tda998x_write_aif() to take struct hdmi_audio_infoframe *
directly as a parameter.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 77 ---
 include/drm/i2c/tda998x.h | 24 +++-
 2 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index f4315bc..f97b748 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -41,7 +41,7 @@ struct tda998x_priv {
u8 vip_cntrl_0;
u8 vip_cntrl_1;
u8 vip_cntrl_2;
-   struct tda998x_encoder_params params;
+   struct tda998x_audio_params audio_params;

wait_queue_head_t wq_edid;
volatile int wq_edid_wait;
@@ -666,26 +666,16 @@ tda998x_write_if(struct tda998x_priv *priv, u8 bit, u16 
addr,
reg_set(priv, REG_DIP_IF_FLAGS, bit);
 }

-static void
-tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p)
+static int tda998x_write_aif(struct tda998x_priv *priv,
+struct hdmi_audio_infoframe *cea)
 {
union hdmi_infoframe frame;

-   hdmi_audio_infoframe_init(&frame.audio);
-
-   frame.audio.channels = p->audio_frame[1] & 0x07;
-   frame.audio.channel_allocation = p->audio_frame[4];
-   frame.audio.level_shift_value = (p->audio_frame[5] & 0x78) >> 3;
-   frame.audio.downmix_inhibit = (p->audio_frame[5] & 0x80) >> 7;
-
-   /*
-* L-PCM and IEC61937 compressed audio shall always set sample
-* frequency to "refer to stream".  For others, see the HDMI
-* specification.
-*/
-   frame.audio.sample_frequency = (p->audio_frame[2] & 0x1c) >> 2;
+   frame.audio = *cea;

tda998x_write_if(priv, DIP_IF_FLAGS_IF4, REG_IF4_HB0, &frame);
+
+   return 0;
 }

 static void
@@ -710,20 +700,21 @@ static void tda998x_audio_mute(struct tda998x_priv *priv, 
bool on)
}
 }

-static void
+static int
 tda998x_configure_audio(struct tda998x_priv *priv,
-   struct drm_display_mode *mode, struct tda998x_encoder_params *p)
+   struct tda998x_audio_params *params,
+   unsigned mode_clock)
 {
u8 buf[6], clksel_aip, clksel_fs, cts_n, adiv;
u32 n;

/* Enable audio ports */
-   reg_write(priv, REG_ENA_AP, p->audio_cfg);
-   reg_write(priv, REG_ENA_ACLK, p->audio_clk_cfg);
+   reg_write(priv, REG_ENA_AP, params->config);

/* Set audio input source */
-   switch (p->audio_format) {
+   switch (params->format) {
case AFMT_SPDIF:
+   reg_write(priv, REG_ENA_ACLK, 0);
reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_SPDIF);
clksel_aip = AIP_CLKSEL_AIP_SPDIF;
clksel_fs = AIP_CLKSEL_FS_FS64SPDIF;
@@ -731,15 +722,29 @@ tda998x_configure_audio(struct tda998x_priv *priv,
break;

case AFMT_I2S:
+   reg_write(priv, REG_ENA_ACLK, 1);
reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_I2S);
clksel_aip = AIP_CLKSEL_AIP_I2S;
clksel_fs = AIP_CLKSEL_FS_ACLK;
-   cts_n = CTS_N_M(3) | CTS_N_K(3);
+   switch (params->sample_width) {
+   case 16:
+   cts_n = CTS_N_M(3) | CTS_N_K(1);
+   break;
+   case 18:
+   case 20:
+   case 24:
+   cts_n = CTS_N_M(3) | CTS_N_K(2);
+   break;
+   default:
+   case 32:
+   cts_n = CTS_N_M(3) | CTS_N_K(3);
+   break;
+   }
break;

default:
BUG();
-   return;
+   return -EINVAL;
}

reg_write(priv, REG_AIP_CLKSEL, clksel_aip);
@@ -755,11 +760,11 @@ tda998x_configure_audio(struct tda998x_priv *priv,
 * assume 100MHz requires larger divider.
 */
adiv = AUDIO_DIV_SERCLK_8;
-   if (mode->clock > 10)
+   if (mode_clock > 10)
adiv++; /* AUDIO_DIV_SERCLK_16 */

/* S/PDIF asks for a larger divider */
-   if (p->audio_format == AFMT_SPDIF)
+   if (params->format == AFMT_SPDIF)
adiv++; /* AUDIO_DIV_SERCLK_16 or _32 */

reg_write(priv, REG_AUDIO_DIV, adiv);
@@ -768,7 +773,7 @@ tda998x_configure_audio(struct tda998x_priv *priv,
 * This is the approximate value of N, which happens to be
 * the recommended values for non-coherent clocks.
 */
-   n = 128 * p->audio_sample_rate / 1000;
+   n = 128 * params-&

[PATCH 3/3] ARM: dts: am335x-boneblack: Add HDMI audio support

2016-08-02 Thread Jyri Sarha
Add HDMI audio support. Adds mcasp0_pins, clk_mcasp0_fixed,
clk_mcasp0, mcasp0, sound node, and updates the tda19988 node to
follow the new binding.

Signed-off-by: Jyri Sarha 
---
 arch/arm/boot/dts/am335x-boneblack.dts | 71 --
 1 file changed, 67 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/am335x-boneblack.dts 
b/arch/arm/boot/dts/am335x-boneblack.dts
index 55c0e95..2bae4d1 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -9,6 +9,7 @@

 #include "am33xx.dtsi"
 #include "am335x-bone-common.dtsi"
+#include 

 / {
model = "TI AM335x BeagleBone Black";
@@ -64,6 +65,16 @@
AM33XX_IOPAD(0x9b0, PIN_OUTPUT_PULLDOWN | MUX_MODE3)
/* xdma_event_intr0 */
>;
};
+
+   mcasp0_pins: mcasp0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x9ac, PIN_INPUT_PULLUP | MUX_MODE0) /* 
mcasp0_ahcklx.mcasp0_ahclkx */
+   AM33XX_IOPAD(0x99c, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* 
mcasp0_ahclkr.mcasp0_axr2*/
+   AM33XX_IOPAD(0x994, PIN_OUTPUT_PULLUP | MUX_MODE0) /* 
mcasp0_fsx.mcasp0_fsx */
+   AM33XX_IOPAD(0x990, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* 
mcasp0_aclkx.mcasp0_aclkx */
+   AM33XX_IOPAD(0x86c, PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* 
gpmc_a11.GPIO1_27 */
+   >;
+   };
 };

 &lcdc {
@@ -76,16 +87,22 @@
 };

 &i2c0 {
-   tda19988 {
+   tda19988: tda19988 {
compatible = "nxp,tda998x";
reg = <0x70>;
+
pinctrl-names = "default", "off";
pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;

-   port {
-   hdmi_0: endpoint at 0 {
-   remote-endpoint = <&lcdc_0>;
+   #sound-dai-cells = <0>;
+   audio-ports = < AFMT_I2S0x03>;
+
+   ports {
+   port at 0 {
+   hdmi_0: endpoint at 0 {
+   remote-endpoint = <&lcdc_0>;
+   };
};
};
};
@@ -94,3 +111,49 @@
 &rtc {
system-power-controller;
 };
+
+&mcasp0{
+   #sound-dai-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&mcasp0_pins>;
+   status = "okay";
+   op-mode = <0>;  /* MCASP_IIS_MODE */
+   tdm-slots = <2>;
+   serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
+   0 0 1 0
+   >;
+   tx-num-evt = <32>;
+   rx-num-evt = <32>;
+};
+
+/ {
+   clk_mcasp0_fixed: clk_mcasp0_fixed {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <24576000>;
+   };
+
+   clk_mcasp0: clk_mcasp0 {
+   #clock-cells = <0>;
+   compatible = "gpio-gate-clock";
+   clocks = <&clk_mcasp0_fixed>;
+   enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on 
GPIO1_27 */
+   };
+
+   sound {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "TI BeagleBone Black";
+   simple-audio-card,format = "i2s";
+   simple-audio-card,bitclock-master = <&dailink0_master>;
+   simple-audio-card,frame-master = <&dailink0_master>;
+
+   dailink0_master: simple-audio-card,cpu {
+   sound-dai = <&mcasp0>;
+   clocks = <&clk_mcasp0>;
+   };
+
+   simple-audio-card,codec {
+   sound-dai = <&tda19988>;
+   };
+   };
+};
-- 
1.9.1



[PATCH 2/3] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-08-02 Thread Jyri Sarha
Register ASoC HDMI codec for audio functionality and adds device tree
binding for audio configuration.

With the registered HDMI codec the tda998x node can be used like a
regular codec node in ASoC card configurations. HDMI audio info-frame
and audio stream header is generated by the ASoC HDMI codec. The codec
also applies constraints for available sample-rates based on Edid Like
Data from the display. The device tree binding document has been
updated [1].

Part of this patch has been inspired by Jean Francoise's "drm/i2c: tda998x:
Add support of a DT graph of ports"-patch [2]. There may still be some
identical lines left from the original patch and some of the ideas
have come from there.

[1] Documentation/devicetree/bindings/display/bridge/tda998x.txt
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2015-July/095255.html

Signed-off-by: Jyri Sarha 
---
 .../devicetree/bindings/display/bridge/tda998x.txt |  18 ++
 drivers/gpu/drm/i2c/Kconfig|   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c  | 199 -
 include/drm/i2c/tda998x.h  |   4 +-
 include/dt-bindings/display/tda998x.h  |   7 +
 5 files changed, 224 insertions(+), 5 deletions(-)
 create mode 100644 include/dt-bindings/display/tda998x.h

diff --git a/Documentation/devicetree/bindings/display/bridge/tda998x.txt 
b/Documentation/devicetree/bindings/display/bridge/tda998x.txt
index e178e6b..24cc246 100644
--- a/Documentation/devicetree/bindings/display/bridge/tda998x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/tda998x.txt
@@ -21,8 +21,19 @@ Optional properties:
   - video-ports: 24 bits value which defines how the video controller
output is wired to the TDA998x input - default: <0x230145>

+  - audio-ports: array of 8-bit values, 2 values per one DAI[1].
+   The first value defines the DAI type: TDA998x_SPDIF or TDA998x_I2S[2].
+   The second value defines the tda998x AP_ENA reg content when the DAI
+   in question is used. The implementation allows one or two DAIs. If two
+   DAIs are defined, they must be of different type.
+
+[1] Documentation/sound/alsa/soc/DAI.txt
+[2] include/dt-bindings/display/tda998x.h
+
 Example:

+#include 
+
tda998x: hdmi-encoder {
compatible = "nxp,tda998x";
reg = <0x70>;
@@ -30,4 +41,11 @@ Example:
interrupts = <27 2>;/* falling edge */
pinctrl-0 = <&pmx_camera>;
pinctrl-names = "default";
+   video-ports = <0x230145>;
+
+   #sound-dai-cells = <2>;
+/* DAI-format  AP_ENA reg value */
+   audio-ports = < TDA998x_SPDIF   0x04
+   TDA998x_I2S 0x03>;
+
};
diff --git a/drivers/gpu/drm/i2c/Kconfig b/drivers/gpu/drm/i2c/Kconfig
index 4d341db..a6c92be 100644
--- a/drivers/gpu/drm/i2c/Kconfig
+++ b/drivers/gpu/drm/i2c/Kconfig
@@ -22,6 +22,7 @@ config DRM_I2C_SIL164
 config DRM_I2C_NXP_TDA998X
tristate "NXP Semiconductors TDA998X HDMI encoder"
default m if DRM_TILCDC
+   select SND_SOC_HDMI_CODEC if SND_SOC
help
  Support for NXP Semiconductors TDA998X HDMI encoders.

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index f97b748..bd720cc 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -30,6 +31,11 @@

 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)

+struct tda998x_audio_port {
+   u8 format;  /* AFMT_xxx */
+   u8 config;  /* AP value */
+};
+
 struct tda998x_priv {
struct i2c_client *cec;
struct i2c_client *hdmi;
@@ -43,6 +49,8 @@ struct tda998x_priv {
u8 vip_cntrl_2;
struct tda998x_audio_params audio_params;

+   struct platform_device *audio_pdev;
+
wait_queue_head_t wq_edid;
volatile int wq_edid_wait;

@@ -53,6 +61,8 @@ struct tda998x_priv {

struct drm_encoder encoder;
struct drm_connector connector;
+
+   struct tda998x_audio_port audio_port[2];
 };

 #define conn_to_tda998x_priv(x) \
@@ -743,7 +753,7 @@ tda998x_configure_audio(struct tda998x_priv *priv,
break;

default:
-   BUG();
+   dev_err(&priv->hdmi->dev, "Unsupported I2S format\n");
return -EINVAL;
}

@@ -1160,6 +1170,8 @@ 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);
+   drm_edid_to_eld(connector, edid);
+
kfree(e

[PATCH 1/3] drm/i2c: tda998x: Improve tda998x_configure_audio() audio related pdata

2016-08-05 Thread Jyri Sarha
On 08/04/16 16:31, Russell King - ARM Linux wrote:
> On Tue, Aug 02, 2016 at 03:05:07PM +0300, Jyri Sarha wrote:
>> @@ -787,19 +792,13 @@ tda998x_configure_audio(struct tda998x_priv *priv,
>>  reg_clear(priv, REG_AIP_CNTRL_0, AIP_CNTRL_0_RST_CTS);
>>  
>>  /* Write the channel status */
>> -buf[0] = IEC958_AES0_CON_NOT_COPYRIGHT;
>> -buf[1] = 0x00;
>> -buf[2] = IEC958_AES3_CON_FS_NOTID;
>> -buf[3] = IEC958_AES4_CON_ORIGFS_NOTID |
>> -IEC958_AES4_CON_MAX_WORDLEN_24;
>> -reg_write_range(priv, REG_CH_STAT_B(0), buf, 4);
>> +reg_write_range(priv, REG_CH_STAT_B(0), params->status, 4);
> 
> Take a close look at the code you are replacing here - the buffer
> contents is not AES bytes 0, 1, 2, 3, 4, but AES bytes 0, 1, 3, 4
> - byte 2 is not present in this array.  I don't think you've noticed
> this as your second patch merely copies verboten the IEC status:
> 
> +   memcpy(audio.status, params->iec.status,
> +  min(sizeof(audio.status), sizeof(params->iec.status)));
> 
> assuming that it is bytes 0-3.  Byte 2 is stored separately for each
> I2S channel in the following registers.
> 

Oh, yes. I missed that. I think it would be better to increase
tda998x_audio_params status buffer length by one and keep it otherwise
as it is. Then just write the bytes 0-1 and 3-4 separately into channel
status registers, with appropriate comments. I guess the the AES byte 2
can remain 0 for now (source and channel unspecified, with assumption of
consumer stream).

>> diff --git a/include/drm/i2c/tda998x.h b/include/drm/i2c/tda998x.h
>> index 3e419d9..24be7aa 100644
>> --- a/include/drm/i2c/tda998x.h
>> +++ b/include/drm/i2c/tda998x.h
>> @@ -1,6 +1,19 @@
>>  #ifndef __DRM_I2C_TDA998X_H__
>>  #define __DRM_I2C_TDA998X_H__
>>  
>> +#define AFMT_UNUSED 0
>> +#define AFMT_SPDIF  1
>> +#define AFMT_I2S2
> 
> I'd prefer this to stay an enum please.
> 

Ok.

>> +struct tda998x_audio_params {
>> +u8 config;
>> +u8 format;
>> +unsigned sample_width;
>> +unsigned sample_rate;
>> +struct hdmi_audio_infoframe cea;
> 
> With this addition, this file will need to include linux/hdmi.h.
> 

Oh yes, thanks.

>> +u8 status[4];
> 
> A comment here about the missing byte 2 would probably be a good idea.
> 

As I said earlier, I'd rather keep this as plain channel status buffer
and just increase its size by one.

Thanks a lot for the review!

Best reagards,
Jyri


[PATCH 2/3] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-08-05 Thread Jyri Sarha
On 08/04/16 17:07, Russell King - ARM Linux wrote:
> On Tue, Aug 02, 2016 at 03:05:08PM +0300, Jyri Sarha wrote:
>> +memcpy(audio.status, params->iec.status,
>> +   min(sizeof(audio.status), sizeof(params->iec.status)));
> 
> As mentioned in the other patch, the audio status does not directly
> correspond with the AES bytes, so this ends up causing the driver to
> write the wrong bytes to the wrong registers.
> 

As I said earlier, I'd rather have it as plain AES/IEC958 channel status
bits buffer.

>> +ret = tda998x_configure_audio(priv,
>> +  &audio,
>> +  priv->encoder.crtc->hwmode.clock);
> 
> What happens if audio changes at the same time that the video mode
> changes?  What protection is there against two threads concurrently
> executing tda998x_configure_audio() ?
> 

Oh, yes. I definitely need some locking here. The same lock could
protect the atomicity of tda998x_audio_params update and usage.

>> +priv->audio_pdev = platform_device_register_data(
>> +dev, HDMI_CODEC_DRV_NAME, PLATFORM_DEVID_AUTO,
>> +&codec_data, sizeof(codec_data));
> 
> I'd much prefer that this was a child of the I2C device, which will
> show the relationship between this virtual platform device and the
> device which it's associated with.  That can be done via
> platform_device_register_full().
> 

That may be a problem. The ASoC card device tree binding current looks
for the ASoC DAI's parent's of-node if it can not find the node for the
DAI-device itself. Indicating ASoC DAI-link by referencing the parent
i2c device simply won't work, because there may be other ASoC codecs on
the same i2c bus. Adding a separate DT-node for a virtual audio device
should be possible, but it needs some thinking and may have its own
problems. I can not follow the reasoning behind this, is this really
necessary?

Best regards,
Jyri


[PATCH 2/3] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-08-08 Thread Jyri Sarha
On 08/06/16 01:19, Russell King - ARM Linux wrote:
>> > It'll pick up that as the DT device to hang things off which I'd expect
>> > to be the desired outcome given that this is a very similar situation to
>> > the MFD situation.  I've not been following the full thread so there is
>> > probably context I'm missing here...
> Okay, and that sounds to me like a very reasonable thing to want to
> happen - so that the audio side can be clearly identified as being
> coupled with the video side.
> 
> So, I'm not seeing a problem with my suggestion... I'm actually more
> reasons why it's a good thing to want.


Ok, so getting back to this comment:

>> +priv->audio_pdev = platform_device_register_data(
>> > +  dev, HDMI_CODEC_DRV_NAME, PLATFORM_DEVID_AUTO,
>> > +  &codec_data, sizeof(codec_data));
> I'd much prefer that this was a child of the I2C device, which will
> show the relationship between this virtual platform device and the
> device which it's associated with.  That can be done via
> platform_device_register_full().

The platform_device_register_data() sets the parent of the registered
platform device according to the first parameter, the tda998x i2c-client
in this case. Is there some reason why I should use
platform_device_register_full() and should I set parent to something
else than the tda998x i2c device?

BR,
Jyri


[PATCH v2 1/3] drm/i2c: tda998x: Improve tda998x_configure_audio() audio related pdata

2016-08-09 Thread Jyri Sarha
Define struct tda998x_audio_params in include/drm/i2c/tda998x.h and
use it in pdata and for tda998x_configure_audio() parameters. Also
updates tda998x_write_aif() to take struct hdmi_audio_infoframe *
directly as a parameter.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/i2c/tda998x_drv.c | 84 +--
 include/drm/i2c/tda998x.h | 28 -
 2 files changed, 64 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index f4315bc..f7c414a7 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -41,7 +41,7 @@ struct tda998x_priv {
u8 vip_cntrl_0;
u8 vip_cntrl_1;
u8 vip_cntrl_2;
-   struct tda998x_encoder_params params;
+   struct tda998x_audio_params audio_params;

wait_queue_head_t wq_edid;
volatile int wq_edid_wait;
@@ -666,26 +666,16 @@ tda998x_write_if(struct tda998x_priv *priv, u8 bit, u16 
addr,
reg_set(priv, REG_DIP_IF_FLAGS, bit);
 }

-static void
-tda998x_write_aif(struct tda998x_priv *priv, struct tda998x_encoder_params *p)
+static int tda998x_write_aif(struct tda998x_priv *priv,
+struct hdmi_audio_infoframe *cea)
 {
union hdmi_infoframe frame;

-   hdmi_audio_infoframe_init(&frame.audio);
-
-   frame.audio.channels = p->audio_frame[1] & 0x07;
-   frame.audio.channel_allocation = p->audio_frame[4];
-   frame.audio.level_shift_value = (p->audio_frame[5] & 0x78) >> 3;
-   frame.audio.downmix_inhibit = (p->audio_frame[5] & 0x80) >> 7;
-
-   /*
-* L-PCM and IEC61937 compressed audio shall always set sample
-* frequency to "refer to stream".  For others, see the HDMI
-* specification.
-*/
-   frame.audio.sample_frequency = (p->audio_frame[2] & 0x1c) >> 2;
+   frame.audio = *cea;

tda998x_write_if(priv, DIP_IF_FLAGS_IF4, REG_IF4_HB0, &frame);
+
+   return 0;
 }

 static void
@@ -710,20 +700,21 @@ static void tda998x_audio_mute(struct tda998x_priv *priv, 
bool on)
}
 }

-static void
+static int
 tda998x_configure_audio(struct tda998x_priv *priv,
-   struct drm_display_mode *mode, struct tda998x_encoder_params *p)
+   struct tda998x_audio_params *params,
+   unsigned mode_clock)
 {
u8 buf[6], clksel_aip, clksel_fs, cts_n, adiv;
u32 n;

/* Enable audio ports */
-   reg_write(priv, REG_ENA_AP, p->audio_cfg);
-   reg_write(priv, REG_ENA_ACLK, p->audio_clk_cfg);
+   reg_write(priv, REG_ENA_AP, params->config);

/* Set audio input source */
-   switch (p->audio_format) {
+   switch (params->format) {
case AFMT_SPDIF:
+   reg_write(priv, REG_ENA_ACLK, 0);
reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_SPDIF);
clksel_aip = AIP_CLKSEL_AIP_SPDIF;
clksel_fs = AIP_CLKSEL_FS_FS64SPDIF;
@@ -731,15 +722,29 @@ tda998x_configure_audio(struct tda998x_priv *priv,
break;

case AFMT_I2S:
+   reg_write(priv, REG_ENA_ACLK, 1);
reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_I2S);
clksel_aip = AIP_CLKSEL_AIP_I2S;
clksel_fs = AIP_CLKSEL_FS_ACLK;
-   cts_n = CTS_N_M(3) | CTS_N_K(3);
+   switch (params->sample_width) {
+   case 16:
+   cts_n = CTS_N_M(3) | CTS_N_K(1);
+   break;
+   case 18:
+   case 20:
+   case 24:
+   cts_n = CTS_N_M(3) | CTS_N_K(2);
+   break;
+   default:
+   case 32:
+   cts_n = CTS_N_M(3) | CTS_N_K(3);
+   break;
+   }
break;

default:
BUG();
-   return;
+   return -EINVAL;
}

reg_write(priv, REG_AIP_CLKSEL, clksel_aip);
@@ -755,11 +760,11 @@ tda998x_configure_audio(struct tda998x_priv *priv,
 * assume 100MHz requires larger divider.
 */
adiv = AUDIO_DIV_SERCLK_8;
-   if (mode->clock > 10)
+   if (mode_clock > 10)
adiv++; /* AUDIO_DIV_SERCLK_16 */

/* S/PDIF asks for a larger divider */
-   if (p->audio_format == AFMT_SPDIF)
+   if (params->format == AFMT_SPDIF)
adiv++; /* AUDIO_DIV_SERCLK_16 or _32 */

reg_write(priv, REG_AUDIO_DIV, adiv);
@@ -768,7 +773,7 @@ tda998x_configure_audio(struct tda998x_priv *priv,
 * This is the approximate value of N, which happens to be
 * the recommended values for non-coherent clocks.
 */
-   n = 128 * p->audio_sample_rate / 1000;
+   n = 128 * params-&

[PATCH v2 3/3] ARM: dts: am335x-boneblack: Add HDMI audio support

2016-08-09 Thread Jyri Sarha
Add HDMI audio support. Adds mcasp0_pins, clk_mcasp0_fixed,
clk_mcasp0, mcasp0, sound node, and updates the tda19988 node to
follow the new binding.

Signed-off-by: Jyri Sarha 
---
 arch/arm/boot/dts/am335x-boneblack.dts | 71 --
 1 file changed, 67 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/am335x-boneblack.dts 
b/arch/arm/boot/dts/am335x-boneblack.dts
index ca72167..528559b 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -9,6 +9,7 @@

 #include "am33xx.dtsi"
 #include "am335x-bone-common.dtsi"
+#include 

 / {
model = "TI AM335x BeagleBone Black";
@@ -75,6 +76,16 @@
AM33XX_IOPAD(0x9b0, PIN_OUTPUT_PULLDOWN | MUX_MODE3)
/* xdma_event_intr0 */
>;
};
+
+   mcasp0_pins: mcasp0_pins {
+   pinctrl-single,pins = <
+   AM33XX_IOPAD(0x9ac, PIN_INPUT_PULLUP | MUX_MODE0) /* 
mcasp0_ahcklx.mcasp0_ahclkx */
+   AM33XX_IOPAD(0x99c, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* 
mcasp0_ahclkr.mcasp0_axr2*/
+   AM33XX_IOPAD(0x994, PIN_OUTPUT_PULLUP | MUX_MODE0) /* 
mcasp0_fsx.mcasp0_fsx */
+   AM33XX_IOPAD(0x990, PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* 
mcasp0_aclkx.mcasp0_aclkx */
+   AM33XX_IOPAD(0x86c, PIN_OUTPUT_PULLDOWN | MUX_MODE7) /* 
gpmc_a11.GPIO1_27 */
+   >;
+   };
 };

 &lcdc {
@@ -87,16 +98,22 @@
 };

 &i2c0 {
-   tda19988 {
+   tda19988: tda19988 {
compatible = "nxp,tda998x";
reg = <0x70>;
+
pinctrl-names = "default", "off";
pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;

-   port {
-   hdmi_0: endpoint at 0 {
-   remote-endpoint = <&lcdc_0>;
+   #sound-dai-cells = <0>;
+   audio-ports = < TDA998x_I2S 0x03>;
+
+   ports {
+   port at 0 {
+   hdmi_0: endpoint at 0 {
+   remote-endpoint = <&lcdc_0>;
+   };
};
};
};
@@ -105,3 +122,49 @@
 &rtc {
system-power-controller;
 };
+
+&mcasp0{
+   #sound-dai-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&mcasp0_pins>;
+   status = "okay";
+   op-mode = <0>;  /* MCASP_IIS_MODE */
+   tdm-slots = <2>;
+   serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
+   0 0 1 0
+   >;
+   tx-num-evt = <32>;
+   rx-num-evt = <32>;
+};
+
+/ {
+   clk_mcasp0_fixed: clk_mcasp0_fixed {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <24576000>;
+   };
+
+   clk_mcasp0: clk_mcasp0 {
+   #clock-cells = <0>;
+   compatible = "gpio-gate-clock";
+   clocks = <&clk_mcasp0_fixed>;
+   enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on 
GPIO1_27 */
+   };
+
+   sound {
+   compatible = "simple-audio-card";
+   simple-audio-card,name = "TI BeagleBone Black";
+   simple-audio-card,format = "i2s";
+   simple-audio-card,bitclock-master = <&dailink0_master>;
+   simple-audio-card,frame-master = <&dailink0_master>;
+
+   dailink0_master: simple-audio-card,cpu {
+   sound-dai = <&mcasp0>;
+   clocks = <&clk_mcasp0>;
+   };
+
+   simple-audio-card,codec {
+   sound-dai = <&tda19988>;
+   };
+   };
+};
-- 
1.9.1



[PATCH v2 2/3] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-08-09 Thread Jyri Sarha
Register ASoC HDMI codec for audio functionality and adds device tree
binding for audio configuration.

With the registered HDMI codec the tda998x node can be used like a
regular codec node in ASoC card configurations. HDMI audio info-frame
and audio stream header is generated by the ASoC HDMI codec. The codec
also applies constraints for available sample-rates based on Edid Like
Data from the display. The device tree binding document has been
updated [1].

Part of this patch has been inspired by Jean Francoise's "drm/i2c: tda998x:
Add support of a DT graph of ports"-patch [2]. There may still be some
identical lines left from the original patch and some of the ideas
have come from there.

[1] Documentation/devicetree/bindings/display/bridge/tda998x.txt
[2] http://mailman.alsa-project.org/pipermail/alsa-devel/2015-July/095255.html

Signed-off-by: Jyri Sarha 
---
 .../devicetree/bindings/display/bridge/tda998x.txt |  18 ++
 drivers/gpu/drm/i2c/Kconfig|   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c  | 213 -
 include/drm/i2c/tda998x.h  |   5 +-
 include/dt-bindings/display/tda998x.h  |   7 +
 5 files changed, 239 insertions(+), 5 deletions(-)
 create mode 100644 include/dt-bindings/display/tda998x.h

diff --git a/Documentation/devicetree/bindings/display/bridge/tda998x.txt 
b/Documentation/devicetree/bindings/display/bridge/tda998x.txt
index e178e6b..24cc246 100644
--- a/Documentation/devicetree/bindings/display/bridge/tda998x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/tda998x.txt
@@ -21,8 +21,19 @@ Optional properties:
   - video-ports: 24 bits value which defines how the video controller
output is wired to the TDA998x input - default: <0x230145>

+  - audio-ports: array of 8-bit values, 2 values per one DAI[1].
+   The first value defines the DAI type: TDA998x_SPDIF or TDA998x_I2S[2].
+   The second value defines the tda998x AP_ENA reg content when the DAI
+   in question is used. The implementation allows one or two DAIs. If two
+   DAIs are defined, they must be of different type.
+
+[1] Documentation/sound/alsa/soc/DAI.txt
+[2] include/dt-bindings/display/tda998x.h
+
 Example:

+#include 
+
tda998x: hdmi-encoder {
compatible = "nxp,tda998x";
reg = <0x70>;
@@ -30,4 +41,11 @@ Example:
interrupts = <27 2>;/* falling edge */
pinctrl-0 = <&pmx_camera>;
pinctrl-names = "default";
+   video-ports = <0x230145>;
+
+   #sound-dai-cells = <2>;
+/* DAI-format  AP_ENA reg value */
+   audio-ports = < TDA998x_SPDIF   0x04
+   TDA998x_I2S 0x03>;
+
};
diff --git a/drivers/gpu/drm/i2c/Kconfig b/drivers/gpu/drm/i2c/Kconfig
index 4d341db..a6c92be 100644
--- a/drivers/gpu/drm/i2c/Kconfig
+++ b/drivers/gpu/drm/i2c/Kconfig
@@ -22,6 +22,7 @@ config DRM_I2C_SIL164
 config DRM_I2C_NXP_TDA998X
tristate "NXP Semiconductors TDA998X HDMI encoder"
default m if DRM_TILCDC
+   select SND_SOC_HDMI_CODEC if SND_SOC
help
  Support for NXP Semiconductors TDA998X HDMI encoders.

diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
b/drivers/gpu/drm/i2c/tda998x_drv.c
index f7c414a7..46c0574 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -30,6 +31,11 @@

 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)

+struct tda998x_audio_port {
+   u8 format;  /* AFMT_xxx */
+   u8 config;  /* AP value */
+};
+
 struct tda998x_priv {
struct i2c_client *cec;
struct i2c_client *hdmi;
@@ -43,6 +49,9 @@ struct tda998x_priv {
u8 vip_cntrl_2;
struct tda998x_audio_params audio_params;

+   struct platform_device *audio_pdev;
+   struct mutex audio_mutex;
+
wait_queue_head_t wq_edid;
volatile int wq_edid_wait;

@@ -53,6 +62,8 @@ struct tda998x_priv {

struct drm_encoder encoder;
struct drm_connector connector;
+
+   struct tda998x_audio_port audio_port[2];
 };

 #define conn_to_tda998x_priv(x) \
@@ -743,7 +754,7 @@ tda998x_configure_audio(struct tda998x_priv *priv,
break;

default:
-   BUG();
+   dev_err(&priv->hdmi->dev, "Unsupported I2S format\n");
return -EINVAL;
}

@@ -1064,9 +1075,11 @@ tda998x_encoder_mode_set(struct drm_encoder *encoder,
tda998x_write_avi(priv, adjusted_mode);

if (priv->audio_params.format != AFMT_UNUSED) {
+   mutex_lock(&priv->audi

[PATCH v2 0/3] drm/i2c: tda998x ASoC hdmi-codec support + BeagleBoneBlack audio support

2016-08-09 Thread Jyri Sarha
Changes since first version [1] of this series:
- "drm/i2c: tda998x: Improve tda998x_configure_audio() audio related pdata"
  - Change audio in tda998x pdata to audio_params to match the naming in
private data struct
  - Skip IEC958_AES2 byte when writing status bytes to registers 
  - Turn AFMT-macros to enum
  - include linux/hdmi.h in drm/i2c/tda998x.h
- "drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding"
  - Fix macronaming naming in dt-bindings/display/tda998x.h
  - Turn AFMT-macros to enum
  - Add locking to protect access to audio registers from ASoC thread
- "dts/am335x-boneblack: SQUASH"
  - Use corrected macros from dt-bindings/display/tda998x.h

[1] https://lists.freedesktop.org/archives/dri-devel/2016-August/114491.html 

Jyri Sarha (3):
  drm/i2c: tda998x: Improve tda998x_configure_audio() audio related
pdata
  drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding
  ARM: dts: am335x-boneblack: Add HDMI audio support

 .../devicetree/bindings/display/bridge/tda998x.txt |  18 ++
 arch/arm/boot/dts/am335x-boneblack.dts |  71 -
 drivers/gpu/drm/i2c/Kconfig|   1 +
 drivers/gpu/drm/i2c/tda998x_drv.c  | 297 ++---
 include/drm/i2c/tda998x.h  |  29 +-
 include/dt-bindings/display/tda998x.h  |   7 +
 6 files changed, 368 insertions(+), 55 deletions(-)
 create mode 100644 include/dt-bindings/display/tda998x.h

-- 
1.9.1



[GIT PULL] drm/tilcdc atomic modeset support and some non critical fixes

2016-08-09 Thread Jyri Sarha
Hi Dave,
Please pull tilcdc atomic modeset support and some non critical fixes.

The patches were under review [1] and there were no comments any
more to the v2 series. Code has been rebased and tested on top of
latest drm-next and the only change needed was to adapt to the
drm_atomic_helper_swap_state() parameter change.

[1] https://lists.freedesktop.org/archives/dri-devel/2016-June/112071.html

The following changes since commit 5c6c201ccbaf9d3901f829441d457293f7ca8ef4:

  drm: Paper over locking inversion after registration rework
(2016-08-08 16:08:25 +1000)

are available in the git repository at:

  https://github.com/jsarha/linux drm-next-tilcdc-atomic

for you to fetch changes up to e0e344e620b11b76376027087574f8ae1c7807fd:

  drm/tilcdc: Change tilcdc_crtc_page_flip() to tilcdc_crtc_update_fb()
(2016-08-08 23:05:19 +0300)


Jyri Sarha (29):
  drm/tilcdc: Restore old dpms state in pm_resume()
  drm/tilcdc: Move LCDC_SYNC_LOST handling inside if (ver == 2)
statement
  drm/tilcdc: Write to LCDC_END_OF_INT_IND_REG at the end of IRQ
function
  drm/tilcdc: Move waiting of LCDC_FRAME_DONE IRQ into stop()
  drm/tilcdc: Increase time out for waiting frame done interrupt
  drm/tilcdc: Call drm_crtc_vblank_on() and *_off() in start() and
stop()
  drm/tilcdc: Refer to panel.txt and tfp410.txt bindings in tilcdc.txt
  drm/tilcdc: Avoid error print by of_graph_get_next_endpoint()
  drm/tilcdc: Fix tilcdc component master unloading
  drm/tilcdc: Make tilcdc_crtc_page_flip() public
  drm/tilcdc: Make tilcdc_crtc_page_flip() work if crtc is not yet on
  drm/tilcdc: Add dummy primary plane implementation
  drm/tilcdc: Initialize dummy primary plane from crtc init
  drm/tilcdc: Add tilcdc_crtc_mode_set_nofb()
  drm/tilcdc: Add tilcdc_crtc_atomic_check()
  drm/tilcdc: Add atomic mode config funcs
  drm/tilcdc: Add drm_mode_config_reset() call to tilcdc_load()
  drm/tilcdc: Set DRIVER_ATOMIC and use atomic crtc helpers
  drm/tilcdc: Remove obsolete crtc helper functions
  drm/tilcdc: Remove tilcdc_verify_fb()
  drm/tilcdc: panel: Set crtc panel info at init phase
  drm/tilcdc: panel: Add atomic modeset helpers to connector funcs
  drm/tilcdc: tfp410: Set crtc panel info at init phase
  drm/tilcdc: tfp410: Add atomic modeset helpers to connector funcs
  drm/tilcdc: Enable and disable interrupts in crtc start() and stop()
  drm/tilcdc: Use drm_atomic_helper_resume/suspend()
  drm/tilcdc: Get rid of legacy dpms mechanism
  drm/tilcdc: Remove unnecessary pm_runtime_get() and *_put() calls
  drm/tilcdc: Change tilcdc_crtc_page_flip() to tilcdc_crtc_update_fb()

 .../devicetree/bindings/display/tilcdc/tilcdc.txt  |   4 +
 drivers/gpu/drm/tilcdc/Makefile|   1 +
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c   | 375
+++--
 drivers/gpu/drm/tilcdc/tilcdc_drv.c| 207 ++--
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|  12 +-
 drivers/gpu/drm/tilcdc/tilcdc_external.c   |  13 +-
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |  11 +-
 drivers/gpu/drm/tilcdc/tilcdc_plane.c  | 132 
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c |   8 +-
 9 files changed, 465 insertions(+), 298 deletions(-)
 create mode 100644 drivers/gpu/drm/tilcdc/tilcdc_plane.c


-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160809/61421dc5/attachment.sig>


[PATCH] drm: tilcdc: Fix check for remote port parent

2016-08-15 Thread Jyri Sarha
On 08/15/16 11:16, Teresa Remmet wrote:
> In function tilcdc_get_external_components the check for
> the remote port parent is not correct. We need a '||' instead of
> an '&&'.
> 
> Signed-off-by: Teresa Remmet 
> ---
> There has been send out a different version of this patch about a year ago.
> But there was no feedback at all. Please apply one of the solutions.
> 
> https://patchwork.kernel.org/patch/6596441/
> 

Oh, I wonder how I lost track of that first fix. I must have forgotten
it with some of those rejected BBB audio implementation attempts.

Not really sure if my earlier rewrite is actually any better that this.
I'll pick this one up for my next pull request.

Thanks!
Jyri

> Teresa
> 
>  drivers/gpu/drm/tilcdc/tilcdc_external.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c 
> b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> index 03acb4f..ceba712 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
> @@ -145,7 +145,7 @@ int tilcdc_get_external_components(struct device *dev,
>   struct device_node *node;
>  
>   node = of_graph_get_remote_port_parent(ep);
> - if (!node && !of_device_is_available(node)) {
> + if (!node || !of_device_is_available(node)) {
>   of_node_put(node);
>   continue;
>   }
> 



[PATCH 0/4] drm/tilcdc: Address LCDC rev 2 color errata

2016-08-16 Thread Jyri Sarha
The first patch ("drm/tilcdc: Remove drm_helper_disable_unused_functions()
call") is completely independent fix.

The red and blue components are reversed between 24 and 16 bit modes
on am335x LCDC output pins. To get 24 RGB format the wires red and
blue wires has to be crossed and this in turn causes 16 colors output
to be in BGR format. With straight wiring the 16 color is RGB and 24
bit is BGR. These patches try to deal with the issue in reasonable
manner.

For more details see section 3.1.1 in AM335x Silicon Errata:
http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360

Jyri Sarha (4):
  drm/tilcdc: Remove drm_helper_disable_unused_functions() call
  drm/tilcdc: Add blue-and-red-wiring -device tree property
  drm/tilcdc: Choose console BPP that supports RGB
  ARM: dts: am335x-boneblack: Convert BGR from LCDC to RGB in tda19988

 .../devicetree/bindings/display/tilcdc/tilcdc.txt  | 12 +
 arch/arm/boot/dts/am335x-boneblack.dts | 11 
 drivers/gpu/drm/tilcdc/tilcdc_drv.c| 59 ++
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|  5 +-
 drivers/gpu/drm/tilcdc/tilcdc_external.c   |  7 ++-
 drivers/gpu/drm/tilcdc/tilcdc_external.h   |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_panel.c  |  2 -
 drivers/gpu/drm/tilcdc/tilcdc_plane.c  |  9 ++--
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c |  2 -
 9 files changed, 82 insertions(+), 27 deletions(-)

-- 
1.9.1



[PATCH 1/4] drm/tilcdc: Remove drm_helper_disable_unused_functions() call

2016-08-16 Thread Jyri Sarha
drm_helper_disable_unused_functions() should not be called by atomic
drivers.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3404d24..e45c268 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -361,8 +361,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
break;
}

-   drm_helper_disable_unused_functions(dev);
-
drm_mode_config_reset(dev);

priv->fbdev = drm_fbdev_cma_init(dev, bpp,
-- 
1.9.1



[PATCH 2/4] drm/tilcdc: Add blue-and-red-wiring -device tree property

2016-08-16 Thread Jyri Sarha
Add "blue-and-red-wiring"-device tree property and update devicetree
binding document. The red and blue components are reversed between 24
and 16 bit modes on am335x LCDC output pins. To get 24 RGB format the
red and blue wires has to be crossed and this in turn causes 16 colors
output to be in BGR format. With straight wiring the 16 color is RGB
and 24 bit is BGR. The new property describes whether the red and blue
wires are crossed or not. The am335x-evm has the wires going to LCD
crossed and that is chosen to be the default mode if
"blue-and-red-wiring"-property is not found.

For more details see section 3.1.1 in AM335x Silicon Errata:
http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360

Signed-off-by: Jyri Sarha 
---
 .../devicetree/bindings/display/tilcdc/tilcdc.txt  | 12 ++
 drivers/gpu/drm/tilcdc/tilcdc_drv.c| 44 ++
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|  4 ++
 drivers/gpu/drm/tilcdc/tilcdc_plane.c  |  9 ++---
 4 files changed, 63 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt 
b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
index 6efa4c5..992803b 100644
--- a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
+++ b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
@@ -17,6 +17,8 @@ Optional properties:
the lcd controller.
  - max-pixelclock: The maximum pixel clock that can be supported
by the lcd controller in KHz.
+ - blue-and-red-wiring: Either "crossed" or "straight", if not present
+   crossed wiring is assumed for dtb backward compatibility. [1]

 Optional nodes:

@@ -28,6 +30,14 @@ Optional nodes:
Documentation/devicetree/bindings/display/tilcdc/tfp410.txt for connecting
tfp410 DVI encoder or lcd panel to lcdc

+[1] There is an errata about AM335x color wiring. For 16-bit color mode
+the wires work as they should (LCD_DATA[0:4] is for Blue[3:7]),
+but for 24 bit color modes the wiring of blue and red components is
+crossed and LCD_DATA[0:4] is for Red[3:7] and LCD_DATA[11:15] is
+for Blue[3-7]. For more details see section 3.1.1 in AM335x
+Silicon Errata:
+
http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360
+
 Example:

fb: fb at 4830e000 {
@@ -37,6 +47,8 @@ Example:
interrupts = <36>;
ti,hwmods = "lcdc";

+   blue-and-red-wiring = "crossed";
+
port {
lcdc_0: endpoint at 0 {
remote-endpoint = <&hdmi_0>;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index e45c268..7f9c19d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -33,6 +33,16 @@

 static LIST_HEAD(module_list);

+static const u32 tilcdc_rev1_formats[] = { DRM_FORMAT_RGB565 };
+
+static const u32 tilcdc_straight_formats[] = { DRM_FORMAT_RGB565,
+  DRM_FORMAT_BGR888,
+  DRM_FORMAT_XBGR };
+
+static const u32 tilcdc_crossed_formats[] = { DRM_FORMAT_BGR565,
+ DRM_FORMAT_RGB888,
+ DRM_FORMAT_XRGB };
+
 void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
const struct tilcdc_module_ops *funcs)
 {
@@ -221,6 +231,26 @@ static int tilcdc_unload(struct drm_device *dev)
return 0;
 }

+static bool tilcdc_of_blue_and_red_crossed(struct device_node *node)
+{
+   const char *str;
+   int ret;
+
+   ret = of_property_read_string(node, "blue-and-red-wiring", &str);
+
+   /* If no property is present, assume that wires are crossed */
+   if (ret != 0)
+   return true;
+
+   DBG("blue-and-red-wiring = \"%s\"", str);
+
+   /* Unless property is "crossed", assume the wires are straight */
+   if (0 == strcmp(str, "crossed"))
+   return true;
+
+   return false;
+}
+
 static int tilcdc_load(struct drm_device *dev, unsigned long flags)
 {
struct platform_device *pdev = dev->platformdev;
@@ -318,6 +348,20 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)

pm_runtime_put_sync(dev->dev);

+   if (priv->rev == 1) {
+   DBG("Revision 1 LCDC supports only RGB565 format");
+   priv->pixelformats = tilcdc_rev1_formats;
+   priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
+   } else if (tilcdc_of_blue_and_red_crossed(node)) {
+   DBG("Configured for crossed blue and red wires");
+   priv->pixelformats = tilcdc_crossed_formats;
+

[PATCH 3/4] drm/tilcdc: Choose console BPP that supports RGB

2016-08-16 Thread Jyri Sarha
Choose console BPP that supports RGB and remove the old fbdev bpp
selection code. LCDC on AM335x has red and blue wires switched between
24 bit and 16 bit colors. If 24 format is wired for RGB colors, the 16
bit format is wired for BGR. drm_fbdev_cma_init() does not currently
like anything else but RGB formats, so we must choose such bytes per
pixel value that supports RGB.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  | 13 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.h  |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_external.c |  7 +++
 drivers/gpu/drm/tilcdc/tilcdc_external.h |  2 +-
 drivers/gpu/drm/tilcdc/tilcdc_panel.c|  2 --
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c   |  2 --
 6 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 7f9c19d..bb7af14 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -256,7 +256,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
struct platform_device *pdev = dev->platformdev;
struct device_node *node = pdev->dev.of_node;
struct tilcdc_drm_private *priv;
-   struct tilcdc_module *mod;
struct resource *res;
u32 bpp = 0;
int ret;
@@ -352,14 +351,17 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
DBG("Revision 1 LCDC supports only RGB565 format");
priv->pixelformats = tilcdc_rev1_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
+   bpp = 16;
} else if (tilcdc_of_blue_and_red_crossed(node)) {
DBG("Configured for crossed blue and red wires");
priv->pixelformats = tilcdc_crossed_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_crossed_formats);
+   bpp = 32; /* Choose bpp with RGB support for fbdef */
} else {
DBG("Configured for straight blue and red wires");
priv->pixelformats = tilcdc_straight_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_straight_formats);
+   bpp = 16; /* Choose bpp with RGB support for fbdef */
}

ret = modeset_init(dev);
@@ -375,7 +377,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
if (ret < 0)
goto fail_mode_config_cleanup;

-   ret = tilcdc_add_external_encoders(dev, &bpp);
+   ret = tilcdc_add_external_encoders(dev);
if (ret < 0)
goto fail_component_cleanup;
}
@@ -398,13 +400,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned 
long flags)
goto fail_vblank_cleanup;
}

-   list_for_each_entry(mod, &module_list, list) {
-   DBG("%s: preferred_bpp: %d", mod->name, mod->preferred_bpp);
-   bpp = mod->preferred_bpp;
-   if (bpp > 0)
-   break;
-   }
-
drm_mode_config_reset(dev);

priv->fbdev = drm_fbdev_cma_init(dev, bpp,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 0e19c14..a6e5e6d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -116,7 +116,6 @@ struct tilcdc_module {
const char *name;
struct list_head list;
const struct tilcdc_module_ops *funcs;
-   unsigned int preferred_bpp;
 };

 void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c 
b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 849b23e..68e8950 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -52,7 +52,7 @@ static int tilcdc_external_mode_valid(struct drm_connector 
*connector,
return MODE_OK;
 }

-static int tilcdc_add_external_encoder(struct drm_device *dev, int *bpp,
+static int tilcdc_add_external_encoder(struct drm_device *dev,
   struct drm_connector *connector)
 {
struct tilcdc_drm_private *priv = dev->dev_private;
@@ -64,7 +64,6 @@ static int tilcdc_add_external_encoder(struct drm_device 
*dev, int *bpp,
/* Only tda998x is supported at the moment. */
tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true);
tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x);
-   *bpp = panel_info_tda998x.bpp;

connector_funcs = devm_kzalloc(dev->dev, sizeof(*connector_funcs),
   GFP_KERNEL);
@@ -94,7 +93,7 @@ static int tilcdc_add_external_encoder(struct drm_device 
*dev, int *bpp,
return 0;
 }

-int tilcdc_add_external_encoders(struct drm_device *dev, int *bpp)
+int tilcd

[PATCH 4/4] ARM: dts: am335x-boneblack: Convert BGR from LCDC to RGB in tda19988

2016-08-16 Thread Jyri Sarha
Convert BGR from LCDC to RGB in tda19988 with video-ports property.
The red and blue components are reversed between 24 and 16 bit modes
on color output of am335x LCDC. On BBB the 16 bit video output is by
default RGB and 24 is BGR. This patch reverts that using tda19988 so
we have a 24 bit RGB mode and 16 BGR mode.

The commit also adds blue-and-red-wiring = "crossed" -property to LCDC
node. This change is functionally redundant as "crossed" is the
default mode if the property does not exist, but it makes the reason
for tda19988 video-port property mode explicit.

If you want to get 16 RGB mode (and 24 BGR mode), set tda19988
video-ports -property to 0x230145 and tilcdc blue-and-red-wiring
-property to "straight".

Signed-off-by: Jyri Sarha 
---
 arch/arm/boot/dts/am335x-boneblack.dts | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-boneblack.dts 
b/arch/arm/boot/dts/am335x-boneblack.dts
index 528559b..a745962 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -90,6 +90,14 @@

 &lcdc {
status = "okay";
+
+   /* If you want to get 16 RGB and 24 BGR mode instead of
+* current 24 bit RGB and 16 BGR modes, set this property to
+* "straight" and the tda19988 video-ports -property bellow
+* to 0x230145 (or remove the property).
+*/
+   blue-and-red-wiring = "crossed";
+
port {
lcdc_0: endpoint at 0 {
remote-endpoint = <&hdmi_0>;
@@ -106,6 +114,9 @@
pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;

+   /* Convert 24bit BGR to RGB, e.g. cross red and blue wiring */
+   video-ports = <0x234501>;
+
#sound-dai-cells = <0>;
audio-ports = < TDA998x_I2S 0x03>;

-- 
1.9.1



[PATCH 2/4] drm/tilcdc: Add blue-and-red-wiring -device tree property

2016-08-19 Thread Jyri Sarha
On 08/18/16 22:17, Rob Herring wrote:
> On Tue, Aug 16, 2016 at 12:24:28PM +0300, Jyri Sarha wrote:
>> Add "blue-and-red-wiring"-device tree property and update devicetree
>> binding document. The red and blue components are reversed between 24
>> and 16 bit modes on am335x LCDC output pins. To get 24 RGB format the
>> red and blue wires has to be crossed and this in turn causes 16 colors
>> output to be in BGR format. With straight wiring the 16 color is RGB
>> and 24 bit is BGR. The new property describes whether the red and blue
>> wires are crossed or not. The am335x-evm has the wires going to LCD
>> crossed and that is chosen to be the default mode if
>> "blue-and-red-wiring"-property is not found.
>>
>> For more details see section 3.1.1 in AM335x Silicon Errata:
>> http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sprz360
>>
>> Signed-off-by: Jyri Sarha 
>> ---
>>  .../devicetree/bindings/display/tilcdc/tilcdc.txt  | 12 ++
>>  drivers/gpu/drm/tilcdc/tilcdc_drv.c| 44 
>> ++
>>  drivers/gpu/drm/tilcdc/tilcdc_drv.h|  4 ++
>>  drivers/gpu/drm/tilcdc/tilcdc_plane.c  |  9 ++---
>>  4 files changed, 63 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt 
>> b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
>> index 6efa4c5..992803b 100644
>> --- a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
>> +++ b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
>> @@ -17,6 +17,8 @@ Optional properties:
>> the lcd controller.
>>   - max-pixelclock: The maximum pixel clock that can be supported
>> by the lcd controller in KHz.
>> + - blue-and-red-wiring: Either "crossed" or "straight", if not present
>> +   crossed wiring is assumed for dtb backward compatibility. [1]
> 
> Just do a boolean and restrict it to a particular compatible string so 
> we don't have to carry it forever on new parts.
>

Do you mean having "blue-and-red-straight" boolean property to keep old
dtbs compatible, or coming up with a new compatible string (I actually
hate ti,tilcdc tautology) and having "blue-and-red-crossed" boolean there?

BTW, I find it unlikely that there will be new versions of LCDC coming
any more, so the errata will remain "forever" on LCDC and will only fade
out when the am3 fades out. I base my assumption only on the fact that
am4 does not have LCDC any more.

Best regards,
Jyri



[PATCH v8 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-05-27 Thread Jyri Sarha
The sii902x chip family supports also HDMI audio. Add binding for
describing the necessary i2s and mclk wiring for it.

Signed-off-by: Jyri Sarha 
Reviewed-by: Rob Herring 
---
 .../bindings/display/bridge/sii902x.txt   | 40 +++
 1 file changed, 40 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index c4c1855ca654..2df44b7d3821 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -9,6 +9,40 @@ Optional properties:
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
+   HDMI audio properties:
+   - #sound-dai-cells: <0> or <1>. <0> if only i2s or spdif pin
+  is wired, <1> if the both are wired. HDMI audio is
+  configured only if this property is found.
+   - sil,i2s-data-lanes: Array of up to 4 integers with values of 0-3
+  Each integer indicates which i2s pin is connected to which
+  audio fifo. The first integer selects i2s audio pin for the
+  first audio fifo#0 (HDMI channels 1&2), second for fifo#1
+  (HDMI channels 3&4), and so on. There is 4 fifos and 4 i2s
+  pins (SD0 - SD3). Any i2s pin can be connected to any fifo,
+  but there can be no gaps. E.g. an i2s pin must be mapped to
+  fifo#0 and fifo#1 before mapping a channel to fifo#2. Default
+  value is <0>, describing SD0 pin beiging routed to hdmi audio
+  fifo #0.
+   - clocks: phandle and clock specifier for each clock listed in
+   the clock-names property
+   - clock-names: "mclk"
+  Describes SII902x MCLK input. MCLK is used to produce
+  HDMI audio CTS values. This property is required if
+  "#sound-dai-cells"-property is present. This property follows
+  Documentation/devicetree/bindings/clock/clock-bindings.txt
+  consumer binding.
+
+   If HDMI audio is configured the sii902x device becomes an I2S
+   and/or spdif audio codec component (e.g a digital audio sink),
+   that can be used in configuring a full audio devices with
+   simple-card or audio-graph-card binding. See their binding
+   documents on how to describe the way the sii902x device is
+   connected to the rest of the audio system:
+   Documentation/devicetree/bindings/sound/simple-card.txt
+   Documentation/devicetree/bindings/sound/audio-graph-card.txt
+   Note: In case of the audio-graph-card binding the used port
+   index should be 3.
+
 Optional subnodes:
- video input: this subnode can contain a video input port node
  to connect the bridge to a display controller output (See this
@@ -21,6 +55,12 @@ Example:
compatible = "sil,sii9022";
reg = <0x39>;
reset-gpios = <&pioA 1 0>;
+
+   #sound-dai-cells = <0>;
+   sil,i2s-data-lanes = < 0 1 2 >;
+   clocks = <&mclk>;
+   clock-names = "mclk";
+
ports {
#address-cells = <1>;
#size-cells = <0>;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v8 4/6] dt-bindings: display: sii902x: Remove trailing white space

2019-05-27 Thread Jyri Sarha
Remove trailing white space from sii902x display bridge binding.

Signed-off-by: Jyri Sarha 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Rob Herring 
---
 Documentation/devicetree/bindings/display/bridge/sii902x.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index 72d2dc6c3e6b..c4c1855ca654 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -5,7 +5,7 @@ Required properties:
- reg: i2c address of the bridge
 
 Optional properties:
-   - interrupts: describe the interrupt line used to inform the host 
+   - interrupts: describe the interrupt line used to inform the host
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v8 0/6] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-05-27 Thread Jyri Sarha
I think these should be ready for applying to drm-misc.

Changes since v7:
 - Debased on top of the lasts drm-misc-next and tested
 - "dt-bindings: display: sii902x: Add HDMI audio bindings"
   - Dropped off "or higher to avoid conflict with video ports"
 and added "Reviewed-by: Rob Herring "

Ther previous round:
https://patchwork.kernel.org/cover/10919173/

Jyri Sarha (5):
  drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
  dt-bindings: display: sii902x: Remove trailing white space
  dt-bindings: display: sii902x: Add HDMI audio bindings
  drm/bridge: sii902x: Implement HDMI audio support

Tomi Valkeinen (1):
  drm/bridge: sii902x: add input_bus_flags

 .../bindings/display/bridge/sii902x.txt   |  42 +-
 drivers/gpu/drm/bridge/sii902x.c  | 488 +-
 2 files changed, 522 insertions(+), 8 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v8 1/6] drm/bridge: sii902x: add input_bus_flags

2019-05-27 Thread Jyri Sarha
From: Tomi Valkeinen 

The driver always sets InputBusFmt:EDGE to 0 (falling edge).

Add drm_bridge_timings's input_bus_flags to reflect that the bridge
samples on falling edges.

Signed-off-by: Tomi Valkeinen 
Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index cdb8dfdb2dff..0d3d730b97ff 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -461,6 +461,12 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core 
*mux, u32 chan_id)
return 0;
 }
 
+static const struct drm_bridge_timings default_sii902x_timings = {
+   .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_DE_HIGH,
+};
+
 static int sii902x_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -531,6 +537,7 @@ static int sii902x_probe(struct i2c_client *client,
 
sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
+   sii902x->bridge.timings = &default_sii902x_timings;
drm_bridge_add(&sii902x->bridge);
 
i2c_set_clientdata(client, sii902x);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v8 2/6] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-05-27 Thread Jyri Sarha
Set output mode to HDMI or DVI according to EDID HDMI signature.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 0d3d730b97ff..128d8fdb4ba6 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -181,12 +181,16 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
 {
struct sii902x *sii902x = connector_to_sii902x(connector);
u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+   u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
struct edid *edid;
int num = 0, ret;
 
edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
drm_connector_update_edid_property(connector, edid);
if (edid) {
+   if (drm_detect_hdmi_monitor(edid))
+   output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
+
num = drm_add_edid_modes(connector, edid);
kfree(edid);
}
@@ -196,6 +200,11 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
if (ret)
return ret;
 
+   ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
+SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
+   if (ret)
+   return ret;
+
return num;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v8 3/6] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

2019-05-27 Thread Jyri Sarha
The pixel clock unit in the first two registers (0x00 and 0x01) of
sii9022 is 10kHz, not 1kHz as in struct drm_display_mode. Division by
10 fixes the issue.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 128d8fdb4ba6..19f982a00dba 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -249,10 +249,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge 
*bridge,
struct regmap *regmap = sii902x->regmap;
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
struct hdmi_avi_infoframe frame;
+   u16 pixel_clock_10kHz = adj->clock / 10;
int ret;
 
-   buf[0] = adj->clock;
-   buf[1] = adj->clock >> 8;
+   buf[0] = pixel_clock_10kHz & 0xff;
+   buf[1] = pixel_clock_10kHz >> 8;
buf[2] = adj->vrefresh;
buf[3] = 0x00;
buf[4] = adj->hdisplay;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v8 6/6] drm/bridge: sii902x: Implement HDMI audio support

2019-05-27 Thread Jyri Sarha
Implement HDMI audio support by using ASoC HDMI codec. The commit
implements the necessary callbacks and configuration for the HDMI
codec and registers a virtual platform device for the codec to attach.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 469 ++-
 1 file changed, 463 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 19f982a00dba..bc3325c5e5c3 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -34,6 +35,8 @@
 #include 
 #include 
 
+#include 
+
 #define SII902X_TPI_VIDEO_DATA 0x0
 
 #define SII902X_TPI_PIXEL_REPETITION   0x8
@@ -75,6 +78,77 @@
 #define SII902X_AVI_POWER_STATE_MSKGENMASK(1, 0)
 #define SII902X_AVI_POWER_STATE_D(l)   ((l) & 
SII902X_AVI_POWER_STATE_MSK)
 
+/* Audio  */
+#define SII902X_TPI_I2S_ENABLE_MAPPING_REG 0x1f
+#define SII902X_TPI_I2S_CONFIG_FIFO0   (0 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO1   (1 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO2   (2 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO3   (3 << 0)
+#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP(1 << 2)
+#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE(1 << 3)
+#define SII902X_TPI_I2S_SELECT_SD0 (0 << 4)
+#define SII902X_TPI_I2S_SELECT_SD1 (1 << 4)
+#define SII902X_TPI_I2S_SELECT_SD2 (2 << 4)
+#define SII902X_TPI_I2S_SELECT_SD3 (3 << 4)
+#define SII902X_TPI_I2S_FIFO_ENABLE(1 << 7)
+
+#define SII902X_TPI_I2S_INPUT_CONFIG_REG   0x20
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES(0 << 0)
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO (1 << 0)
+#define SII902X_TPI_I2S_SD_DIRECTION_MSB_FIRST (0 << 1)
+#define SII902X_TPI_I2S_SD_DIRECTION_LSB_FIRST (1 << 1)
+#define SII902X_TPI_I2S_SD_JUSTIFY_LEFT(0 << 2)
+#define SII902X_TPI_I2S_SD_JUSTIFY_RIGHT   (1 << 2)
+#define SII902X_TPI_I2S_WS_POLARITY_LOW(0 << 3)
+#define SII902X_TPI_I2S_WS_POLARITY_HIGH   (1 << 3)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_128(0 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_256(1 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_384(2 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_512(3 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_768(4 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1024   (5 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1152   (6 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_192(7 << 4)
+#define SII902X_TPI_I2S_SCK_EDGE_FALLING   (0 << 7)
+#define SII902X_TPI_I2S_SCK_EDGE_RISING(1 << 7)
+
+#define SII902X_TPI_I2S_STRM_HDR_BASE  0x21
+#define SII902X_TPI_I2S_STRM_HDR_SIZE  5
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE2_REG 0x26
+#define SII902X_TPI_AUDIO_CODING_STREAM_HEADER (0 << 0)
+#define SII902X_TPI_AUDIO_CODING_PCM   (1 << 0)
+#define SII902X_TPI_AUDIO_CODING_AC3   (2 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG1 (3 << 0)
+#define SII902X_TPI_AUDIO_CODING_MP3   (4 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG2 (5 << 0)
+#define SII902X_TPI_AUDIO_CODING_AAC   (6 << 0)
+#define SII902X_TPI_AUDIO_CODING_DTS   (7 << 0)
+#define SII902X_TPI_AUDIO_CODING_ATRAC (8 << 0)
+#define SII902X_TPI_AUDIO_MUTE_DISABLE (0 << 4)
+#define SII902X_TPI_AUDIO_MUTE_ENABLE  (1 << 4)
+#define SII902X_TPI_AUDIO_LAYOUT_2_CHANNELS(0 << 5)
+#define SII902X_TPI_AUDIO_LAYOUT_8_CHANNELS(1 << 5)
+#define SII902X_TPI_AUDIO_INTERFACE_DISABLE(0 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_SPDIF  (1 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_I2S(2 << 6)
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE3_REG 0x27
+#define SII902X_TPI_AUDIO_FREQ_STREAM  (0 << 3)
+#define SII902X_TPI_AUDIO_FREQ_32KHZ   (1 << 3)
+#define SII902X_TPI_AUDIO_FREQ_44KHZ   (2 << 3)
+#define SII902X_TPI_AUDIO_FREQ_48KHZ   (3 << 3)
+#define SII902X_TPI_AUDIO_FREQ_88KHZ   (4 << 3)
+#define SII902X_TPI_AUDIO_FREQ_96KHZ   (5 <

Re: [PATCH v6 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-04-06 Thread Jyri Sarha
On 06/04/2019 09:06, Rob Herring wrote:
> On Tue, Apr 02, 2019 at 10:29:14AM +0300, Jyri Sarha wrote:
>> The sii902x chip family supports also HDMI audio. Add binding for
>> describing the necessary i2s and mclk wiring for it.
>>
>> Signed-off-by: Jyri Sarha 
>> ---
>>  .../bindings/display/bridge/sii902x.txt   | 37 +++
>>  1 file changed, 37 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
>> b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>> index c4c1855ca654..d124a5fedab1 100644
>> --- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>> +++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>> @@ -9,6 +9,37 @@ Optional properties:
>>about hotplug events.
>>  - reset-gpios: OF device-tree gpio specification for RST_N pin.
>>  
>> +HDMI audio properties:
>> +- #sound-dai-cells: <0> or <1>. <0> if only i2s or spdif pin
>> +   is wired, <1> if the both are wired. HDMI audio is
>> +   configured only if this property is found.
>> +- sil,i2s-data-lanes: Array of up to 4 integers with values of 0-3
>> +   Each integer indicates which i2s pin is connected to which
>> +   audio fifo. The first integer selects i2s audio pin for the
>> +   first audio fifo#0 (HDMI channels 1&2), second for fifo#1
>> +   (HDMI channels 3&4), and so on. There is 4 fifos and 4 i2s
>> +   pins (SD0 - SD3). Any i2s pin can be connected to any fifo,
>> +   but there can be no gaps. E.g. an i2s pin must be mapped to
>> +   fifo#0 and fifo#1 before mapping a channel to fifo#2. Default
>> +   value is <0>, describing SD0 pin beiging routed to hdmi audio
>> +   fifo #0.
>> +- clocks: phandle and clock specifier for each clock listed in
>> +   the clock-names property
>> +- clock-names: "mclk"
>> +   Describes SII902x MCLK input. MCLK is used to produce
>> +   HDMI audio CTS values. This property is required if
>> +   "#sound-dai-cells"-property is present. This property follows
>> +   Documentation/devicetree/bindings/clock/clock-bindings.txt
>> +   consumer binding.
>> +
>> +If HDMI audio is configured the sii902x device becomes an ASoC
>> +codec component, that can be used in configuring full audio
>> +devices with ASoC simple-card or audio-graph-card. See their
> 
> ASoC is a Linux thing.

Yes it is. Does it mean that I should not use the term in the binding
document?

E.g. Write it like this:

If HDMI audio is configured the sii902x device becomes an I2S and/or
spdif audio codec component (e.g a digital audio sink), that can be used
in configuring a full audio devices with simple-card or audio-graph-card
binding. See their binding documents on how to describe the way the
sii902x device is connected to the rest of the audio system:
Documentation/devicetree/bindings/sound/simple-card.txt
Documentation/devicetree/bindings/sound/audio-graph-card.txt

> 
>> +binding documents on how to describe how the sii902x device is
>> +connected to the rest of the audio system:
>> +Documentation/devicetree/bindings/sound/simple-card.txt
>> +Documentation/devicetree/bindings/sound/audio-graph-card.txt
>> +
>>  Optional subnodes:
>>  - video input: this subnode can contain a video input port node
>>to connect the bridge to a display controller output (See this
>> @@ -21,6 +52,12 @@ Example:
>>  compatible = "sil,sii9022";
>>  reg = <0x39>;
>>  reset-gpios = <&pioA 1 0>;
>> +
>> +#sound-dai-cells = <0>;
>> +i2s-data-lanes = < 0 1 2 >;
>> +clocks = <&mclk>;
>> +clock-names = "mclk";
>> +
>>  ports {
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>> -- 
>> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
>> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
>>
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v5 6/6] drm/bridge: sii902x: Implement HDMI audio support

2019-04-12 Thread Jyri Sarha
On 12/04/2019 11:52, Andrzej Hajda wrote:
> On 22.03.2019 09:06, Jyri Sarha wrote:
>> Implement HDMI audio support by using ASoC HDMI codec. The commit
>> implements the necessary callbacks and configuration for the HDMI
>> codec and registers a virtual platform device for the codec to attach.
>>
>> Signed-off-by: Jyri Sarha 
>> ---
>>  drivers/gpu/drm/bridge/sii902x.c | 459 ++-
>>  1 file changed, 453 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/sii902x.c 
>> b/drivers/gpu/drm/bridge/sii902x.c
>> index 358cf81c5ea4..cb12e264111d 100644
>> --- a/drivers/gpu/drm/bridge/sii902x.c
>> +++ b/drivers/gpu/drm/bridge/sii902x.c
>> @@ -27,12 +27,15 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #include 
>>  #include 
>>  #include 
>>  #include 
>>  
>> +#include 
>> +
>>  #define SII902X_TPI_VIDEO_DATA  0x0
>>  
>>  #define SII902X_TPI_PIXEL_REPETITION0x8
>> @@ -74,6 +77,77 @@
>>  #define SII902X_AVI_POWER_STATE_MSK GENMASK(1, 0)
>>  #define SII902X_AVI_POWER_STATE_D(l)((l) & 
>> SII902X_AVI_POWER_STATE_MSK)
>>  
>> +/* Audio  */
>> +#define SII902X_TPI_I2S_ENABLE_MAPPING_REG  0x1f
>> +#define SII902X_TPI_I2S_CONFIG_FIFO0(0 << 0)
>> +#define SII902X_TPI_I2S_CONFIG_FIFO1(1 << 0)
>> +#define SII902X_TPI_I2S_CONFIG_FIFO2(2 << 0)
>> +#define SII902X_TPI_I2S_CONFIG_FIFO3(3 << 0)
>> +#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP (1 << 2)
>> +#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE (1 << 3)
>> +#define SII902X_TPI_I2S_SELECT_SD0  (0 << 4)
>> +#define SII902X_TPI_I2S_SELECT_SD1  (1 << 4)
>> +#define SII902X_TPI_I2S_SELECT_SD2  (2 << 4)
>> +#define SII902X_TPI_I2S_SELECT_SD3  (3 << 4)
>> +#define SII902X_TPI_I2S_FIFO_ENABLE (1 << 7)
>> +
>> +#define SII902X_TPI_I2S_INPUT_CONFIG_REG0x20
>> +#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES (0 << 0)
>> +#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO  (1 << 0)
>> +#define SII902X_TPI_I2S_SD_DIRECTION_MSB_FIRST  (0 << 1)
>> +#define SII902X_TPI_I2S_SD_DIRECTION_LSB_FIRST  (1 << 1)
>> +#define SII902X_TPI_I2S_SD_JUSTIFY_LEFT (0 << 2)
>> +#define SII902X_TPI_I2S_SD_JUSTIFY_RIGHT(1 << 2)
>> +#define SII902X_TPI_I2S_WS_POLARITY_LOW (0 << 3)
>> +#define SII902X_TPI_I2S_WS_POLARITY_HIGH(1 << 3)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_128 (0 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_256 (1 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_384 (2 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_512 (3 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_768 (4 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1024(5 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1152(6 << 4)
>> +#define SII902X_TPI_I2S_MCLK_MULTIPLIER_192 (7 << 4)
>> +#define SII902X_TPI_I2S_SCK_EDGE_FALLING(0 << 7)
>> +#define SII902X_TPI_I2S_SCK_EDGE_RISING (1 << 7)
>> +
>> +#define SII902X_TPI_I2S_STRM_HDR_BASE   0x21
>> +#define SII902X_TPI_I2S_STRM_HDR_SIZE   5
>> +
>> +#define SII902X_TPI_AUDIO_CONFIG_BYTE2_REG  0x26
>> +#define SII902X_TPI_AUDIO_CODING_STREAM_HEADER  (0 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_PCM(1 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_AC3(2 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_MPEG1  (3 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_MP3(4 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_MPEG2  (5 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_AAC(6 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_DTS(7 << 0)
>> +#define SII902X_TPI_AUDIO_CODING_ATRAC  (8 << 0)
>> +#define SII902X_TPI_AUDIO_MUTE_DISABLE  (0 << 4)
>> +#define SII902X_TPI_AUDIO_MUTE_ENABLE   (1 << 4)
>

Re: [PATCH v5 6/6] drm/bridge: sii902x: Implement HDMI audio support

2019-04-15 Thread Jyri Sarha
On 12/04/2019 15:30, Andrzej Hajda wrote:
 +static const unsigned int sii902x_mclk_div_table[] = {
 +  128, 256, 384, 512, 768, 1024, 1152, 192 };
 +
 +static int sii902x_select_mclk_div(u8 *i2s_config_reg, unsigned int rate,
 + unsigned int mclk)
 +{
 +  unsigned int div = mclk / rate;
 +  int distance = 10;
 +  u8 i, nearest = 0;
 +
 +  for (i = 0; i < ARRAY_SIZE(sii902x_mclk_div_table); i++) {
 +  unsigned int d = abs(div - sii902x_mclk_div_table[i]);
>>> Using unsigned types in this context seems to be asking for troubles.
>>>
>> Why? Isn't return value of abs() by definition unsigned? Using signed
>> integers when comparing absolute distances would seem awkward to me.
> 
> (div - sii902x_mclk_div_table[i]) is unsigned, if div is lower, there is 
> overflow, and the value is big int, I suppose this is not what you want.
> 

Oh yes. I had my eyes fixed on wrong unsigned. The first operand of
subtraction should indeed be signed for the result to be signed, I
completely overlooked that.

Thanks,
Jyri



-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 1/6] drm/bridge: sii902x: add input_bus_flags

2019-04-26 Thread Jyri Sarha
From: Tomi Valkeinen 

The driver always sets InputBusFmt:EDGE to 0 (falling edge).

Add drm_bridge_timings's input_bus_flags to reflect that the bridge
samples on falling edges.

Signed-off-by: Tomi Valkeinen 
Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index bfa902013aa4..1afa000141d5 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -459,6 +459,12 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core 
*mux, u32 chan_id)
return 0;
 }
 
+static const struct drm_bridge_timings default_sii902x_timings = {
+   .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_DE_HIGH,
+};
+
 static int sii902x_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -529,6 +535,7 @@ static int sii902x_probe(struct i2c_client *client,
 
sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
+   sii902x->bridge.timings = &default_sii902x_timings;
drm_bridge_add(&sii902x->bridge);
 
i2c_set_clientdata(client, sii902x);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 2/6] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-04-26 Thread Jyri Sarha
Set output mode to HDMI or DVI according to EDID HDMI signature.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1afa000141d5..f73eaa6d729a 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -180,12 +180,16 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
 {
struct sii902x *sii902x = connector_to_sii902x(connector);
u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+   u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
struct edid *edid;
int num = 0, ret;
 
edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
drm_connector_update_edid_property(connector, edid);
if (edid) {
+   if (drm_detect_hdmi_monitor(edid))
+   output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
+
num = drm_add_edid_modes(connector, edid);
kfree(edid);
}
@@ -195,6 +199,11 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
if (ret)
return ret;
 
+   ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
+SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
+   if (ret)
+   return ret;
+
return num;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-04-26 Thread Jyri Sarha
The sii902x chip family supports also HDMI audio. Add binding for
describing the necessary i2s and mclk wiring for it.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/bridge/sii902x.txt   | 41 +++
 1 file changed, 41 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index c4c1855ca654..b5168a0e3a2b 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -9,6 +9,41 @@ Optional properties:
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
+   HDMI audio properties:
+   - #sound-dai-cells: <0> or <1>. <0> if only i2s or spdif pin
+  is wired, <1> if the both are wired. HDMI audio is
+  configured only if this property is found.
+   - sil,i2s-data-lanes: Array of up to 4 integers with values of 0-3
+  Each integer indicates which i2s pin is connected to which
+  audio fifo. The first integer selects i2s audio pin for the
+  first audio fifo#0 (HDMI channels 1&2), second for fifo#1
+  (HDMI channels 3&4), and so on. There is 4 fifos and 4 i2s
+  pins (SD0 - SD3). Any i2s pin can be connected to any fifo,
+  but there can be no gaps. E.g. an i2s pin must be mapped to
+  fifo#0 and fifo#1 before mapping a channel to fifo#2. Default
+  value is <0>, describing SD0 pin beiging routed to hdmi audio
+  fifo #0.
+   - clocks: phandle and clock specifier for each clock listed in
+   the clock-names property
+   - clock-names: "mclk"
+  Describes SII902x MCLK input. MCLK is used to produce
+  HDMI audio CTS values. This property is required if
+  "#sound-dai-cells"-property is present. This property follows
+  Documentation/devicetree/bindings/clock/clock-bindings.txt
+  consumer binding.
+
+   If HDMI audio is configured the sii902x device becomes an I2S
+   and/or spdif audio codec component (e.g a digital audio sink),
+   that can be used in configuring a full audio devices with
+   simple-card or audio-graph-card binding. See their binding
+   documents on how to describe the way the sii902x device is
+   connected to the rest of the audio system:
+   Documentation/devicetree/bindings/sound/simple-card.txt
+   Documentation/devicetree/bindings/sound/audio-graph-card.txt
+   Note: In case of the audio-graph-card binding the used port
+   index should be 3 or higher to avoid conflict with video ports
+   (see bellow).
+
 Optional subnodes:
- video input: this subnode can contain a video input port node
  to connect the bridge to a display controller output (See this
@@ -21,6 +56,12 @@ Example:
compatible = "sil,sii9022";
reg = <0x39>;
reset-gpios = <&pioA 1 0>;
+
+   #sound-dai-cells = <0>;
+   sil,i2s-data-lanes = < 0 1 2 >;
+   clocks = <&mclk>;
+   clock-names = "mclk";
+
ports {
#address-cells = <1>;
#size-cells = <0>;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 4/6] dt-bindings: display: sii902x: Remove trailing white space

2019-04-26 Thread Jyri Sarha
Remove trailing white space from sii902x display bridge binding.

Signed-off-by: Jyri Sarha 
Reviewed-by: Laurent Pinchart 
Reviewed-by: Rob Herring 
---
 Documentation/devicetree/bindings/display/bridge/sii902x.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index 72d2dc6c3e6b..c4c1855ca654 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -5,7 +5,7 @@ Required properties:
- reg: i2c address of the bridge
 
 Optional properties:
-   - interrupts: describe the interrupt line used to inform the host 
+   - interrupts: describe the interrupt line used to inform the host
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 0/6] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-04-26 Thread Jyri Sarha
The already reviewed patches are in front. Not reviewed still patches 5-6. 

Changes since v6:
- "dt-bindings: display: sii902x: Add HDMI audio bindings"
 - Replace references to ASoC (a Linux term) with more generic terms
 - Add "sil,"-prefix to "i2s-data-lanes"-property in the example node
- "drm/bridge: sii902x: Implement HDMI audio support"
 - Do not use unsigned in sii902x_select_mclk_div()'s "distance" calculations
   to avoid bad type promotions to unsigned causing unexpected results
 - Always return the clock divisor by sii902x_select_mclk_div()
 - Disable regmap locking since the driver specific locking should be enough
 - Add missing mutex locking to the register access in the irq handler

The previous round:
https://patchwork.kernel.org/cover/10881169/

Jyri Sarha (5):
  drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
  dt-bindings: display: sii902x: Remove trailing white space
  dt-bindings: display: sii902x: Add HDMI audio bindings
  drm/bridge: sii902x: Implement HDMI audio support

Tomi Valkeinen (1):
  drm/bridge: sii902x: add input_bus_flags

 .../bindings/display/bridge/sii902x.txt   |  43 +-
 drivers/gpu/drm/bridge/sii902x.c  | 488 +-
 2 files changed, 523 insertions(+), 8 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 3/6] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

2019-04-26 Thread Jyri Sarha
The pixel clock unit in the first two registers (0x00 and 0x01) of
sii9022 is 10kHz, not 1kHz as in struct drm_display_mode. Division by
10 fixes the issue.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index f73eaa6d729a..358cf81c5ea4 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -248,10 +248,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge 
*bridge,
struct regmap *regmap = sii902x->regmap;
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
struct hdmi_avi_infoframe frame;
+   u16 pixel_clock_10kHz = adj->clock / 10;
int ret;
 
-   buf[0] = adj->clock;
-   buf[1] = adj->clock >> 8;
+   buf[0] = pixel_clock_10kHz & 0xff;
+   buf[1] = pixel_clock_10kHz >> 8;
buf[2] = adj->vrefresh;
buf[3] = 0x00;
buf[4] = adj->hdisplay;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v7 6/6] drm/bridge: sii902x: Implement HDMI audio support

2019-04-26 Thread Jyri Sarha
Implement HDMI audio support by using ASoC HDMI codec. The commit
implements the necessary callbacks and configuration for the HDMI
codec and registers a virtual platform device for the codec to attach.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/sii902x.c | 469 ++-
 1 file changed, 463 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 358cf81c5ea4..2ecbd3f80715 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -27,12 +27,15 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+
 #define SII902X_TPI_VIDEO_DATA 0x0
 
 #define SII902X_TPI_PIXEL_REPETITION   0x8
@@ -74,6 +77,77 @@
 #define SII902X_AVI_POWER_STATE_MSKGENMASK(1, 0)
 #define SII902X_AVI_POWER_STATE_D(l)   ((l) & 
SII902X_AVI_POWER_STATE_MSK)
 
+/* Audio  */
+#define SII902X_TPI_I2S_ENABLE_MAPPING_REG 0x1f
+#define SII902X_TPI_I2S_CONFIG_FIFO0   (0 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO1   (1 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO2   (2 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO3   (3 << 0)
+#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP(1 << 2)
+#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE(1 << 3)
+#define SII902X_TPI_I2S_SELECT_SD0 (0 << 4)
+#define SII902X_TPI_I2S_SELECT_SD1 (1 << 4)
+#define SII902X_TPI_I2S_SELECT_SD2 (2 << 4)
+#define SII902X_TPI_I2S_SELECT_SD3 (3 << 4)
+#define SII902X_TPI_I2S_FIFO_ENABLE(1 << 7)
+
+#define SII902X_TPI_I2S_INPUT_CONFIG_REG   0x20
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES(0 << 0)
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO (1 << 0)
+#define SII902X_TPI_I2S_SD_DIRECTION_MSB_FIRST (0 << 1)
+#define SII902X_TPI_I2S_SD_DIRECTION_LSB_FIRST (1 << 1)
+#define SII902X_TPI_I2S_SD_JUSTIFY_LEFT(0 << 2)
+#define SII902X_TPI_I2S_SD_JUSTIFY_RIGHT   (1 << 2)
+#define SII902X_TPI_I2S_WS_POLARITY_LOW(0 << 3)
+#define SII902X_TPI_I2S_WS_POLARITY_HIGH   (1 << 3)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_128(0 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_256(1 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_384(2 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_512(3 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_768(4 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1024   (5 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1152   (6 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_192(7 << 4)
+#define SII902X_TPI_I2S_SCK_EDGE_FALLING   (0 << 7)
+#define SII902X_TPI_I2S_SCK_EDGE_RISING(1 << 7)
+
+#define SII902X_TPI_I2S_STRM_HDR_BASE  0x21
+#define SII902X_TPI_I2S_STRM_HDR_SIZE  5
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE2_REG 0x26
+#define SII902X_TPI_AUDIO_CODING_STREAM_HEADER (0 << 0)
+#define SII902X_TPI_AUDIO_CODING_PCM   (1 << 0)
+#define SII902X_TPI_AUDIO_CODING_AC3   (2 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG1 (3 << 0)
+#define SII902X_TPI_AUDIO_CODING_MP3   (4 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG2 (5 << 0)
+#define SII902X_TPI_AUDIO_CODING_AAC   (6 << 0)
+#define SII902X_TPI_AUDIO_CODING_DTS   (7 << 0)
+#define SII902X_TPI_AUDIO_CODING_ATRAC (8 << 0)
+#define SII902X_TPI_AUDIO_MUTE_DISABLE (0 << 4)
+#define SII902X_TPI_AUDIO_MUTE_ENABLE  (1 << 4)
+#define SII902X_TPI_AUDIO_LAYOUT_2_CHANNELS(0 << 5)
+#define SII902X_TPI_AUDIO_LAYOUT_8_CHANNELS(1 << 5)
+#define SII902X_TPI_AUDIO_INTERFACE_DISABLE(0 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_SPDIF  (1 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_I2S(2 << 6)
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE3_REG 0x27
+#define SII902X_TPI_AUDIO_FREQ_STREAM  (0 << 3)
+#define SII902X_TPI_AUDIO_FREQ_32KHZ   (1 << 3)
+#define SII902X_TPI_AUDIO_FREQ_44KHZ   (2 << 3)
+#define SII902X_TPI_AUDIO_FREQ_48KHZ   (3 << 3)
+#define SII902X_TPI_AUDIO_FREQ_88KHZ   (4 << 3)
+#define SII902X_TPI_AUDIO_FREQ_96KHZ   (5 << 3)
+#define SII902X_TPI_AU

[PATCH] drm/tilcdc: Register cpufreq notifier after we have initialized crtc

2019-01-04 Thread Jyri Sarha
Register cpufreq notifier after we have initialized the crtc and
unregister it before we remove the ctrc. Receiving a cpufreq notify
without crtc causes a crash.

Reported-by: Peter Ujfalusi 
Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 34 ++---
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 33e533268488..bbd390cacc6b 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -184,6 +184,12 @@ static void tilcdc_fini(struct drm_device *dev)
 {
struct tilcdc_drm_private *priv = dev->dev_private;
 
+#ifdef CONFIG_CPU_FREQ
+   if (priv->freq_transition.notifier_call)
+   cpufreq_unregister_notifier(&priv->freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+#endif
+
if (priv->crtc)
tilcdc_crtc_shutdown(priv->crtc);
 
@@ -198,12 +204,6 @@ static void tilcdc_fini(struct drm_device *dev)
drm_mode_config_cleanup(dev);
tilcdc_remove_external_device(dev);
 
-#ifdef CONFIG_CPU_FREQ
-   if (priv->freq_transition.notifier_call)
-   cpufreq_unregister_notifier(&priv->freq_transition,
-   CPUFREQ_TRANSITION_NOTIFIER);
-#endif
-
if (priv->clk)
clk_put(priv->clk);
 
@@ -274,17 +274,6 @@ static int tilcdc_init(struct drm_driver *ddrv, struct 
device *dev)
goto init_failed;
}
 
-#ifdef CONFIG_CPU_FREQ
-   priv->freq_transition.notifier_call = cpufreq_transition;
-   ret = cpufreq_register_notifier(&priv->freq_transition,
-   CPUFREQ_TRANSITION_NOTIFIER);
-   if (ret) {
-   dev_err(dev, "failed to register cpufreq notifier\n");
-   priv->freq_transition.notifier_call = NULL;
-   goto init_failed;
-   }
-#endif
-
if (of_property_read_u32(node, "max-bandwidth", &priv->max_bandwidth))
priv->max_bandwidth = TILCDC_DEFAULT_MAX_BANDWIDTH;
 
@@ -361,6 +350,17 @@ static int tilcdc_init(struct drm_driver *ddrv, struct 
device *dev)
}
modeset_init(ddev);
 
+#ifdef CONFIG_CPU_FREQ
+   priv->freq_transition.notifier_call = cpufreq_transition;
+   ret = cpufreq_register_notifier(&priv->freq_transition,
+   CPUFREQ_TRANSITION_NOTIFIER);
+   if (ret) {
+   dev_err(dev, "failed to register cpufreq notifier\n");
+   priv->freq_transition.notifier_call = NULL;
+   goto init_failed;
+   }
+#endif
+
if (priv->is_componentized) {
ret = component_bind_all(dev, ddev);
if (ret < 0)
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[GIT PULL] tilcdc changes for 4.22

2019-01-07 Thread Jyri Sarha
Hi Dave,
Please pull this drm/tilcdc patch for Linux v4.22.

Best regards and thanks,
Jyri


The following changes since commit 8fe28cb58bcb235034b64cbbb7550a8a43fd88be:

  Linux 4.20 (2018-12-23 15:55:59 -0800)

are available in the Git repository at:

  https://github.com/jsarha/linux tags/tilcdc-4.22

for you to fetch changes up to 432973fd3a20102840d5f7e61af9f1a03c217a4c:

  drm/tilcdc: Register cpufreq notifier after we have initialized crtc
(2019-01-04 18:01:58 +0200)


tilcdc pull request for Linux v4.22


Jyri Sarha (1):
  drm/tilcdc: Register cpufreq notifier after we have initialized crtc

 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RESEND] drm/i2c: tda998x: Reset the I2S_FORMAT (Page0, Reg 0xfc) to it's default

2019-02-22 Thread Jyri Sarha
On 22/02/2019 18:40, Russell King - ARM Linux admin wrote:
> On Fri, Feb 22, 2019 at 03:27:43PM +, Russell King - ARM Linux admin 
> wrote:
>> On Fri, Feb 22, 2019 at 05:20:15PM +0200, Peter Ujfalusi wrote:
>>> Hi Russell,
>>>
>>> On 22/02/2019 16.35, Russell King - ARM Linux admin wrote:
 It would also be good to know what Fs value(s) BBB uses, and what
 sample sizes you have tested.
>>>
>>> On BBB McASP is the clock master and as I recall I have tested 44.1, 48
>>> KHz at least with 16 and 24 bits.
>>

Peter, I doubt you you were able to natively play 24bit 48kHz stereo, or
anything at 44.1kHz. Did you have ALSA plug -plugin configured?

BBB has 24.576MHz McASP mclk, which divides nicely by 48kHz to 512 clock
cycles / sample. 512 is divisible by 32 (= 16-bit stereo) and 64 (=
32-bit stereo), but not by 48 e.g. 24-bit stereo.

That is why I originally insisted in allowing 32-bit sample-format in
HDMI-codec (that is used in tda998x) and simply marking in struct
snd_soc_dai_driver that there is only 24 significant bits per a sample.

The other alternative would have been using set_bclk_ratio(), but it was
a quite new thing back then and had even less support in the drivers
than the currently.

>> Sorry, I wasn't clear enough... is the bus clocked at 32Fs for 16bit
>> samples and 64Fs for 24bit samples, or is it 64Fs for both?
> 

It is 32Fs for 16-bit and 64Fs for 32-bit, but 24-bit format is not
supported as such.

> To be clear, the reason I'm asking for this information is that
> Sven Van Asbroeck is trying to use TDA998x, and he has a problem with
> the current implementation that adjusts CTS_N_M and CTS_N_K parameters
> according to the _sample_ size.
> 
> This appears to be wrong, these settings should be set according to
> the BCLK ratio (Fs multiplier) and not the sample size.
> 
> If you say that the existing code works for you, but your device
> always produces a bclk at 64fs, then we have a problem - it means
> that to add support for Sven's platform, we're probably going to end
> up causing a regression for your platform.
> 
> The next issue is with snd_soc_dai_set_bclk_ratio().  Today, no one
> calls that function, so none of the DAI .set_bclk_ratio
> implementations are used (and probably completely untested.)  If your
> CPU DAI changes the bclk ratio depending on the sample size, I will
> need something to call that function at the appropriate time to set
> the clocking ratio.
> 
> I suspect most codecs don't care about it, but TDA998x does, because
> it _looks_ like it uses the BCLK to generate the CTS value to be
> passed to the HDMI sink.  Since CTS = f(tmds) * N / (128 * fs),
> using BCLK to derive the CTS value requires TDA998x to know the
> BCLK ratio.
> 
> So, knowing this information ahead of time is very advantageous.
> 

Sound to me that .set_bclk_ratio() support should be added to tda998x
(and HDMI-codec), but with the default behaviour that assumes the
bclk-ratio to be 2*sample-width if .set_bclk_ratio() is not called.
bcm2835-i2s codec driver appears to already implement .set_bclk_ratio()
like that.

Or am I missing something?

Best regards,
Jyri

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 0/4] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-02-25 Thread Jyri Sarha
- The bus_flags patch is important for DRM masters that rely on those, but
  the chage is in no way dependend on HDMI-audio support.
- The output mode patch is needed for HDMI-audio to work.
- The HDMI-audio implementation supports only i2s-mode.
- I do not know if the pixel clock unit change has any effect on the actual
  functionality. 

Jyri Sarha (3):
  drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  drm/bridge: sii902x: Implement HDMI audio support
  drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

Tomi Valkeinen (1):
  drm/bridge: sii902x: add input_bus_flags

 .../bindings/display/bridge/sii902x.txt   |  24 +
 drivers/gpu/drm/bridge/sii902x.c  | 475 +-
 include/dt-bindings/sound/sii902x-audio.h |  11 +
 3 files changed, 503 insertions(+), 7 deletions(-)
 create mode 100644 include/dt-bindings/sound/sii902x-audio.h

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 1/4] drm/bridge: sii902x: add input_bus_flags

2019-02-25 Thread Jyri Sarha
From: Tomi Valkeinen 

The driver always sets InputBusFmt:EDGE to 0 (falling edge).

Add drm_bridge_timings's input_bus_flags to reflect that the bridge
samples on falling edges.

Signed-off-by: Tomi Valkeinen 
Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/sii902x.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index bfa902013aa4..1afa000141d5 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -459,6 +459,12 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core 
*mux, u32 chan_id)
return 0;
 }
 
+static const struct drm_bridge_timings default_sii902x_timings = {
+   .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_DE_HIGH,
+};
+
 static int sii902x_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -529,6 +535,7 @@ static int sii902x_probe(struct i2c_client *client,
 
sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
+   sii902x->bridge.timings = &default_sii902x_timings;
drm_bridge_add(&sii902x->bridge);
 
i2c_set_clientdata(client, sii902x);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 3/4] drm/bridge: sii902x: Implement HDMI audio support

2019-02-25 Thread Jyri Sarha
Implement HDMI audio support by using ASoC HDMI codec. The commit
implements the necessary callbacks and configuration for the HDMI
codec and registers a virtual platform device for the codec to attach.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/bridge/sii902x.txt   |  24 +
 drivers/gpu/drm/bridge/sii902x.c  | 456 +-
 include/dt-bindings/sound/sii902x-audio.h |  11 +
 3 files changed, 485 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/sound/sii902x-audio.h

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index 72d2dc6c3e6b..a1cff91e4e84 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -8,6 +8,21 @@ Optional properties:
- interrupts: describe the interrupt line used to inform the host 
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
+   - i2s-fifo-routing: Array of exactly 4 integers indicating i2s
+ pins for audio fifo routing. First integer defines routing to
+ fifo 0 and second to fifo 1, etc. Integers can be filled with
+ definitions from: include/dt-bindings/sound/sii902x-audio.h
+ The available definitions are:
+ - ENABLE_BIT: enable this audio fifo
+ - CONNECT_SD#: route audio input from SD0, SD1, SD2, or SD3 i2s
+data input pin
+ - LEFT_RIGHT_SWAP_BIT: swap i2s input channels for this fifo
+ I2S HDMI audio is configured only if this property is found.
+   - clocks: describes SII902x MCLK input. MCLK is used to produce
+ HDMI audio CTS values. This property is required if
+ "i2s-fifo-routing"-property is present. This property follows
+ Documentation/devicetree/bindings/clock/clock-bindings.txt
+ consumer binding.
 
 Optional subnodes:
- video input: this subnode can contain a video input port node
@@ -21,6 +36,15 @@ Example:
compatible = "sil,sii9022";
reg = <0x39>;
reset-gpios = <&pioA 1 0>;
+
+   i2s-fifo-routing = <
+   (ENABLE_BIT|CONNECT_SD0)
+   0
+   0
+   0
+   >;
+   clocks = <&mclk>;
+
ports {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 0e21fa419d27..f296a33c57c7 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -27,12 +27,16 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #define SII902X_TPI_VIDEO_DATA 0x0
 
 #define SII902X_TPI_PIXEL_REPETITION   0x8
@@ -74,6 +78,77 @@
 #define SII902X_AVI_POWER_STATE_MSKGENMASK(1, 0)
 #define SII902X_AVI_POWER_STATE_D(l)   ((l) & 
SII902X_AVI_POWER_STATE_MSK)
 
+/* Audio  */
+#define SII902X_TPI_I2S_ENABLE_MAPPING_REG 0x1f
+#define SII902X_TPI_I2S_CONFIG_FIFO0   (0 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO1   (1 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO2   (2 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO3   (3 << 0)
+#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP(1 << 2)
+#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE(1 << 3)
+#define SII902X_TPI_I2S_SELECT_SD0 (0 << 4)
+#define SII902X_TPI_I2S_SELECT_SD1 (1 << 4)
+#define SII902X_TPI_I2S_SELECT_SD2 (2 << 4)
+#define SII902X_TPI_I2S_SELECT_SD3 (3 << 4)
+#define SII902X_TPI_I2S_FIFO_ENABLE(1 << 7)
+
+#define SII902X_TPI_I2S_INPUT_CONFIG_REG   0x20
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES(0 << 0)
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO (1 << 0)
+#define SII902X_TPI_I2S_SD_DIRECTION_MSB_FIRST (0 << 1)
+#define SII902X_TPI_I2S_SD_DIRECTION_LSB_FIRST (1 << 1)
+#define SII902X_TPI_I2S_SD_JUSTIFY_LEFT(0 << 2)
+#define SII902X_TPI_I2S_SD_JUSTIFY_RIGHT   (1 << 2)
+#define SII902X_TPI_I2S_WS_POLARITY_LOW(0 << 3)
+#define SII902X_TPI_I2S_WS_POLARITY_HIGH   (1 << 3)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_128(0 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_256(1 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_384(2 << 4)
+#d

[PATCH 4/4] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

2019-02-25 Thread Jyri Sarha
The pixel clock unit in the first two registers (0x00 and 0x01) of
sii9022 is 10kHz, not 1kHz as in struct drm_display_mode. Division by
10 fixes the issue.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index f296a33c57c7..9cf0dbb6c764 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -358,10 +358,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge 
*bridge,
struct regmap *regmap = sii902x->regmap;
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
struct hdmi_avi_infoframe frame;
+   u16 pixel_clock_10kHz = adj->clock / 10;
int ret;
 
-   buf[0] = adj->clock;
-   buf[1] = adj->clock >> 8;
+   buf[0] = pixel_clock_10kHz & 0xFF;
+   buf[1] = pixel_clock_10kHz >> 8;
buf[2] = adj->vrefresh;
buf[3] = 0x00;
buf[4] = adj->hdisplay;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH 2/4] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-02-25 Thread Jyri Sarha
Set output mode to HDMI or DVI according to EDID HDMI signature.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/sii902x.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1afa000141d5..0e21fa419d27 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -181,11 +181,15 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
struct sii902x *sii902x = connector_to_sii902x(connector);
u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
struct edid *edid;
+   u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
int num = 0, ret;
 
edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
drm_connector_update_edid_property(connector, edid);
if (edid) {
+   if (drm_detect_hdmi_monitor(edid))
+   output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
+
num = drm_add_edid_modes(connector, edid);
kfree(edid);
}
@@ -195,6 +199,11 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
if (ret)
return ret;
 
+   ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
+SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
+   if (ret)
+   return ret;
+
return num;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH RFC 1/3] drm/i2c: tda998x: implement different I2S flavours

2019-02-25 Thread Jyri Sarha
On 22/02/2019 23:27, Russell King wrote:
> Add support for the left and right justified I2S formats as well as the
> more tranditional "Philips" I2S format.
> 
> Signed-off-by: Russell King 

I do not have a spec to check REG_I2S_FORMAT bits, but at least philips
and left justified formats work on BBB (McASP does not support right
justified format). With the above conditions:

Reviewed-by: Jyri Sarha 
Tested-by: Jyri Sarha 



> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 57 
> ++-
>  include/drm/i2c/tda998x.h | 11 +---
>  2 files changed, 47 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
> b/drivers/gpu/drm/i2c/tda998x_drv.c
> index a7c39f39793f..645d884fb9e8 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -242,7 +242,9 @@ struct tda998x_priv {
>  # define HVF_CNTRL_1_SEMI_PLANAR  (1 << 6)
>  #define REG_RPT_CNTRL REG(0x00, 0xf0) /* write */
>  #define REG_I2S_FORMATREG(0x00, 0xfc) /* read/write */
> -# define I2S_FORMAT(x)(((x) & 3) << 0)
> +# define I2S_FORMAT_PHILIPS   (0 << 0)
> +# define I2S_FORMAT_LEFT_J(2 << 0)
> +# define I2S_FORMAT_RIGHT_J   (3 << 0)
>  #define REG_AIP_CLKSELREG(0x00, 0xfd) /* write */
>  # define AIP_CLKSEL_AIP_SPDIF  (0 << 3)
>  # define AIP_CLKSEL_AIP_I2S(1 << 3)
> @@ -872,14 +874,14 @@ static int
>  tda998x_configure_audio(struct tda998x_priv *priv,
>   struct tda998x_audio_params *params)
>  {
> - u8 buf[6], clksel_aip, clksel_fs, cts_n, adiv;
> + u8 buf[6], clksel_aip, clksel_fs, cts_n, adiv, i2s_fmt;
>   u32 n;
>  
>   /* Enable audio ports */
>   reg_write(priv, REG_ENA_AP, params->config);
>  
>   /* Set audio input source */
> - switch (params->format) {
> + switch (params->format & AFMT_MASK) {
>   case AFMT_SPDIF:
>   reg_write(priv, REG_ENA_ACLK, 0);
>   reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_SPDIF);
> @@ -907,6 +909,19 @@ tda998x_configure_audio(struct tda998x_priv *priv,
>   cts_n = CTS_N_M(3) | CTS_N_K(3);
>   break;
>   }
> +
> + switch (params->format & AFMT_I2S_MASK) {
> + case AFMT_I2S_LEFT_J:
> + i2s_fmt = I2S_FORMAT_LEFT_J;
> + break;
> + case AFMT_I2S_RIGHT_J:
> + i2s_fmt = I2S_FORMAT_RIGHT_J;
> + break;
> + default:
> + i2s_fmt = I2S_FORMAT_PHILIPS;
> + break;
> + }
> + reg_write(priv, REG_I2S_FORMAT, i2s_fmt);
>   break;
>  
>   default:
> @@ -992,23 +1007,15 @@ static int tda998x_audio_hw_params(struct device *dev, 
> void *data,
>  
>   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;
> + audio.format = AFMT_I2S | AFMT_I2S_PHILIPS;
> + break;
> + case HDMI_LEFT_J:
> + audio.format = AFMT_I2S | AFMT_I2S_LEFT_J;
> + break;
> + case HDMI_RIGHT_J:
> + audio.format = AFMT_I2S | AFMT_I2S_RIGHT_J;
>   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:
> @@ -1016,11 +1023,25 @@ static int tda998x_audio_hw_params(struct device 
> *dev, void *data,
>   return -EINVAL;
>   }
>  
> + for (i = 0; i < ARRAY_SIZE(priv->audio_port); i++)
> + if (priv->audio_port[i].format == (audio.for

Re: [PATCH RFC 3/3] drm/i2c: tda998x: add support for bclk_ratio

2019-02-25 Thread Jyri Sarha
On 22/02/2019 23:27, Russell King wrote:
> It appears that TDA998x derives the CTS value using the supplied I2S
> bit clock (BCLK) rather than 128·fs.  TDA998x uses two constants named
> m and k in the CTS generator such that we have this relationship
> between the source BCLK and the sink fs:
> 
>   128·fs_sink = BCLK·m / k
> 
> Where BCLK = bclk_ratio·fs_source.
> 
> We have been lucky up to now that all users have scaled their bclk_ratio
> to match the sample width - for example, on Beagle Bone Black, with a
> 16-bit sample width, BCLK = 32·fs, which increases to 64·fs for 32-bit
> samples.  24-bit samples are sent as 32-bit.
> 
> We are now starting to see users whose I2S blocks send at 64·fs for
> 16-bit samples, which means TDA998x now breaks.
> 
> ASoC has a snd_soc_dai_set_bclk_ratio() call available which sets the
> ratio of BCLK to the sample rate.  Implement support for this.
> 
> Signed-off-by: Russell King 

Works at least on Beaglebone-black.

Tested-by: Jyri Sarha 
Reviewed-by: Jyri Sarha 

> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 20 +---
>  include/drm/i2c/tda998x.h |  1 +
>  2 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c 
> b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 645d884fb9e8..f2d40235acf9 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -895,21 +895,26 @@ tda998x_configure_audio(struct tda998x_priv *priv,
>   reg_write(priv, REG_MUX_AP, MUX_AP_SELECT_I2S);
>   clksel_aip = AIP_CLKSEL_AIP_I2S;
>   clksel_fs = AIP_CLKSEL_FS_ACLK;
> - switch (params->sample_width) {
> + switch (params->bclk_ratio) {
>   case 16:
> + cts_n = CTS_N_M(3) | CTS_N_K(0);
> + break;
> + case 32:
>   cts_n = CTS_N_M(3) | CTS_N_K(1);
>   break;
> - case 18:
> - case 20:
> - case 24:
> + case 48:
>   cts_n = CTS_N_M(3) | CTS_N_K(2);
>   break;
> - default:
> - case 32:
> + case 64:
>   cts_n = CTS_N_M(3) | CTS_N_K(3);
>   break;
> + case 128:
> + cts_n = CTS_N_M(0) | CTS_N_K(0);
> + break;
> + default:
> + dev_err(&priv->hdmi->dev, "unsupported I2S bclk 
> ratio\n");
> + return -EINVAL;
>   }
> -
>   switch (params->format & AFMT_I2S_MASK) {
>   case AFMT_I2S_LEFT_J:
>   i2s_fmt = I2S_FORMAT_LEFT_J;
> @@ -997,6 +1002,7 @@ static int tda998x_audio_hw_params(struct device *dev, 
> void *data,
>   struct tda998x_priv *priv = dev_get_drvdata(dev);
>   int i, ret;
>   struct tda998x_audio_params audio = {
> + .bclk_ratio = daifmt->bclk_ratio,
>   .sample_width = params->sample_width,
>   .sample_rate = params->sample_rate,
>   .cea = params->cea,
> diff --git a/include/drm/i2c/tda998x.h b/include/drm/i2c/tda998x.h
> index b0864f0be017..4e0f0cd2d428 100644
> --- a/include/drm/i2c/tda998x.h
> +++ b/include/drm/i2c/tda998x.h
> @@ -19,6 +19,7 @@ enum {
>  struct tda998x_audio_params {
>   u8 config;
>   u8 format;
> + u8 bclk_ratio;
>   unsigned sample_width;
>   unsigned sample_rate;
>   struct hdmi_audio_infoframe cea;
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 3/4] drm/bridge: sii902x: Implement HDMI audio support

2019-02-25 Thread Jyri Sarha
On 25/02/2019 15:57, Andrzej Hajda wrote:
> On 25.02.2019 12:23, Jyri Sarha wrote:
>> Implement HDMI audio support by using ASoC HDMI codec. The commit
>> implements the necessary callbacks and configuration for the HDMI
>> codec and registers a virtual platform device for the codec to attach.
>>
>> Signed-off-by: Jyri Sarha 
>> ---
>>  .../bindings/display/bridge/sii902x.txt   |  24 +
>>  drivers/gpu/drm/bridge/sii902x.c  | 456 +-
>>  include/dt-bindings/sound/sii902x-audio.h |  11 +
>>  3 files changed, 485 insertions(+), 6 deletions(-)
>>  create mode 100644 include/dt-bindings/sound/sii902x-audio.h
>>
>> diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
>> b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>> index 72d2dc6c3e6b..a1cff91e4e84 100644
>> --- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>> +++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>> @@ -8,6 +8,21 @@ Optional properties:
>>  - interrupts: describe the interrupt line used to inform the host 
>>about hotplug events.
>>  - reset-gpios: OF device-tree gpio specification for RST_N pin.
>> +- i2s-fifo-routing: Array of exactly 4 integers indicating i2s
>> +  pins for audio fifo routing. First integer defines routing to
>> +  fifo 0 and second to fifo 1, etc. Integers can be filled with
>> +  definitions from: include/dt-bindings/sound/sii902x-audio.h
>> +  The available definitions are:
>> +  - ENABLE_BIT: enable this audio fifo
>> +  - CONNECT_SD#: route audio input from SD0, SD1, SD2, or SD3 i2s
>> + data input pin
>> +  - LEFT_RIGHT_SWAP_BIT: swap i2s input channels for this fifo
>> +  I2S HDMI audio is configured only if this property is found.
>> +- clocks: describes SII902x MCLK input. MCLK is used to produce
>> +  HDMI audio CTS values. This property is required if
>> +  "i2s-fifo-routing"-property is present. This property follows
>> +  Documentation/devicetree/bindings/clock/clock-bindings.txt
>> +  consumer binding.
> 
> 
> I wonder if it wouldn't be better to use of_graph to show connections
> between audio producer (A/V media processor) and the transmitter,
> i2s-fifo-routing value should be then derived from these bindings.
> 
> 

I do not think anybody will come up with a configuration where there
would be more than one audio producer. While there is multiple i2s input
data pins, there is only one i2s-clock-pin. The multiple pins are there
to provide 2, 4, 6, or 8 channel HDMI audio (two channels per wire), not
for multiple audio producers.

AFAIK, no driver describes i2s-wire one by one with of_graphs. However,
there are different kind of ASoC card-drivers pulling the different
ASoC-components, but the codec driver (like the sii902x with configured
audio would be) do not take part in such binding.

Then again we may never need the flexibility provided here. Maybe we
could survive with just the number of wires connected. That would
require that all HW designers will have decency to connect the i2s-wires
in the right order without skipping or crossing the wires.

Adding devicet...@vger.kernel.org to cc, since I forgot it from the
original recipient list.

>>  
>>  Optional subnodes:
>>  - video input: this subnode can contain a video input port node
>> @@ -21,6 +36,15 @@ Example:
>>  compatible = "sil,sii9022";
>>  reg = <0x39>;
>>  reset-gpios = <&pioA 1 0>;
>> +
>> +i2s-fifo-routing = <
>> +(ENABLE_BIT|CONNECT_SD0)
>> +0
>> +0
>> +0
>> +>;
>> +clocks = <&mclk>;
>> +
>>  ports {
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>> diff --git a/drivers/gpu/drm/bridge/sii902x.c 
>> b/drivers/gpu/drm/bridge/sii902x.c
>> index 0e21fa419d27..f296a33c57c7 100644
>> --- a/drivers/gpu/drm/bridge/sii902x.c
>> +++ b/drivers/gpu/drm/bridge/sii902x.c
>> @@ -27,12 +27,16 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #include 
>>  #include 
>>  #include 
>>  #include 
>>  
>> +#include 
>> +#include 
>> +
>>  #define SII902X_TPI_VIDEO_DATA  0x0
>>  
>>  #define SII902X_TPI_PIXEL_REPETITION0x8
>> @@ -74,6 +78,77 @@
>>

[PATCH v2 3/5] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

2019-02-27 Thread Jyri Sarha
The pixel clock unit in the first two registers (0x00 and 0x01) of
sii9022 is 10kHz, not 1kHz as in struct drm_display_mode. Division by
10 fixes the issue.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 0e21fa419d27..1e91ed72 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -248,10 +248,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge 
*bridge,
struct regmap *regmap = sii902x->regmap;
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
struct hdmi_avi_infoframe frame;
+   u16 pixel_clock_10kHz = adj->clock / 10;
int ret;
 
-   buf[0] = adj->clock;
-   buf[1] = adj->clock >> 8;
+   buf[0] = pixel_clock_10kHz & 0xFF;
+   buf[1] = pixel_clock_10kHz >> 8;
buf[2] = adj->vrefresh;
buf[3] = 0x00;
buf[4] = adj->hdisplay;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 4/5] drm/bridge: sii902x: Select I2C_MUX

2019-02-27 Thread Jyri Sarha
"drm/bridge/sii902x: Fix EDID readback"-commit added a dependency to
I2C_MUX, but not indicate it in the Kconfig entry. Fix it by selecting
I2C_MUX for DRM_SII902X config option.

Fixes: 88664675239 ("drm/bridge/sii902x: Fix EDID readback")
Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index fb0b37918382..a6f6ff8f06b3 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -95,6 +95,7 @@ config DRM_SII902X
depends on OF
select DRM_KMS_HELPER
select REGMAP_I2C
+   select I2C_MUX
---help---
  Silicon Image sii902x bridge chip driver.
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 5/5] drm/bridge: sii902x: Implement HDMI audio support

2019-02-27 Thread Jyri Sarha
Implement HDMI audio support by using ASoC HDMI codec. The commit
implements the necessary callbacks and configuration for the HDMI
codec and registers a virtual platform device for the codec to attach.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/bridge/sii902x.txt   |  36 +-
 drivers/gpu/drm/bridge/sii902x.c  | 453 +-
 include/dt-bindings/sound/sii902x-audio.h |  11 +
 3 files changed, 493 insertions(+), 7 deletions(-)
 create mode 100644 include/dt-bindings/sound/sii902x-audio.h

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index 72d2dc6c3e6b..647b2fd84db9 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -5,9 +5,32 @@ Required properties:
- reg: i2c address of the bridge
 
 Optional properties:
-   - interrupts: describe the interrupt line used to inform the host 
+   - interrupts: describe the interrupt line used to inform the host
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
+   - i2s-fifo-routing: Array of exactly 4 integers indicating i2s
+ pins for audio fifo routing. First integer defines routing to
+ fifo 0 and second to fifo 1, etc. Integers can be filled with
+ definitions from: include/dt-bindings/sound/sii902x-audio.h
+ The available definitions are:
+ - ENABLE_BIT: enable this audio fifo
+ - CONNECT_SD#: route audio input from SD0, SD1, SD2, or SD3 i2s
+data input pin
+ - LEFT_RIGHT_SWAP_BIT: swap i2s input channels for this fifo
+ I2S HDMI audio is configured only if this property is found.
+   - clocks: phandle mclk
+   - clock-names: "mclk"
+   Describes SII902x MCLK input. MCLK is used to produce
+   HDMI audio CTS values. This property is required if
+   "i2s-fifo-routing"-property is present. This property follows
+   Documentation/devicetree/bindings/clock/clock-bindings.txt
+   consumer binding.
+   - #sound-dai-cells = <0>: ASoC codec dai available for simple-card
+   If audio properties are present sii902x provides an ASoC
+   codec component driver that can be used by other ASoC
+   components like simple-card. See binding document for
+   details:
+   Documentation/devicetree/bindings/sound/simple-card.txt
 
 Optional subnodes:
- video input: this subnode can contain a video input port node
@@ -21,6 +44,17 @@ Example:
compatible = "sil,sii9022";
reg = <0x39>;
reset-gpios = <&pioA 1 0>;
+
+   #sound-dai-cells = <0>;
+   i2s-fifo-routing = <
+   (ENABLE_BIT|CONNECT_SD0)
+   0
+   0
+   0
+   >;
+   clocks = <&mclk>;
+   clock-names = "mclk";
+
ports {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1e91ed72..2be27bc54fb5 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -27,12 +27,16 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #define SII902X_TPI_VIDEO_DATA 0x0
 
 #define SII902X_TPI_PIXEL_REPETITION   0x8
@@ -74,6 +78,77 @@
 #define SII902X_AVI_POWER_STATE_MSKGENMASK(1, 0)
 #define SII902X_AVI_POWER_STATE_D(l)   ((l) & 
SII902X_AVI_POWER_STATE_MSK)
 
+/* Audio  */
+#define SII902X_TPI_I2S_ENABLE_MAPPING_REG 0x1f
+#define SII902X_TPI_I2S_CONFIG_FIFO0   (0 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO1   (1 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO2   (2 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO3   (3 << 0)
+#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP(1 << 2)
+#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE(1 << 3)
+#define SII902X_TPI_I2S_SELECT_SD0 (0 << 4)
+#define SII902X_TPI_I2S_SELECT_SD1 (1 << 4)
+#define SII902X_TPI_I2S_SELECT_SD2 (2 << 4)
+#define SII902X_TPI_I2S_SELECT_SD3 (3 << 4)
+#define SII902X_TPI_I2S_FIFO_ENABLE(1 << 7)
+
+#define SII902X_TPI_I2S_INPUT_CONFIG_REG   0x20
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES(0 << 0)
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO (1 <

[PATCH v2 1/5] drm/bridge: sii902x: add input_bus_flags

2019-02-27 Thread Jyri Sarha
From: Tomi Valkeinen 

The driver always sets InputBusFmt:EDGE to 0 (falling edge).

Add drm_bridge_timings's input_bus_flags to reflect that the bridge
samples on falling edges.

Signed-off-by: Tomi Valkeinen 
Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index bfa902013aa4..1afa000141d5 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -459,6 +459,12 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core 
*mux, u32 chan_id)
return 0;
 }
 
+static const struct drm_bridge_timings default_sii902x_timings = {
+   .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_DE_HIGH,
+};
+
 static int sii902x_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -529,6 +535,7 @@ static int sii902x_probe(struct i2c_client *client,
 
sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
+   sii902x->bridge.timings = &default_sii902x_timings;
drm_bridge_add(&sii902x->bridge);
 
i2c_set_clientdata(client, sii902x);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 2/5] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-02-27 Thread Jyri Sarha
Set output mode to HDMI or DVI according to EDID HDMI signature.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1afa000141d5..0e21fa419d27 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -181,11 +181,15 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
struct sii902x *sii902x = connector_to_sii902x(connector);
u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
struct edid *edid;
+   u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
int num = 0, ret;
 
edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
drm_connector_update_edid_property(connector, edid);
if (edid) {
+   if (drm_detect_hdmi_monitor(edid))
+   output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
+
num = drm_add_edid_modes(connector, edid);
kfree(edid);
}
@@ -195,6 +199,11 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
if (ret)
return ret;
 
+   ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
+SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
+   if (ret)
+   return ret;
+
return num;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 0/5] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-02-27 Thread Jyri Sarha
Changes since first version:
- Moved reviewed patches to front:
  - drm/bridge: sii902x: add input_bus_flags
  - drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  - drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
- Added a new fix:
  - drm/bridge: sii902x: Select I2C_MUX
- Applied some review suggestions to
  - drm/bridge: sii902x: Implement HDMI audio support
- use clock-names property to name mclk
- move comment describing added mutex to struct sii902x and improve it
- cleanup sii902x_mute()
- cleanup sii902x_select_mclk_div()
- fix condition for checking ENABLE_BIT from i2s_fifo_routing in
  sii902x_audio_codec_init()

Still to do

- Agree on i2s wires to HDMI audio fifo routing in dts. 

  The current scheme is quite straight forward, but there is maybe
  there is even more straight forward solutions like:

  audio-fifo-enable = <1 1 1 1>;
  audio-i2s-pin-to-fifo = <0 1 2 3>;

  Meaning that all fifos are enabled and SD0 is routed to fifo 0, SD1
  to fifo 1, etc. I am not sure if the channel swap functionality
  should show in dts binding.

Jyri Sarha (4):
  drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
  drm/bridge: sii902x: Select I2C_MUX
  drm/bridge: sii902x: Implement HDMI audio support

Tomi Valkeinen (1):
  drm/bridge: sii902x: add input_bus_flags

 .../bindings/display/bridge/sii902x.txt   |  36 +-
 drivers/gpu/drm/bridge/Kconfig|   1 +
 drivers/gpu/drm/bridge/sii902x.c  | 472 +-
 include/dt-bindings/sound/sii902x-audio.h |  11 +
 4 files changed, 512 insertions(+), 8 deletions(-)
 create mode 100644 include/dt-bindings/sound/sii902x-audio.h

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[tiL4.19-AD PATCH 2/2] drm/tilcdc: Remove obsolete crtc_mode_valid() hack

2019-02-28 Thread Jyri Sarha
Earlier there were no mode_valid() helper for crtc and tilcdc had a
hack to over come this limitation. But now the mode_valid() helper is
there (has been since v4.13), so it is about time to get rid of that
hack.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 28 +++-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.h  |  2 -
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 88 +++-
 drivers/gpu/drm/tilcdc/tilcdc_external.h |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_panel.c|  9 ---
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c   |  9 ---
 7 files changed, 19 insertions(+), 119 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index a8ae064f52bb..f9600f2ad660 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -659,9 +659,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state)
 {
-   struct drm_display_mode *mode = &state->mode;
-   int ret;
-
/* If we are not active we don't care */
if (!state->active)
return 0;
@@ -673,12 +670,6 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
return -EINVAL;
}
 
-   ret = tilcdc_crtc_mode_valid(crtc, mode);
-   if (ret) {
-   dev_dbg(crtc->dev->dev, "Mode \"%s\" not valid", mode->name);
-   return -EINVAL;
-   }
-
return 0;
 }
 
@@ -730,13 +721,6 @@ static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
.disable_vblank = tilcdc_crtc_disable_vblank,
 };
 
-static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
-   .mode_fixup = tilcdc_crtc_mode_fixup,
-   .atomic_check   = tilcdc_crtc_atomic_check,
-   .atomic_enable  = tilcdc_crtc_atomic_enable,
-   .atomic_disable = tilcdc_crtc_atomic_disable,
-};
-
 int tilcdc_crtc_max_width(struct drm_crtc *crtc)
 {
struct drm_device *dev = crtc->dev;
@@ -751,7 +735,9 @@ int tilcdc_crtc_max_width(struct drm_crtc *crtc)
return max_width;
 }
 
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode 
*mode)
+static enum drm_mode_status
+tilcdc_crtc_mode_valid(struct drm_crtc *crtc,
+  const struct drm_display_mode *mode)
 {
struct tilcdc_drm_private *priv = crtc->dev->dev_private;
unsigned int bandwidth;
@@ -839,6 +825,14 @@ int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct 
drm_display_mode *mode)
return MODE_OK;
 }
 
+static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
+   .mode_valid = tilcdc_crtc_mode_valid,
+   .mode_fixup = tilcdc_crtc_mode_fixup,
+   .atomic_check   = tilcdc_crtc_atomic_check,
+   .atomic_enable  = tilcdc_crtc_atomic_enable,
+   .atomic_disable = tilcdc_crtc_atomic_disable,
+};
+
 void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info)
 {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3dac08b24140..36fd05b145a4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -192,7 +192,6 @@ static void tilcdc_fini(struct drm_device *dev)
drm_kms_helper_poll_fini(dev);
drm_irq_uninstall(dev);
drm_mode_config_cleanup(dev);
-   tilcdc_remove_external_device(dev);
 
 #ifdef CONFIG_CPU_FREQ
if (priv->freq_transition.notifier_call)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 62cea5ff5558..3298f39d320e 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -86,7 +86,6 @@ struct tilcdc_drm_private {
 
struct drm_encoder *external_encoder;
struct drm_connector *external_connector;
-   const struct drm_connector_helper_funcs *connector_funcs;
 
bool is_registered;
bool is_componentized;
@@ -168,7 +167,6 @@ void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info);
 void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
bool simulate_vesa_sync);
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode 
*mode);
 int tilcdc_crtc_max_width(struct drm_crtc *crtc);
 void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
 int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c 
b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index b4eaf9bc87f8..54adf05f44e6 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c

[tiL4.19-AD PATCH 0/2] drm/tilcdc: a cleanup and a fix

2019-02-28 Thread Jyri Sarha
Jyri Sarha (2):
  drm/tilcdc: Check drm_fb_cma_get_gem_obj() return value
  drm/tilcdc: Remove obsolete crtc_mode_valid() hack

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 30 
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.h  |  2 -
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 88 +++-
 drivers/gpu/drm/tilcdc/tilcdc_external.h |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_panel.c|  9 ---
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c   |  9 ---
 7 files changed, 21 insertions(+), 119 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[tiL4.19-AD PATCH 1/2] drm/tilcdc: Check drm_fb_cma_get_gem_obj() return value

2019-02-28 Thread Jyri Sarha
drm_fb_cma_get_gem_obj() may return NULL. The return value needs to be
checked before dereferencing the returned pointer.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 1067e702c22c..a8ae064f52bb 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -75,6 +75,8 @@ static void set_scanout(struct drm_crtc *crtc, struct 
drm_framebuffer *fb)
u64 dma_base_and_ceiling;
 
gem = drm_fb_cma_get_gem_obj(fb, 0);
+   if (WARN_ON(!gem))
+   return;
 
start = gem->paddr + fb->offsets[0] +
crtc->y * fb->pitches[0] +
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v2 2/5] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-03-04 Thread Jyri Sarha
On 04/03/2019 14:52, Laurent Pinchart wrote:
> Hi Jyri,
> 
> Thank you for the patch.
> On Wed, Feb 27, 2019 at 11:54:20PM +0200, Jyri Sarha wrote:
>> Set output mode to HDMI or DVI according to EDID HDMI signature.
>>
>> Signed-off-by: Jyri Sarha 
>> Reviewed-by: Andrzej Hajda 
>> ---
>>  drivers/gpu/drm/bridge/sii902x.c | 9 +
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/bridge/sii902x.c 
>> b/drivers/gpu/drm/bridge/sii902x.c
>> index 1afa000141d5..0e21fa419d27 100644
>> --- a/drivers/gpu/drm/bridge/sii902x.c
>> +++ b/drivers/gpu/drm/bridge/sii902x.c
>> @@ -181,11 +181,15 @@ static int sii902x_get_modes(struct drm_connector 
>> *connector)
>>  struct sii902x *sii902x = connector_to_sii902x(connector);
>>  u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
>>  struct edid *edid;
>> +u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
> 
> I'd move this one line up, but that's certainly a matter of taste :-)

I usually sort the local variables by length too. I wonder why I did not
do it this time... I'll fix it :).

>>  int num = 0, ret;
>>  
>>  edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
>>  drm_connector_update_edid_property(connector, edid);
>>  if (edid) {
>> +if (drm_detect_hdmi_monitor(edid))
>> +output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
>> +
>>  num = drm_add_edid_modes(connector, edid);
>>  kfree(edid);
>>  }
>> @@ -195,6 +199,11 @@ static int sii902x_get_modes(struct drm_connector 
>> *connector)
>>  if (ret)
>>  return ret;
>>  
>> +ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
>> + SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
>> +if (ret)
>> +return ret;
>> +
> 
> Is this the right place to update the register, shouldn't this be done
> in sii902x_bridge_enable() instead ? I could foresee cases where the
> chip could be powered down between get_modes() and enable(), losing its
> internal state.
> 

I have a spec (unfortunately I can not share it) that describes the
sequence of handling a hot plug event on sii9022. There it is said that
the HDMI mode, if HDMI signature is found, should be set at the same
time while releasing the DCC access by setting SII902X_SYS_CTRL_DATA
bits #1 and #2 to zero.

However, I did not dare to change sii902x_i2c_bypass_deselect()
function, so I set the HDMI mode right after the DCC pass trough mode is
disabled.

Having it there is logical too, since the HDMI/DVI-mode should not
change without a hot plug event. In practice sii9022 does not appear to
be too picky when the bit is set.

>>  return num;
>>  }
>>  
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v2 0/5] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-03-04 Thread Jyri Sarha
On 04/03/2019 14:42, Laurent Pinchart wrote:
> Hi Jyri,
> 
> On Wed, Feb 27, 2019 at 11:54:18PM +0200, Jyri Sarha wrote:
>> Changes since first version:
>> - Moved reviewed patches to front:
>>   - drm/bridge: sii902x: add input_bus_flags
>>   - drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
>>   - drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
>> - Added a new fix:
>>   - drm/bridge: sii902x: Select I2C_MUX
>> - Applied some review suggestions to
>>   - drm/bridge: sii902x: Implement HDMI audio support
>> - use clock-names property to name mclk
>> - move comment describing added mutex to struct sii902x and improve it
>> - cleanup sii902x_mute()
>> - cleanup sii902x_select_mclk_div()
>> - fix condition for checking ENABLE_BIT from i2s_fifo_routing in
>>   sii902x_audio_codec_init()
>>
>> Still to do
>>
>> - Agree on i2s wires to HDMI audio fifo routing in dts. 
>>
>>   The current scheme is quite straight forward, but there is maybe
>>   there is even more straight forward solutions like:
>>
>>   audio-fifo-enable = <1 1 1 1>;
>>   audio-i2s-pin-to-fifo = <0 1 2 3>;
>>
>>   Meaning that all fifos are enabled and SD0 is routed to fifo 0, SD1
>>   to fifo 1, etc. I am not sure if the channel swap functionality
>>   should show in dts binding.
> Please forgive my lack of audio knowledge, but it this a system
> description that should be encoded in DT, or a policy that should be
> handled purely in software (either fully inside the kernel or with the
> help of userspace) ?
> 

This property describes how many i2s wires are connected to sii902x and
in what order, so I think it belongs to DTS.

One might of course wonder why anybody would put the i2s wires to any
other order than 0 <-> 0, 1 <-> 1, 2 <-> 2, and 3 <-> 3, but then a
again I've seen weirder board designs.

Best regards,
Jyri


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [tiL4.19-AD PATCH 1/2] drm/tilcdc: Check drm_fb_cma_get_gem_obj() return value

2019-03-05 Thread Jyri Sarha
On 05/03/2019 17:43, Laurent Pinchart wrote:
> Hi Jyri,
> 
> Thank you for the patch.
> 
> On Thu, Feb 28, 2019 at 01:18:50PM +0200, Jyri Sarha wrote:
>> drm_fb_cma_get_gem_obj() may return NULL. The return value needs to be
>> checked before dereferencing the returned pointer.
>>
>> Signed-off-by: Jyri Sarha 
>> ---
>>  drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
>> b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
>> index 1067e702c22c..a8ae064f52bb 100644
>> --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
>> +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
>> @@ -75,6 +75,8 @@ static void set_scanout(struct drm_crtc *crtc, struct 
>> drm_framebuffer *fb)
>>  u64 dma_base_and_ceiling;
>>  
>>  gem = drm_fb_cma_get_gem_obj(fb, 0);
>> +if (WARN_ON(!gem))
>> +return;
> 
> But this should not happen, right ? Don't we have the required checks in
> place to ensure there will always be a valid GEM object available here ?
> 

The patch is trying to make clockwork - a static analysis tool - happy.
Should have mentioned that in the patch. But the fact that static
clockwork complains about this suggests that either there is no such
check elsewhere, or clockwork does not understand it.

>>  start = gem->paddr + fb->offsets[0] +
>>  crtc->y * fb->pitches[0] +
> 

Best regards,
Jyri



-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 1/6] drm/bridge: sii902x: add input_bus_flags

2019-03-13 Thread Jyri Sarha
From: Tomi Valkeinen 

The driver always sets InputBusFmt:EDGE to 0 (falling edge).

Add drm_bridge_timings's input_bus_flags to reflect that the bridge
samples on falling edges.

Signed-off-by: Tomi Valkeinen 
Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index bfa902013aa4..1afa000141d5 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -459,6 +459,12 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core 
*mux, u32 chan_id)
return 0;
 }
 
+static const struct drm_bridge_timings default_sii902x_timings = {
+   .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_DE_HIGH,
+};
+
 static int sii902x_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -529,6 +535,7 @@ static int sii902x_probe(struct i2c_client *client,
 
sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
+   sii902x->bridge.timings = &default_sii902x_timings;
drm_bridge_add(&sii902x->bridge);
 
i2c_set_clientdata(client, sii902x);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 2/6] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-03-13 Thread Jyri Sarha
Set output mode to HDMI or DVI according to EDID HDMI signature.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1afa000141d5..0e21fa419d27 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -181,11 +181,15 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
struct sii902x *sii902x = connector_to_sii902x(connector);
u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
struct edid *edid;
+   u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
int num = 0, ret;
 
edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
drm_connector_update_edid_property(connector, edid);
if (edid) {
+   if (drm_detect_hdmi_monitor(edid))
+   output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
+
num = drm_add_edid_modes(connector, edid);
kfree(edid);
}
@@ -195,6 +199,11 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
if (ret)
return ret;
 
+   ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
+SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
+   if (ret)
+   return ret;
+
return num;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 4/6] dt-bindings: display: sii902x: Remove trailing white space

2019-03-13 Thread Jyri Sarha
Remove trailing white space from sii902x display bridge binding.

Signed-off-by: Jyri Sarha 
---
 Documentation/devicetree/bindings/display/bridge/sii902x.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index 72d2dc6c3e6b..c4c1855ca654 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -5,7 +5,7 @@ Required properties:
- reg: i2c address of the bridge
 
 Optional properties:
-   - interrupts: describe the interrupt line used to inform the host 
+   - interrupts: describe the interrupt line used to inform the host
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 0/6] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-03-13 Thread Jyri Sarha
Changes since v2:
- split dt-binding and related header to a separate patch
- add vendor prefix to i2s-fifo-routing dt-property
- add license identifier and copyright notice to sii902x-audio.h
- sii902x_get_modes() reorder local variables
- put clk_prepare_enable() before clk_get_rate(), according to documentation
  clk_get_rate() is only valid once the clock is enabled

The three already reviewed patches are in front:
  - drm/bridge: sii902x: add input_bus_flags
  - drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  - drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

The previous review round can be found here:
https://patchwork.kernel.org/cover/10832351/

Jyri Sarha (5):
  drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
  dt-bindings: display: sii902x: Remove trailing white space
  dt-bindings: display: sii902x: Add HDMI audio bindings
  drm/bridge: sii902x: Implement HDMI audio support

Tomi Valkeinen (1):
  drm/bridge: sii902x: add input_bus_flags

 .../bindings/display/bridge/sii902x.txt   |  36 +-
 drivers/gpu/drm/bridge/sii902x.c  | 472 +-
 include/dt-bindings/sound/sii902x-audio.h |  17 +
 3 files changed, 517 insertions(+), 8 deletions(-)
 create mode 100644 include/dt-bindings/sound/sii902x-audio.h

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 3/6] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

2019-03-13 Thread Jyri Sarha
The pixel clock unit in the first two registers (0x00 and 0x01) of
sii9022 is 10kHz, not 1kHz as in struct drm_display_mode. Division by
10 fixes the issue.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 0e21fa419d27..1e91ed72 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -248,10 +248,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge 
*bridge,
struct regmap *regmap = sii902x->regmap;
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
struct hdmi_avi_infoframe frame;
+   u16 pixel_clock_10kHz = adj->clock / 10;
int ret;
 
-   buf[0] = adj->clock;
-   buf[1] = adj->clock >> 8;
+   buf[0] = pixel_clock_10kHz & 0xFF;
+   buf[1] = pixel_clock_10kHz >> 8;
buf[2] = adj->vrefresh;
buf[3] = 0x00;
buf[4] = adj->hdisplay;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v3 6/6] drm/bridge: sii902x: Implement HDMI audio support

2019-03-13 Thread Jyri Sarha
Implement HDMI audio support by using ASoC HDMI codec. The commit
implements the necessary callbacks and configuration for the HDMI
codec and registers a virtual platform device for the codec to attach.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/sii902x.c | 455 ++-
 1 file changed, 448 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1e91ed72..3f49bf24e2a3 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -27,12 +27,16 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #define SII902X_TPI_VIDEO_DATA 0x0
 
 #define SII902X_TPI_PIXEL_REPETITION   0x8
@@ -74,6 +78,77 @@
 #define SII902X_AVI_POWER_STATE_MSKGENMASK(1, 0)
 #define SII902X_AVI_POWER_STATE_D(l)   ((l) & 
SII902X_AVI_POWER_STATE_MSK)
 
+/* Audio  */
+#define SII902X_TPI_I2S_ENABLE_MAPPING_REG 0x1f
+#define SII902X_TPI_I2S_CONFIG_FIFO0   (0 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO1   (1 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO2   (2 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO3   (3 << 0)
+#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP(1 << 2)
+#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE(1 << 3)
+#define SII902X_TPI_I2S_SELECT_SD0 (0 << 4)
+#define SII902X_TPI_I2S_SELECT_SD1 (1 << 4)
+#define SII902X_TPI_I2S_SELECT_SD2 (2 << 4)
+#define SII902X_TPI_I2S_SELECT_SD3 (3 << 4)
+#define SII902X_TPI_I2S_FIFO_ENABLE(1 << 7)
+
+#define SII902X_TPI_I2S_INPUT_CONFIG_REG   0x20
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES(0 << 0)
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO (1 << 0)
+#define SII902X_TPI_I2S_SD_DIRECTION_MSB_FIRST (0 << 1)
+#define SII902X_TPI_I2S_SD_DIRECTION_LSB_FIRST (1 << 1)
+#define SII902X_TPI_I2S_SD_JUSTIFY_LEFT(0 << 2)
+#define SII902X_TPI_I2S_SD_JUSTIFY_RIGHT   (1 << 2)
+#define SII902X_TPI_I2S_WS_POLARITY_LOW(0 << 3)
+#define SII902X_TPI_I2S_WS_POLARITY_HIGH   (1 << 3)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_128(0 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_256(1 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_384(2 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_512(3 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_768(4 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1024   (5 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1152   (6 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_192(7 << 4)
+#define SII902X_TPI_I2S_SCK_EDGE_FALLING   (0 << 7)
+#define SII902X_TPI_I2S_SCK_EDGE_RISING(1 << 7)
+
+#define SII902X_TPI_I2S_STRM_HDR_BASE  0x21
+#define SII902X_TPI_I2S_STRM_HDR_SIZE  5
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE2_REG 0x26
+#define SII902X_TPI_AUDIO_CODING_STREAM_HEADER (0 << 0)
+#define SII902X_TPI_AUDIO_CODING_PCM   (1 << 0)
+#define SII902X_TPI_AUDIO_CODING_AC3   (2 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG1 (3 << 0)
+#define SII902X_TPI_AUDIO_CODING_MP3   (4 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG2 (5 << 0)
+#define SII902X_TPI_AUDIO_CODING_AAC   (6 << 0)
+#define SII902X_TPI_AUDIO_CODING_DTS   (7 << 0)
+#define SII902X_TPI_AUDIO_CODING_ATRAC (8 << 0)
+#define SII902X_TPI_AUDIO_MUTE_DISABLE (0 << 4)
+#define SII902X_TPI_AUDIO_MUTE_ENABLE  (1 << 4)
+#define SII902X_TPI_AUDIO_LAYOUT_2_CHANNELS(0 << 5)
+#define SII902X_TPI_AUDIO_LAYOUT_8_CHANNELS(1 << 5)
+#define SII902X_TPI_AUDIO_INTERFACE_DISABLE(0 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_SPDIF  (1 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_I2S(2 << 6)
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE3_REG 0x27
+#define SII902X_TPI_AUDIO_FREQ_STREAM  (0 << 3)
+#define SII902X_TPI_AUDIO_FREQ_32KHZ   (1 << 3)
+#define SII902X_TPI_AUDIO_FREQ_44KHZ   (2 << 3)
+#define SII902X_TPI_AUDIO_FREQ_48KHZ   (3 << 3)
+#define SII902X_TPI_AUDIO_FREQ_88KHZ   (4 << 3)
+#define SII902X_TPI_AUDIO_FREQ_96KHZ   (5 << 3)
+#define SII902X_TPI_AU

[PATCH v3 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-03-13 Thread Jyri Sarha
The sii902x chip family supports also HDMI audio. Add binding for
describing the necessary i2s and mclk wiring for it.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/bridge/sii902x.txt   | 34 +++
 include/dt-bindings/sound/sii902x-audio.h | 17 ++
 2 files changed, 51 insertions(+)
 create mode 100644 include/dt-bindings/sound/sii902x-audio.h

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index c4c1855ca654..977756841193 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -8,6 +8,29 @@ Optional properties:
- interrupts: describe the interrupt line used to inform the host
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
+   - sil,i2s-fifo-routing: Array of exactly 4 integers indicating i2s
+ pins for audio fifo routing. First integer defines routing to
+ fifo 0 and second to fifo 1, etc. Integers can be filled with
+ definitions from: include/dt-bindings/sound/sii902x-audio.h
+ The available definitions are:
+ - ENABLE_BIT: enable this audio fifo
+ - CONNECT_SD#: route audio input from SD0, SD1, SD2, or SD3 i2s
+data input pin
+ - LEFT_RIGHT_SWAP_BIT: swap i2s input channels for this fifo
+ I2S HDMI audio is configured only if this property is found.
+   - clocks: phandle mclk
+   - clock-names: "mclk"
+   Describes SII902x MCLK input. MCLK is used to produce
+   HDMI audio CTS values. This property is required if
+   "i2s-fifo-routing"-property is present. This property follows
+   Documentation/devicetree/bindings/clock/clock-bindings.txt
+   consumer binding.
+   - #sound-dai-cells = <0>: ASoC codec dai available for simple-card
+   If audio properties are present sii902x provides an ASoC
+   codec component driver that can be used by other ASoC
+   components like simple-card. See binding document for
+   details:
+   Documentation/devicetree/bindings/sound/simple-card.txt
 
 Optional subnodes:
- video input: this subnode can contain a video input port node
@@ -21,6 +44,17 @@ Example:
compatible = "sil,sii9022";
reg = <0x39>;
reset-gpios = <&pioA 1 0>;
+
+   #sound-dai-cells = <0>;
+   sil,i2s-fifo-routing = <
+   (ENABLE_BIT|CONNECT_SD0)
+   0
+   0
+   0
+   >;
+   clocks = <&mclk>;
+   clock-names = "mclk";
+
ports {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/include/dt-bindings/sound/sii902x-audio.h 
b/include/dt-bindings/sound/sii902x-audio.h
new file mode 100644
index ..0a849904754b
--- /dev/null
+++ b/include/dt-bindings/sound/sii902x-audio.h
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Jyri Sarha 
+ */
+
+#ifndef __DT_SII9022_AUDIO_H
+#define __DT_SII9022_AUDIO_H
+
+#define ENABLE_BIT 0x80
+#define CONNECT_SD00x00
+#define CONNECT_SD10x10
+#define CONNECT_SD20x20
+#define CONNECT_SD30x30
+#define LEFT_RIGHT_SWAP_BIT0x04
+
+#endif /* __DT_SII9022_AUDIO_H */
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 0/2] drm/tilcdc: a cleanup and a fix

2019-03-13 Thread Jyri Sarha
No functional changes since the first version. I'll send a pull
request about these soon.

The minor changes:
- "drm/tilcdc: Check drm_fb_cma_get_gem_obj() return value"
  - Add comment and improve commit description
- "drm/tilcdc: Remove obsolete crtc_mode_valid() hack"
  - Improve indentation and add:
Reviewed-by: Laurent Pinchart 

Jyri Sarha (2):
  drm/tilcdc: Check drm_fb_cma_get_gem_obj() return value
  drm/tilcdc: Remove obsolete crtc_mode_valid() hack

 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 30 
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.h  |  2 -
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 88 +++-
 drivers/gpu/drm/tilcdc/tilcdc_external.h |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_panel.c|  9 ---
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c   |  9 ---
 7 files changed, 21 insertions(+), 119 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v2 2/2] drm/tilcdc: Remove obsolete crtc_mode_valid() hack

2019-03-13 Thread Jyri Sarha
Earlier there were no mode_valid() helper for crtc and tilcdc had a
hack to over come this limitation. But now the mode_valid() helper is
there (has been since v4.13), so it is about time to get rid of that
hack.

Signed-off-by: Jyri Sarha 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 28 +++-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.h  |  2 -
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 88 +++-
 drivers/gpu/drm/tilcdc/tilcdc_external.h |  1 -
 drivers/gpu/drm/tilcdc/tilcdc_panel.c|  9 ---
 drivers/gpu/drm/tilcdc/tilcdc_tfp410.c   |  9 ---
 7 files changed, 19 insertions(+), 119 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index bc9f859f45dc..c3eca4f37285 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -659,9 +659,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state)
 {
-   struct drm_display_mode *mode = &state->mode;
-   int ret;
-
/* If we are not active we don't care */
if (!state->active)
return 0;
@@ -673,12 +670,6 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
return -EINVAL;
}
 
-   ret = tilcdc_crtc_mode_valid(crtc, mode);
-   if (ret) {
-   dev_dbg(crtc->dev->dev, "Mode \"%s\" not valid", mode->name);
-   return -EINVAL;
-   }
-
return 0;
 }
 
@@ -730,13 +721,6 @@ static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
.disable_vblank = tilcdc_crtc_disable_vblank,
 };
 
-static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
-   .mode_fixup = tilcdc_crtc_mode_fixup,
-   .atomic_check   = tilcdc_crtc_atomic_check,
-   .atomic_enable  = tilcdc_crtc_atomic_enable,
-   .atomic_disable = tilcdc_crtc_atomic_disable,
-};
-
 int tilcdc_crtc_max_width(struct drm_crtc *crtc)
 {
struct drm_device *dev = crtc->dev;
@@ -751,7 +735,9 @@ int tilcdc_crtc_max_width(struct drm_crtc *crtc)
return max_width;
 }
 
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode 
*mode)
+static enum drm_mode_status
+tilcdc_crtc_mode_valid(struct drm_crtc *crtc,
+  const struct drm_display_mode *mode)
 {
struct tilcdc_drm_private *priv = crtc->dev->dev_private;
unsigned int bandwidth;
@@ -839,6 +825,14 @@ int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct 
drm_display_mode *mode)
return MODE_OK;
 }
 
+static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
+   .mode_valid = tilcdc_crtc_mode_valid,
+   .mode_fixup = tilcdc_crtc_mode_fixup,
+   .atomic_check   = tilcdc_crtc_atomic_check,
+   .atomic_enable  = tilcdc_crtc_atomic_enable,
+   .atomic_disable = tilcdc_crtc_atomic_disable,
+};
+
 void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info)
 {
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3dac08b24140..36fd05b145a4 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -192,7 +192,6 @@ static void tilcdc_fini(struct drm_device *dev)
drm_kms_helper_poll_fini(dev);
drm_irq_uninstall(dev);
drm_mode_config_cleanup(dev);
-   tilcdc_remove_external_device(dev);
 
 #ifdef CONFIG_CPU_FREQ
if (priv->freq_transition.notifier_call)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index 62cea5ff5558..3298f39d320e 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -86,7 +86,6 @@ struct tilcdc_drm_private {
 
struct drm_encoder *external_encoder;
struct drm_connector *external_connector;
-   const struct drm_connector_helper_funcs *connector_funcs;
 
bool is_registered;
bool is_componentized;
@@ -168,7 +167,6 @@ void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info);
 void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
bool simulate_vesa_sync);
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode 
*mode);
 int tilcdc_crtc_max_width(struct drm_crtc *crtc);
 void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
 int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c 
b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index b4eaf9bc87f8..54adf05f44e6 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -40,64 +40,6 @@ 

[PATCH v2 1/2] drm/tilcdc: Check drm_fb_cma_get_gem_obj() return value

2019-03-13 Thread Jyri Sarha
Clockwork, a static code analysis SW, complains about
drm_fb_cma_get_gem_obj() possibly returning NULL. This should never
happen with the frame-buffers used by tilcdc. However, returning null
is still a part of the drm_fb_cma_get_gem_obj() API, so lets make
Clockwork quiet by adding a simple check with WARN.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 1067e702c22c..bc9f859f45dc 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -75,6 +75,8 @@ static void set_scanout(struct drm_crtc *crtc, struct 
drm_framebuffer *fb)
u64 dma_base_and_ceiling;
 
gem = drm_fb_cma_get_gem_obj(fb, 0);
+   if (WARN_ON(!gem)) /* Make Clockwork quiet. Should never happen. */
+   return;
 
start = gem->paddr + fb->offsets[0] +
crtc->y * fb->pitches[0] +
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [tiL4.19-AD PATCH 2/2] drm/tilcdc: Remove obsolete crtc_mode_valid() hack

2019-03-13 Thread Jyri Sarha
On 05/03/2019 21:21, Laurent Pinchart wrote:
> Hi Jyri,
> 
> Thank you for the patch.
> 
> On Thu, Feb 28, 2019 at 01:18:51PM +0200, Jyri Sarha wrote:
>> Earlier there were no mode_valid() helper for crtc and tilcdc had a
>> hack to over come this limitation. But now the mode_valid() helper is
>> there (has been since v4.13), so it is about time to get rid of that
>> hack.
>>
>> Signed-off-by: Jyri Sarha 
>> ---
...
>> +static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
>> +.mode_valid = tilcdc_crtc_mode_valid,
>> +.mode_fixup = tilcdc_crtc_mode_fixup,
>> +.atomic_check   = tilcdc_crtc_atomic_check,
>> +.atomic_enable  = tilcdc_crtc_atomic_enable,
>> +.atomic_disable = tilcdc_crtc_atomic_disable,
> 
> While at it, could you fix the indentation ?
> 
> This patch looks good to me overall, nice cleanup.
> 
> Reviewed-by: Laurent Pinchart 
> 
> Is it paving the way to removal of the custom tftp410 module ? :-)
> 

Not really. There is really no simple way to get rid of the if we want
to keep the DTB backward compatibility. There has not been any other
reason to keep it for some time. Tilcdc supports brides and there is a
bridge driver for tfp410.

BR,
Jyri

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v3 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-03-13 Thread Jyri Sarha
On 13/03/2019 18:47, Laurent Pinchart wrote:
> Hello again,
> 
> On Wed, Mar 13, 2019 at 06:29:19PM +0200, Laurent Pinchart wrote:
>> On Wed, Mar 13, 2019 at 06:01:07PM +0200, Jyri Sarha wrote:
>>> The sii902x chip family supports also HDMI audio. Add binding for
>>> describing the necessary i2s and mclk wiring for it.
>>>
>>> Signed-off-by: Jyri Sarha 
>>> ---
>>>  .../bindings/display/bridge/sii902x.txt   | 34 +++
>>>  include/dt-bindings/sound/sii902x-audio.h | 17 ++
>>>  2 files changed, 51 insertions(+)
>>>  create mode 100644 include/dt-bindings/sound/sii902x-audio.h
>>>
>>> diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
>>> b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>>> index c4c1855ca654..977756841193 100644
>>> --- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>>> +++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>>> @@ -8,6 +8,29 @@ Optional properties:
>>> - interrupts: describe the interrupt line used to inform the host
>>>   about hotplug events.
>>> - reset-gpios: OF device-tree gpio specification for RST_N pin.
>>> +   - sil,i2s-fifo-routing: Array of exactly 4 integers indicating i2s
>>> + pins for audio fifo routing. First integer defines routing to
>>> + fifo 0 and second to fifo 1, etc. Integers can be filled with
>>> + definitions from: include/dt-bindings/sound/sii902x-audio.h
>>> + The available definitions are:
>>> + - ENABLE_BIT: enable this audio fifo
>>> + - CONNECT_SD#: route audio input from SD0, SD1, SD2, or SD3 i2s
>>> +data input pin
>>> + - LEFT_RIGHT_SWAP_BIT: swap i2s input channels for this fifo
>>
>> Are all combinations valid ? For instance, could we have D1 routed to
>> the third FIFO, and all other FIFOs disabled ?
> 
> I found the answer to this question in the datasheet:
> 
> "Note that no gaps are allowed when mapping channels to FIFOs – SD pins
> must be mapped to FIFO#0 and FIFO#1 before mapping a channel to FIFO#2,
> and so on."
> 
> I think we can thus simplify the bindings, and use an approach similar
> to the one taken by the data-lanes property for CSI-2. Furthermore, I
> think this should be standardized, not left device-specific.
> 
> How about an sd-lanes property (better names are welcome) that would
> store an array of N integers, where each sd-lanes[i] tells which SD pin
> the i-th FIFO is connected to ?

I agree otherwise, but I would still rather use i2s than sd, because it
is more explicit. SD overlaps with so many other acronyms. So how would
i2s-lanes sound?

> 
>>> + I2S HDMI audio is configured only if this property is found.
>>> +   - clocks: phandle mclk
>>
>> Maybe "clocks: phandle and clock specifier for each clock listed in the 
>> clock-names property" ?
>>

Ok

>>> +   - clock-names: "mclk"
>>> +   Describes SII902x MCLK input. MCLK is used to produce
>>> +   HDMI audio CTS values. This property is required if
>>> +   "i2s-fifo-routing"-property is present. This property follows
>>
>> The property is named sil,i2s-fifo-routing.
>>

Ok

>>> +   Documentation/devicetree/bindings/clock/clock-bindings.txt
>>> +   consumer binding.
>>> +   - #sound-dai-cells = <0>: ASoC codec dai available for simple-card
>>> +   If audio properties are present sii902x provides an ASoC
>>> +   codec component driver that can be used by other ASoC
>>> +   components like simple-card. See binding document for
>>> +   details:
>>> +   Documentation/devicetree/bindings/sound/simple-card.txt
>>>  
>>>  Optional subnodes:
>>> - video input: this subnode can contain a video input port node
>>> @@ -21,6 +44,17 @@ Example:
>>> compatible = "sil,sii9022";
>>> reg = <0x39>;
>>> reset-gpios = <&pioA 1 0>;
>>> +
>>> +   #sound-dai-cells = <0>;
>>> +   sil,i2s-fifo-routing = <
>>> +   (ENABLE_BIT|CONNECT_SD0)
>>> +   0
>>> +   0
>>> +   0
>>> +   >;
>>> +   clocks = <&mclk>;
>>> +   clock-names = "mclk";
>>> +
>>> ports {
>>>  

Re: [PATCH v3 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-03-13 Thread Jyri Sarha
On 13/03/2019 20:12, Laurent Pinchart wrote:
> Hi Jyri,
> 
> On Wed, Mar 13, 2019 at 07:52:08PM +0200, Jyri Sarha wrote:
>> On 13/03/2019 18:47, Laurent Pinchart wrote:
>>> On Wed, Mar 13, 2019 at 06:29:19PM +0200, Laurent Pinchart wrote:
>>>> On Wed, Mar 13, 2019 at 06:01:07PM +0200, Jyri Sarha wrote:
>>>>> The sii902x chip family supports also HDMI audio. Add binding for
>>>>> describing the necessary i2s and mclk wiring for it.
>>>>>
>>>>> Signed-off-by: Jyri Sarha 
>>>>> ---
>>>>>  .../bindings/display/bridge/sii902x.txt   | 34 +++
>>>>>  include/dt-bindings/sound/sii902x-audio.h | 17 ++
>>>>>  2 files changed, 51 insertions(+)
>>>>>  create mode 100644 include/dt-bindings/sound/sii902x-audio.h
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
>>>>> b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>>>>> index c4c1855ca654..977756841193 100644
>>>>> --- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>>>>> +++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
>>>>> @@ -8,6 +8,29 @@ Optional properties:
>>>>>   - interrupts: describe the interrupt line used to inform the host
>>>>> about hotplug events.
>>>>>   - reset-gpios: OF device-tree gpio specification for RST_N pin.
>>>>> + - sil,i2s-fifo-routing: Array of exactly 4 integers indicating i2s
>>>>> +   pins for audio fifo routing. First integer defines routing to
>>>>> +   fifo 0 and second to fifo 1, etc. Integers can be filled with
>>>>> +   definitions from: include/dt-bindings/sound/sii902x-audio.h
>>>>> +   The available definitions are:
>>>>> +   - ENABLE_BIT: enable this audio fifo
>>>>> +   - CONNECT_SD#: route audio input from SD0, SD1, SD2, or SD3 i2s
>>>>> +  data input pin
>>>>> +   - LEFT_RIGHT_SWAP_BIT: swap i2s input channels for this fifo
>>>> Are all combinations valid ? For instance, could we have D1 routed to
>>>> the third FIFO, and all other FIFOs disabled ?
>>> I found the answer to this question in the datasheet:
>>>
>>> "Note that no gaps are allowed when mapping channels to FIFOs – SD pins
>>> must be mapped to FIFO#0 and FIFO#1 before mapping a channel to FIFO#2,
>>> and so on."
>>>
>>> I think we can thus simplify the bindings, and use an approach similar
>>> to the one taken by the data-lanes property for CSI-2. Furthermore, I
>>> think this should be standardized, not left device-specific.
>>>
>>> How about an sd-lanes property (better names are welcome) that would
>>> store an array of N integers, where each sd-lanes[i] tells which SD pin
>>> the i-th FIFO is connected to ?
>> I agree otherwise, but I would still rather use i2s than sd, because it
>> is more explicit. SD overlaps with so many other acronyms. So how would
>> i2s-lanes sound?
> Sounds good to me. It's a better name, so it's welcome :-) I don't know
> what terminology is usually used in the audio world for this, so I was
> pretty sure my initial name proposal was bad.
> 
> Is there a risk of needing to describe the clock lane separately in the
> future (for this or another I2S-related chip) ? If so, maybe
> i2s-data-lanes, or just data-lanes, would be a better pick.
> 

Usually (or always AFAIK) there is only one bit clock and one frame
clock lane, and 1 - n data lanes. But still being more explicit does not
hurt, let's make it i2s-data-lanes.

Thanks for the prompt review. I'll try to make the changes for tomorrow.

Best regards,
Jyri

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH][next] drm/bridge: sii902x: fix comparision of u32 with less than zero

2019-06-03 Thread Jyri Sarha
On 03/06/2019 17:21, Colin King wrote:
> From: Colin Ian King 
> 
> The less than check for the variable num_lanes is always going to be
> false because the variable is a u32.  Fix this by making num_lanes an
> int and also make loop index i an int too.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
> Signed-off-by: Colin Ian King 

Oh, one of these slipped trough after all.

Acked-by: Jyri Sarha 

> ---
>  drivers/gpu/drm/bridge/sii902x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/bridge/sii902x.c 
> b/drivers/gpu/drm/bridge/sii902x.c
> index d6f98d388ac2..21a947603c88 100644
> --- a/drivers/gpu/drm/bridge/sii902x.c
> +++ b/drivers/gpu/drm/bridge/sii902x.c
> @@ -719,7 +719,7 @@ static int sii902x_audio_codec_init(struct sii902x 
> *sii902x,
>   .max_i2s_channels = 0,
>   };
>   u8 lanes[4];
> - u32 num_lanes, i;
> + int num_lanes, i;
>  
>   if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
>   dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n",
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 1/3] drm/bridge: sii902x: fix missing reference to mclk clock

2019-07-04 Thread Jyri Sarha
On 02/07/2019 18:47, Olivier Moysan wrote:
> Add devm_clk_get call to retrieve reference to master clock.
> 
> Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
> 
> Signed-off-by: Olivier Moysan 

Reviewed-by: Jyri Sarha 

I wonder how that line was dropped and how the code past my final test.
Any way, this fix is definitely needed.

Thanks,
Jyri

> ---
>  drivers/gpu/drm/bridge/sii902x.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/bridge/sii902x.c 
> b/drivers/gpu/drm/bridge/sii902x.c
> index dd7aa466b280..36acc256e67e 100644
> --- a/drivers/gpu/drm/bridge/sii902x.c
> +++ b/drivers/gpu/drm/bridge/sii902x.c
> @@ -750,6 +750,7 @@ static int sii902x_audio_codec_init(struct sii902x 
> *sii902x,
>   sii902x->audio.i2s_fifo_sequence[i] |= audio_fifo_id[i] |
>   i2s_lane_id[lanes[i]] | SII902X_TPI_I2S_FIFO_ENABLE;
>  
> + sii902x->audio.mclk = devm_clk_get(dev, "mclk");
>   if (IS_ERR(sii902x->audio.mclk)) {
>   dev_err(dev, "%s: No clock (audio mclk) found: %ld\n",
>   __func__, PTR_ERR(sii902x->audio.mclk));
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 2/3] dt-bindings: display: sii902x: Change audio mclk binding

2019-07-04 Thread Jyri Sarha
On 02/07/2019 18:47, Olivier Moysan wrote:
> As stated in SiL9022/24 datasheet, master clock is not required for I2S.
> Make mclk property optional in DT bindings.
> 
> Fixes: 3f18021f43a3 ("dt-bindings: display: sii902x: Add HDMI audio bindings")
> 
> Signed-off-by: Olivier Moysan 

Looking the specs again it looks like the mclk is requred for sii9020,
but not for sii9022 and sii9024.

So I guess it is fine to accept the configurations without the mclk.

Reviewed-by: Jyri Sarha 

> ---
>  Documentation/devicetree/bindings/display/bridge/sii902x.txt | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
> b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
> index 2df44b7d3821..6e14e087c0d0 100644
> --- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
> +++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
> @@ -26,9 +26,8 @@ Optional properties:
>   - clocks: phandle and clock specifier for each clock listed in
> the clock-names property
>   - clock-names: "mclk"
> -Describes SII902x MCLK input. MCLK is used to produce
> -HDMI audio CTS values. This property is required if
> -"#sound-dai-cells"-property is present. This property follows
> +Describes SII902x MCLK input. MCLK can be used to produce
> +HDMI audio CTS values. This property follows
>  Documentation/devicetree/bindings/clock/clock-bindings.txt
>  consumer binding.
>  
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 3/3] drm/bridge: sii902x: make audio mclk optional

2019-07-04 Thread Jyri Sarha
On 02/07/2019 18:47, Olivier Moysan wrote:
> The master clock on i2s bus is not mandatory,
> as sii902X internal PLL can be used instead.
> Make use of mclk optional.
> 
> Fixes: ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
> 
> Signed-off-by: Olivier Moysan 

Reviewed-by: Jyri Sarha 

> ---
>  drivers/gpu/drm/bridge/sii902x.c | 39 +++
>  1 file changed, 23 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/sii902x.c 
> b/drivers/gpu/drm/bridge/sii902x.c
> index 36acc256e67e..a08bd9fdc046 100644
> --- a/drivers/gpu/drm/bridge/sii902x.c
> +++ b/drivers/gpu/drm/bridge/sii902x.c
> @@ -562,19 +562,21 @@ static int sii902x_audio_hw_params(struct device *dev, 
> void *data,
>   }
>   }
>  
> - ret = clk_prepare_enable(sii902x->audio.mclk);
> - if (ret) {
> - dev_err(dev, "Enabling mclk failed: %d\n", ret);
> - return ret;
> - }
> + if (sii902x->audio.mclk) {
> + ret = clk_prepare_enable(sii902x->audio.mclk);
> + if (ret) {
> + dev_err(dev, "Enabling mclk failed: %d\n", ret);
> + return ret;
> + }
>  
> - mclk_rate = clk_get_rate(sii902x->audio.mclk);
> + mclk_rate = clk_get_rate(sii902x->audio.mclk);
>  
> - ret = sii902x_select_mclk_div(&i2s_config_reg, params->sample_rate,
> -   mclk_rate);
> - if (mclk_rate != ret * params->sample_rate)
> - dev_dbg(dev, "Inaccurate reference clock (%ld/%d != %u)\n",
> - mclk_rate, ret, params->sample_rate);
> + ret = sii902x_select_mclk_div(&i2s_config_reg,
> +   params->sample_rate, mclk_rate);
> + if (mclk_rate != ret * params->sample_rate)
> + dev_dbg(dev, "Inaccurate reference clock (%ld/%d != 
> %u)\n",
> + mclk_rate, ret, params->sample_rate);
> + }
>  
>   mutex_lock(&sii902x->mutex);
>  
> @@ -640,7 +642,8 @@ static int sii902x_audio_hw_params(struct device *dev, 
> void *data,
>   mutex_unlock(&sii902x->mutex);
>  
>   if (ret) {
> - clk_disable_unprepare(sii902x->audio.mclk);
> + if (sii902x->audio.mclk)
> + clk_disable_unprepare(sii902x->audio.mclk);
>   dev_err(dev, "%s: hdmi audio enable failed: %d\n", __func__,
>   ret);
>   }
> @@ -659,7 +662,8 @@ static void sii902x_audio_shutdown(struct device *dev, 
> void *data)
>  
>   mutex_unlock(&sii902x->mutex);
>  
> - clk_disable_unprepare(sii902x->audio.mclk);
> + if (sii902x->audio.mclk)
> + clk_disable_unprepare(sii902x->audio.mclk);
>  }
>  
>  int sii902x_audio_digital_mute(struct device *dev, void *data, bool enable)
> @@ -752,9 +756,12 @@ static int sii902x_audio_codec_init(struct sii902x 
> *sii902x,
>  
>   sii902x->audio.mclk = devm_clk_get(dev, "mclk");
>   if (IS_ERR(sii902x->audio.mclk)) {
> - dev_err(dev, "%s: No clock (audio mclk) found: %ld\n",
> - __func__, PTR_ERR(sii902x->audio.mclk));
> - return 0;
> + if (PTR_ERR(sii902x->audio.mclk) != -ENOENT) {
> + dev_err(dev, "%s: No clock (audio mclk) found: %ld\n",
> + __func__, PTR_ERR(sii902x->audio.mclk));
> + return PTR_ERR(sii902x->audio.mclk);
> + }
> + sii902x->audio.mclk = NULL;
>   }
>  
>   sii902x->audio.pdev = platform_device_register_data(
> 


-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


[PATCH v4 5/6] dt-bindings: display: sii902x: Add HDMI audio bindings

2019-03-14 Thread Jyri Sarha
The sii902x chip family supports also HDMI audio. Add binding for
describing the necessary i2s and mclk wiring for it.

Signed-off-by: Jyri Sarha 
---
 .../bindings/display/bridge/sii902x.txt   | 33 +++
 1 file changed, 33 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index c4c1855ca654..1a37bbe7c597 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -9,6 +9,33 @@ Optional properties:
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
+   HDMI audio properties:
+   - i2s-data-lanes: Array of up to 4 integers with values of 0-3
+  Each integer indicates which i2s pin is connected to which
+  audio fifo. The first integer selects i2s audio pin for the
+  first audio fifo#0 (HDMI channels 1&2), second for fifo#1
+  (HDMI channels 3&4), and so on. There is 4 fifos and 4 i2s
+  pins (SD0 - SD3). Any i2s pin can be connected to any fifo,
+  but there can be no gaps. E.g. an i2s pin must be mapped to
+  fifo#0 and fifo#1 before mapping a channel to fifo#2.
+  I2S HDMI audio is configured only if this property is found.
+   - clocks: phandle and clock specifier for each clock listed in
+  the clock-names property
+   - clock-names: "mclk"
+   Describes SII902x MCLK input. MCLK is used to produce
+   HDMI audio CTS values. This property is required if
+   "i2s-data-lanes"-property is present. This property follows
+   Documentation/devicetree/bindings/clock/clock-bindings.txt
+   consumer binding.
+
+   If HDMI audio is configured the sii902x device becomes an ASoC
+   codec component, that can be used in configuring full audio
+   devices with ASoC simple-card or audio-graph-card. See their
+   binding documents on how to describe how the sii902x device is
+   connected to the rest of the audio system:
+   Documentation/devicetree/bindings/sound/simple-card.txt
+   Documentation/devicetree/bindings/sound/audio-graph-card.txt
+
 Optional subnodes:
- video input: this subnode can contain a video input port node
  to connect the bridge to a display controller output (See this
@@ -21,6 +48,12 @@ Example:
compatible = "sil,sii9022";
reg = <0x39>;
reset-gpios = <&pioA 1 0>;
+
+   #sound-dai-cells = <0>;
+   i2s-data-lanes = < 0 1 2 >;
+   clocks = <&mclk>;
+   clock-names = "mclk";
+
ports {
#address-cells = <1>;
#size-cells = <0>;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 1/6] drm/bridge: sii902x: add input_bus_flags

2019-03-14 Thread Jyri Sarha
From: Tomi Valkeinen 

The driver always sets InputBusFmt:EDGE to 0 (falling edge).

Add drm_bridge_timings's input_bus_flags to reflect that the bridge
samples on falling edges.

Signed-off-by: Tomi Valkeinen 
Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index bfa902013aa4..1afa000141d5 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -459,6 +459,12 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core 
*mux, u32 chan_id)
return 0;
 }
 
+static const struct drm_bridge_timings default_sii902x_timings = {
+   .input_bus_flags = DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE
+| DRM_BUS_FLAG_DE_HIGH,
+};
+
 static int sii902x_probe(struct i2c_client *client,
 const struct i2c_device_id *id)
 {
@@ -529,6 +535,7 @@ static int sii902x_probe(struct i2c_client *client,
 
sii902x->bridge.funcs = &sii902x_bridge_funcs;
sii902x->bridge.of_node = dev->of_node;
+   sii902x->bridge.timings = &default_sii902x_timings;
drm_bridge_add(&sii902x->bridge);
 
i2c_set_clientdata(client, sii902x);
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 0/6] drm/bridge: sii902x: HDMI-audio support and some fixes

2019-03-14 Thread Jyri Sarha
Changes since v3:
- Change sil,i2s-fifo-routing of property to i2s-data-lanes.
  Both the binding and the implementation has been updated.
- Refer to audio-graph-card.txt and simple-card.txt binding
- remove include/dt-bindings/sound/sii902x-audio.h
- lower case hex constant
- add Laurent's reviewed-by to applicable patches

The already reviewed patches are in front. Not reviewed still:
- "dt-bindings: display: sii902x: Add HDMI audio bindings"
- "drm/bridge: sii902x: Implement HDMI audio support"

The previous round:
https://patchwork.kernel.org/project/dri-devel/list/?series=91145

Jyri Sarha (5):
  drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID
  drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz
  dt-bindings: display: sii902x: Remove trailing white space
  dt-bindings: display: sii902x: Add HDMI audio bindings
  drm/bridge: sii902x: Implement HDMI audio support

Tomi Valkeinen (1):
  drm/bridge: sii902x: add input_bus_flags

 .../bindings/display/bridge/sii902x.txt   |  35 +-
 drivers/gpu/drm/bridge/sii902x.c  | 477 +-
 2 files changed, 504 insertions(+), 8 deletions(-)

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 6/6] drm/bridge: sii902x: Implement HDMI audio support

2019-03-14 Thread Jyri Sarha
Implement HDMI audio support by using ASoC HDMI codec. The commit
implements the necessary callbacks and configuration for the HDMI
codec and registers a virtual platform device for the codec to attach.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/bridge/sii902x.c | 460 ++-
 1 file changed, 453 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1d99108440c1..39a0d25009f2 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -27,12 +27,15 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+
 #define SII902X_TPI_VIDEO_DATA 0x0
 
 #define SII902X_TPI_PIXEL_REPETITION   0x8
@@ -74,6 +77,77 @@
 #define SII902X_AVI_POWER_STATE_MSKGENMASK(1, 0)
 #define SII902X_AVI_POWER_STATE_D(l)   ((l) & 
SII902X_AVI_POWER_STATE_MSK)
 
+/* Audio  */
+#define SII902X_TPI_I2S_ENABLE_MAPPING_REG 0x1f
+#define SII902X_TPI_I2S_CONFIG_FIFO0   (0 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO1   (1 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO2   (2 << 0)
+#define SII902X_TPI_I2S_CONFIG_FIFO3   (3 << 0)
+#define SII902X_TPI_I2S_LEFT_RIGHT_SWAP(1 << 2)
+#define SII902X_TPI_I2S_AUTO_DOWNSAMPLE(1 << 3)
+#define SII902X_TPI_I2S_SELECT_SD0 (0 << 4)
+#define SII902X_TPI_I2S_SELECT_SD1 (1 << 4)
+#define SII902X_TPI_I2S_SELECT_SD2 (2 << 4)
+#define SII902X_TPI_I2S_SELECT_SD3 (3 << 4)
+#define SII902X_TPI_I2S_FIFO_ENABLE(1 << 7)
+
+#define SII902X_TPI_I2S_INPUT_CONFIG_REG   0x20
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_YES(0 << 0)
+#define SII902X_TPI_I2S_FIRST_BIT_SHIFT_NO (1 << 0)
+#define SII902X_TPI_I2S_SD_DIRECTION_MSB_FIRST (0 << 1)
+#define SII902X_TPI_I2S_SD_DIRECTION_LSB_FIRST (1 << 1)
+#define SII902X_TPI_I2S_SD_JUSTIFY_LEFT(0 << 2)
+#define SII902X_TPI_I2S_SD_JUSTIFY_RIGHT   (1 << 2)
+#define SII902X_TPI_I2S_WS_POLARITY_LOW(0 << 3)
+#define SII902X_TPI_I2S_WS_POLARITY_HIGH   (1 << 3)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_128(0 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_256(1 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_384(2 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_512(3 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_768(4 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1024   (5 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_1152   (6 << 4)
+#define SII902X_TPI_I2S_MCLK_MULTIPLIER_192(7 << 4)
+#define SII902X_TPI_I2S_SCK_EDGE_FALLING   (0 << 7)
+#define SII902X_TPI_I2S_SCK_EDGE_RISING(1 << 7)
+
+#define SII902X_TPI_I2S_STRM_HDR_BASE  0x21
+#define SII902X_TPI_I2S_STRM_HDR_SIZE  5
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE2_REG 0x26
+#define SII902X_TPI_AUDIO_CODING_STREAM_HEADER (0 << 0)
+#define SII902X_TPI_AUDIO_CODING_PCM   (1 << 0)
+#define SII902X_TPI_AUDIO_CODING_AC3   (2 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG1 (3 << 0)
+#define SII902X_TPI_AUDIO_CODING_MP3   (4 << 0)
+#define SII902X_TPI_AUDIO_CODING_MPEG2 (5 << 0)
+#define SII902X_TPI_AUDIO_CODING_AAC   (6 << 0)
+#define SII902X_TPI_AUDIO_CODING_DTS   (7 << 0)
+#define SII902X_TPI_AUDIO_CODING_ATRAC (8 << 0)
+#define SII902X_TPI_AUDIO_MUTE_DISABLE (0 << 4)
+#define SII902X_TPI_AUDIO_MUTE_ENABLE  (1 << 4)
+#define SII902X_TPI_AUDIO_LAYOUT_2_CHANNELS(0 << 5)
+#define SII902X_TPI_AUDIO_LAYOUT_8_CHANNELS(1 << 5)
+#define SII902X_TPI_AUDIO_INTERFACE_DISABLE(0 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_SPDIF  (1 << 6)
+#define SII902X_TPI_AUDIO_INTERFACE_I2S(2 << 6)
+
+#define SII902X_TPI_AUDIO_CONFIG_BYTE3_REG 0x27
+#define SII902X_TPI_AUDIO_FREQ_STREAM  (0 << 3)
+#define SII902X_TPI_AUDIO_FREQ_32KHZ   (1 << 3)
+#define SII902X_TPI_AUDIO_FREQ_44KHZ   (2 << 3)
+#define SII902X_TPI_AUDIO_FREQ_48KHZ   (3 << 3)
+#define SII902X_TPI_AUDIO_FREQ_88KHZ   (4 << 3)
+#define SII902X_TPI_AUDIO_FREQ_96KHZ   (5 << 3)
+#define SII902X_TPI_AU

[PATCH v4 2/6] drm/bridge: sii902x: Set output mode to HDMI or DVI according to EDID

2019-03-14 Thread Jyri Sarha
Set output mode to HDMI or DVI according to EDID HDMI signature.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 1afa000141d5..0e21fa419d27 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -181,11 +181,15 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
struct sii902x *sii902x = connector_to_sii902x(connector);
u32 bus_format = MEDIA_BUS_FMT_RGB888_1X24;
struct edid *edid;
+   u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
int num = 0, ret;
 
edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]);
drm_connector_update_edid_property(connector, edid);
if (edid) {
+   if (drm_detect_hdmi_monitor(edid))
+   output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
+
num = drm_add_edid_modes(connector, edid);
kfree(edid);
}
@@ -195,6 +199,11 @@ static int sii902x_get_modes(struct drm_connector 
*connector)
if (ret)
return ret;
 
+   ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
+SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
+   if (ret)
+   return ret;
+
return num;
 }
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 4/6] dt-bindings: display: sii902x: Remove trailing white space

2019-03-14 Thread Jyri Sarha
Remove trailing white space from sii902x display bridge binding.

Signed-off-by: Jyri Sarha 
Reviewed-by: Laurent Pinchart 
---
 Documentation/devicetree/bindings/display/bridge/sii902x.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/sii902x.txt 
b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
index 72d2dc6c3e6b..c4c1855ca654 100644
--- a/Documentation/devicetree/bindings/display/bridge/sii902x.txt
+++ b/Documentation/devicetree/bindings/display/bridge/sii902x.txt
@@ -5,7 +5,7 @@ Required properties:
- reg: i2c address of the bridge
 
 Optional properties:
-   - interrupts: describe the interrupt line used to inform the host 
+   - interrupts: describe the interrupt line used to inform the host
  about hotplug events.
- reset-gpios: OF device-tree gpio specification for RST_N pin.
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[PATCH v4 3/6] drm/bridge: sii902x: pixel clock unit is 10kHz instead of 1kHz

2019-03-14 Thread Jyri Sarha
The pixel clock unit in the first two registers (0x00 and 0x01) of
sii9022 is 10kHz, not 1kHz as in struct drm_display_mode. Division by
10 fixes the issue.

Signed-off-by: Jyri Sarha 
Reviewed-by: Andrzej Hajda 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/bridge/sii902x.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 0e21fa419d27..1d99108440c1 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -248,10 +248,11 @@ static void sii902x_bridge_mode_set(struct drm_bridge 
*bridge,
struct regmap *regmap = sii902x->regmap;
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
struct hdmi_avi_infoframe frame;
+   u16 pixel_clock_10kHz = adj->clock / 10;
int ret;
 
-   buf[0] = adj->clock;
-   buf[1] = adj->clock >> 8;
+   buf[0] = pixel_clock_10kHz & 0xff;
+   buf[1] = pixel_clock_10kHz >> 8;
buf[2] = adj->vrefresh;
buf[3] = 0x00;
buf[4] = adj->hdisplay;
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  1   2   3   4   5   6   7   8   9   10   >