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

2019-03-12 Thread Rob Herring
On Wed, Feb 27, 2019 at 11:54:23PM +0200, 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   |  36 +-
>  drivers/gpu/drm/bridge/sii902x.c  | 453 +-
>  include/dt-bindings/sound/sii902x-audio.h |  11 +

Please split bindings (doc and header) to a separate patch.

>  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

Unrelated change.

> about hotplug events.
>   - reset-gpios: OF device-tree gpio specification for RST_N pin.
> + - i2s-fifo-routing: Array of exactly 4 integers indicating i2s

Needs a vendor prefix.

> +   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 fo> + 
> 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 = < 1 0>;
> +
> + #sound-dai-cells = <0>;
> + i2s-fifo-routing = <
> + (ENABLE_BIT|CONNECT_SD0)
> + 0
> + 0
> + 0
> + >;
> + clocks = <>;
> + 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 ..32e50a926b6f
> --- /dev/null
> +++ b/include/dt-bindings/sound/sii902x-audio.h
> @@ -0,0 +1,11 @@

License?

> +#ifndef __DT_SII9022_AUDIO_H
> +#define __DT_SII9022_AUDIO_H
> +
> +#define ENABLE_BIT   0x80
> +#define CONNECT_SD0  0x00
> +#define CONNECT_SD1  0x10
> +#define CONNECT_SD2  0x20
> +#define CONNECT_SD3  0x30
> +#define LEFT_RIGHT_SWAP_BIT  0x04
> +
> +#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

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

2019-03-04 Thread Andrzej Hajda
On 27.02.2019 22:54, 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   |  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


I am not an audio expert, so please forgive me if I make stupid mistakes :)

As I wrote previously, lack of DT connection between the bridge and the
audio producer looks for me as incomplete binding - hardware connection
is neither discoverable neither represented in DT. As I understand it
works because there is usually only one sound subsystem per board, and
there is only one hdmi output. Am I right?

But I guess boards with more than one hdmi output are not uncommon, how
do you discover topology in such case?


Regards

Andrzej


>  
>  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 = < 1 0>;
> +
> + #sound-dai-cells = <0>;
> + i2s-fifo-routing = <
> + (ENABLE_BIT|CONNECT_SD0)
> + 0
> + 0
> + 0
> + >;
> + clocks = <>;
> + 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_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 

[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 = < 1 0>;
+
+   #sound-dai-cells = <0>;
+   i2s-fifo-routing = <
+   (ENABLE_BIT|CONNECT_SD0)
+   0
+   0
+   0
+   >;
+   clocks = <>;
+   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 << 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)