[PATCH v11 6/8] media: i2c: Add TDA1997x HDMI receiver driver

2018-02-14 Thread Tim Harvey
Add support for the TDA1997x HDMI receivers.

Cc: Hans Verkuil 
Signed-off-by: Tim Harvey 
---
v11:
 - return -ERANGE from tda1997x_detect_std (Hans)
 - clean up tda1997x_g_input_status (Hans)
 - show detected timings on resolution change if debug enabled
 - fix unitialized ret var in tda1997x_query_dv_timings
 - update log status to show detected timings

v10:
 - removed unnecessary check for !timings in get/set/query dv timings (Hans)
 - dropped pointless s_stream handler (Hans)
 - remove need for detected_timings and always use set timings (Hans)

v9:
 - remove redundant pad bounds check already in v4l2-subdev.c
 - assign entity function (Hans)
 - properly assign/check/free ctrl_handler (Hans)
 - fixed typo 'Rull Range' -> 'Full Range'
 - update csc after quant range change

v8:
 - fix available formats for tda19971 bt656 bus width >12
 - support full range of input modes based on timings_cap
 - fix set_format (compliance)
 - fixed get/set edid (compliance)
 - add init_cfg to setup default pad config (compliance)
 - added missing pad checks to get_dv_timings_cap/enum_dv_timings (compliance)
 - fix alignment of if statement and whitespace in comment (Hans)
 - move regs to tda1997x_regs.h to clean up (Hans)
 - add define and sanity check for num of mbus_codes (Hans)

v7:
 - fix interlaced mode
 - support no AVI infoframe (ie DVI) (Hans)
 - add support for multiple output formats (Hans)

v6:
 - fix return on regulator enablei in tda1997x_set_power()
 - replace copyright with SPDX tag
 - fix colorspace handling

v5:
 - uppercase string constants
 - use v4l2_hdmi_rx_coloriemtry to fill format
 - fix V4L2_CID_DV_RX_RGB_RANGE
 - fix interlaced mode format

v4:
 - move include/dt-bindings/media/tda1997x.h to bindings patch
 - fix typos
 - fix default quant range for VGA
 - fix quant range handling and conv matrix
 - add additional standards and capabilities to timings_cap

v3:
 - use V4L2_DV_BT_FRAME_WIDTH/HEIGHT macros
 - fixed missing break
 - use only hdmi_infoframe_log for infoframe logging
 - simplify tda1997x_s_stream error handling
 - add delayed work proc to handle hotplug enable/disable
 - fix set_edid (disable HPD before writing, enable after)
 - remove enabling edid by default
 - initialize timings
 - take quant range into account in colorspace conversion
 - remove vendor/product tracking (we provide this in log_status via infoframes)
 - add v4l_controls
 - add more detail to log_status
 - calculate vhref generator timings
 - timing detection fixes (rounding errors, hswidth errors)
 - rename configure_input/configure_conv functions

v2:
 - implement dv timings enum/cap
 - remove deprecated g_mbus_config op
 - fix dv_query_timings
 - add EDID get/set handling
 - remove max-pixel-rate support
 - add audio codec DAI support
 - change audio bindings

 drivers/media/i2c/Kconfig |9 +
 drivers/media/i2c/Makefile|1 +
 drivers/media/i2c/tda1997x.c  | 2822 +
 drivers/media/i2c/tda1997x_regs.h |  641 +
 include/media/i2c/tda1997x.h  |   42 +
 5 files changed, 3515 insertions(+)
 create mode 100644 drivers/media/i2c/tda1997x.c
 create mode 100644 drivers/media/i2c/tda1997x_regs.h
 create mode 100644 include/media/i2c/tda1997x.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index cb5d7ff..3522641 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -56,6 +56,15 @@ config VIDEO_TDA9840
  To compile this driver as a module, choose M here: the
  module will be called tda9840.
 
+config VIDEO_TDA1997X
+   tristate "NXP TDA1997x HDMI receiver"
+   depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
+   ---help---
+ V4L2 subdevice driver for the NXP TDA1997x HDMI receivers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called tda1997x.
+
 config VIDEO_TEA6415C
tristate "Philips TEA6415C audio processor"
depends on I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..adfcae9 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
 obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
 obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o
 obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
+obj-$(CONFIG_VIDEO_TDA1997X) += tda1997x.o
 obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
 obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
 obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
new file mode 100644
index 000..ce6b694
--- /dev/null
+++ b/drivers/media/i2c/tda1997x.c
@@ -0,0 +1,2822 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Gateworks Corporation
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 

[PATCH v11 6/8] media: i2c: Add TDA1997x HDMI receiver driver

2018-02-14 Thread Tim Harvey
Add support for the TDA1997x HDMI receivers.

