[PATCH v6 5/6] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-03-10 Thread Jyri Sarha
On 03/09/16 15:52, kbuild test robot wrote:
> Hi Jyri,
>
> [auto build test WARNING on drm/drm-next]
> [also build test WARNING on v4.5-rc7 next-20160309]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improving the system]
>
> url:
> https://github.com/0day-ci/linux/commits/Jyri-Sarha/Implement-generic-ASoC-HDMI-codec-and-use-it-in-tda998x/20160309-041821
> base:   git://people.freedesktop.org/~airlied/linux.git drm-next
> config: x86_64-rhel (attached as .config)
> reproduce:
>  # save the attached .config to linux build tree
>  make ARCH=x86_64
>
> All warnings (new ones prefixed by >>):
>
> drivers/gpu/drm/i2c/tda998x_drv.c: In function 'tda998x_get_audio_ports':
>>> drivers/gpu/drm/i2c/tda998x_drv.c:1345:7: warning: 'size' is used 
>>> uninitialized in this function [-Wuninitialized]
>   size /= sizeof(u32);
>^
>
> vim +/size +1345 drivers/gpu/drm/i2c/tda998x_drv.c
>
>1329   if (IS_ERR(priv->audio_pdev))
>1330   return PTR_ERR(priv->audio_pdev);
>1331   
>1332   return 0;
>1333   }
>1334   
>1335   /* I2C driver functions */
>1336   
>1337   static int tda998x_get_audio_ports(struct tda998x_priv *priv,
>1338  struct device_node *np)
>1339   {
>1340   const u32 *port_data;
>1341   u32 size;
>1342   int i;
>1343   
>1344   port_data = of_get_property(np, "audio-ports", );
 >> 1345size /= sizeof(u32);

Oops, that is a real bug. I should test if port_data is not null before 
assuming that the size has been set (/me thinks that he had that line 
there at some point but then it vanished). Actually initializing size to 
0 would be enough, but I think I'll do the both just to be more explicit.

And I'll start using PTR_ERR_OR_ZERO() while I am at it.

>1346   
>1347   if (size > 2 * ARRAY_SIZE(priv->audio_port) || size % 2 
> != 0) {
>1348   dev_err(>hdmi->dev,
>1349   "Bad number of elements in audio-ports 
> dt-property\n");
>1350   return -EINVAL;
>1351   }
>1352   
>1353   size /= 2;
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>



[PATCH v6 5/6] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-03-09 Thread kbuild test robot
Hi Jyri,

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.5-rc7 next-20160309]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Jyri-Sarha/Implement-generic-ASoC-HDMI-codec-and-use-it-in-tda998x/20160309-041821
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: x86_64-rhel (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/i2c/tda998x_drv.c: In function 'tda998x_get_audio_ports':
>> drivers/gpu/drm/i2c/tda998x_drv.c:1345:7: warning: 'size' is used 
>> uninitialized in this function [-Wuninitialized]
 size /= sizeof(u32);
  ^

vim +/size +1345 drivers/gpu/drm/i2c/tda998x_drv.c

  1329  if (IS_ERR(priv->audio_pdev))
  1330  return PTR_ERR(priv->audio_pdev);
  1331  
  1332  return 0;
  1333  }
  1334  
  1335  /* I2C driver functions */
  1336  
  1337  static int tda998x_get_audio_ports(struct tda998x_priv *priv,
  1338 struct device_node *np)
  1339  {
  1340  const u32 *port_data;
  1341  u32 size;
  1342  int i;
  1343  
  1344  port_data = of_get_property(np, "audio-ports", );
> 1345  size /= sizeof(u32);
  1346  
  1347  if (size > 2 * ARRAY_SIZE(priv->audio_port) || size % 2 != 0) {
  1348  dev_err(>hdmi->dev,
  1349  "Bad number of elements in audio-ports 
dt-property\n");
  1350  return -EINVAL;
  1351  }
  1352  
  1353  size /= 2;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
-- next part --
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 36116 bytes
Desc: not available
URL: 



[PATCH v6 5/6] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-03-09 Thread kbuild test robot
Hi Jyri,

[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.5-rc7 next-20160308]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improving the system]

url:
https://github.com/0day-ci/linux/commits/Jyri-Sarha/Implement-generic-ASoC-HDMI-codec-and-use-it-in-tda998x/20160309-041821
base:   git://people.freedesktop.org/~airlied/linux.git drm-next


coccinelle warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/i2c/tda998x_drv.c:1329:1-3: WARNING: PTR_ERR_OR_ZERO can be 
>> used

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH v6 5/6] drm/i2c: tda998x: Register ASoC hdmi-codec and add audio DT binding

2016-03-08 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  | 194 -
 include/drm/i2c/tda998x.h  |   4 +-
 include/dt-bindings/display/tda998x.h  |   7 +
 5 files changed, 219 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..816f6b5 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 = <_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 22c7ed6..088f278 100644
--- a/drivers/gpu/drm/i2c/Kconfig
+++ b/drivers/gpu/drm/i2c/Kconfig
@@ -28,6 +28,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 206df0b..d5733436 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(>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(edid);

return n;
@@ -1181,6 +1193,9 @@ static void tda998x_destroy(struct tda998x_priv *priv)
cec_write(priv,