Cc: Hans Verkuil 
Signed-off-by: Tim Harvey 
---
v11:
 - return -ERANGE from tda1997x_detect_std (Hans)
 - clean up tda1997x_g_input_status (Hans)
 - show detected timings on resolution change if debug enabled
 - fix unitialized ret var in tda1997x_query_dv_timings
 - update log status to show detected timings

v10:
 - removed unnecessary check for !timings in get/set/query dv timings (Hans)
 - dropped pointless s_stream handler (Hans)
 - remove need for detected_timings and always use set timings (Hans)

v9:
 - remove redundant pad bounds check already in v4l2-subdev.c
 - assign entity function (Hans)
 - properly assign/check/free ctrl_handler (Hans)
 - fixed typo 'Rull Range' -> 'Full Range'
 - update csc after quant range change

v8:
 - fix available formats for tda19971 bt656 bus width >12
 - support full range of input modes based on timings_cap
 - fix set_format (compliance)
 - fixed get/set edid (compliance)
 - add init_cfg to setup default pad config (compliance)
 - added missing pad checks to get_dv_timings_cap/enum_dv_timings (compliance)
 - fix alignment of if statement and whitespace in comment (Hans)
 - move regs to tda1997x_regs.h to clean up (Hans)
 - add define and sanity check for num of mbus_codes (Hans)

v7:
 - fix interlaced mode
 - support no AVI infoframe (ie DVI) (Hans)
 - add support for multiple output formats (Hans)

v6:
 - fix return on regulator enablei in tda1997x_set_power()
 - replace copyright with SPDX tag
 - fix colorspace handling

v5:
 - uppercase string constants
 - use v4l2_hdmi_rx_coloriemtry to fill format
 - fix V4L2_CID_DV_RX_RGB_RANGE
 - fix interlaced mode format

v4:
 - move include/dt-bindings/media/tda1997x.h to bindings patch
 - fix typos
 - fix default quant range for VGA
 - fix quant range handling and conv matrix
 - add additional standards and capabilities to timings_cap

v3:
 - use V4L2_DV_BT_FRAME_WIDTH/HEIGHT macros
 - fixed missing break
 - use only hdmi_infoframe_log for infoframe logging
 - simplify tda1997x_s_stream error handling
 - add delayed work proc to handle hotplug enable/disable
 - fix set_edid (disable HPD before writing, enable after)
 - remove enabling edid by default
 - initialize timings
 - take quant range into account in colorspace conversion
 - remove vendor/product tracking (we provide this in log_status via infoframes)
 - add v4l_controls
 - add more detail to log_status
 - calculate vhref generator timings
 - timing detection fixes (rounding errors, hswidth errors)
 - rename configure_input/configure_conv functions

v2:
 - implement dv timings enum/cap
 - remove deprecated g_mbus_config op
 - fix dv_query_timings
 - add EDID get/set handling
 - remove max-pixel-rate support
 - add audio codec DAI support
 - change audio bindings

 drivers/media/i2c/Kconfig |9 +
 drivers/media/i2c/Makefile|1 +
 drivers/media/i2c/tda1997x.c  | 2822 +
 drivers/media/i2c/tda1997x_regs.h |  641 +
 include/media/i2c/tda1997x.h  |   42 +
 5 files changed, 3515 insertions(+)
 create mode 100644 drivers/media/i2c/tda1997x.c
 create mode 100644 drivers/media/i2c/tda1997x_regs.h
 create mode 100644 include/media/i2c/tda1997x.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index cb5d7ff..3522641 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -56,6 +56,15 @@ config VIDEO_TDA9840
  To compile this driver as a module, choose M here: the
  module will be called tda9840.
 
+config VIDEO_TDA1997X
+   tristate "NXP TDA1997x HDMI receiver"
+   depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
+   ---help---
+ V4L2 subdevice driver for the NXP TDA1997x HDMI receivers.
+
+ To compile this driver as a module, choose M here: the
+ module will be called tda1997x.
+
 config VIDEO_TEA6415C
tristate "Philips TEA6415C audio processor"
depends on I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..adfcae9 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_VIDEO_TVAUDIO) += tvaudio.o
 obj-$(CONFIG_VIDEO_TDA7432) += tda7432.o
 obj-$(CONFIG_VIDEO_SAA6588) += saa6588.o
 obj-$(CONFIG_VIDEO_TDA9840) += tda9840.o
+obj-$(CONFIG_VIDEO_TDA1997X) += tda1997x.o
 obj-$(CONFIG_VIDEO_TEA6415C) += tea6415c.o
 obj-$(CONFIG_VIDEO_TEA6420) += tea6420.o
 obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o
diff --git a/drivers/media/i2c/tda1997x.c b/drivers/media/i2c/tda1997x.c
new file mode 100644
index 000..ce6b694
--- /dev/null
+++ b/drivers/media/i2c/tda1997x.c
@@ -0,0 +1,2822 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Gateworks Corporation
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include