Re: [RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2015-02-18 Thread Philipp Zabel
Hi Mats,

Am Dienstag, den 17.02.2015, 16:53 +0100 schrieb Mats Randgaard
(matrandg):
  I think this calculation should include the blanking intervals.
 
 As far as I understand is only the active video from the HDMI interface 
 transferred on the CSI interface, so I think this calculation is 
 correct. We transfer 1080p60 video on four lanes with 823.5 Mbps/lane, 
 which would not have been possible if the blanking should have been 
 transferred as well ((2200 * 1125 * 60 * 24) bps / 823.5 Mbps/lane  = 
 4.33 lanes.

You are right, I confused the reference and minimum suitable CSI
lane speed fields in REF_02. There ought to be _some_ overhead though?
(1920 * 1080 * 60 * 24) bps = 746.496 Mbps, but REF_02 suggests a
minimum of 820.92 Mbps per lane (reference is 891 Mbps as expected).

[...]
  +  i2c_wr32(sd, HSTXVREGEN,
  +  ((lanes  0) ? MASK_CLM_HSTXVREGEN : 0x0) |
  +  ((lanes  0) ? MASK_D0M_HSTXVREGEN : 0x0) |
  +  ((lanes  1) ? MASK_D1M_HSTXVREGEN : 0x0) |
  +  ((lanes  2) ? MASK_D2M_HSTXVREGEN : 0x0) |
  +  ((lanes  3) ? MASK_D3M_HSTXVREGEN : 0x0));
  +
  +  i2c_wr32(sd, TXOPTIONCNTRL, MASK_CONTCLKMODE);
  Since anything below can't be undone without pulling CTXRST, I propose
  to split tc358743_set_csi into tc358743_set_csi (above) and
  tc358743_start_csi (below).
 
  To make this driver work with the Synopsys DesignWare MIPI CSI-2 Host
  Controller, there needs to be a time when the lanes are in stop state
  first, so the host can synchronize. I'd then like to call start_csi in
  s_stream only.
 
 With help from Toshiba we have now implemented start and stop of the CSI 
 interface without pulling CTXRST. You can see our solution in the next 
 RFC, and I would appreciate if you could test if that works fine for you 
 as well!

I'm looking forward to it.

regards
Philipp

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2015-02-17 Thread Mats Randgaard (matrandg)

Thank you again for testing this driver!
I am sorry I haven't had time to prepare a second RFC for this driver, 
but I will try to do that as soon as possible.


On 02/17/2015 09:50 AM, Philipp Zabel wrote:

Hi Mats,

Am Montag, den 15.12.2014, 19:21 +0100 schrieb matra...@cisco.com:
[...]

+static void tc358743_set_pll(struct v4l2_subdev *sd)
+{
+   struct tc358743_state *state = to_state(sd);
+   struct tc358743_platform_data *pdata = state-pdata;
+   u16 pllctl0 = i2c_rd16(sd, PLLCTL0);
+   u16 pllctl0_new = SET_PLL_PRD(pdata-pll_prd) |
+   SET_PLL_FBD(pdata-pll_fbd);
+
+   v4l2_dbg(2, debug, sd, %s:\n, __func__);
+
+   /* Only rewrite when needed, since rewriting triggers another format
+* change event. */
+   if (pllctl0 != pllctl0_new) {
+   u32 hsck = (pdata-refclk_hz * pdata-pll_prd) / pdata-pll_fbd;

This is the wrong way around. refclk_hz is divided by pll_prd to get the
PLL input clock. The PLL then multiplies by pll_fbd. Example:

refclk_hz = 2700, pll_prd = 4, pll_fbd = 88
-- hsck = refclk_hz / pll_prd * pll_fbd = 594 MHz, pll_frs should be 0.


Yes, you are right, and there was a bug in SET_PLL_FRS() as well, so the 
bits where always set to zero. I will fix that!



[...]

+static unsigned tc358743_num_csi_lanes_needed(struct v4l2_subdev *sd)
+{
+   struct tc358743_state *state = to_state(sd);
+   struct v4l2_bt_timings *bt = state-timings.bt;
+   u32 bits_pr_pixel =
+   (state-mbus_fmt_code == MEDIA_BUS_FMT_UYVY8_1X16) ?  16 : 24;
+   u32 bps = bt-width * bt-height * fps(bt) * bits_pr_pixel;

I think this calculation should include the blanking intervals.


As far as I understand is only the active video from the HDMI interface 
transferred on the CSI interface, so I think this calculation is 
correct. We transfer 1080p60 video on four lanes with 823.5 Mbps/lane, 
which would not have been possible if the blanking should have been 
transferred as well ((2200 * 1125 * 60 * 24) bps / 823.5 Mbps/lane  = 
4.33 lanes.



+static void tc358743_set_csi(struct v4l2_subdev *sd)
+{
+   struct tc358743_state *state = to_state(sd);
+   struct tc358743_platform_data *pdata = state-pdata;
+   unsigned lanes = tc358743_num_csi_lanes_needed(sd);
+
+   v4l2_dbg(3, debug, sd, %s:\n, __func__);
+
+   tc358743_reset(sd, MASK_CTXRST);
+
+   if (lanes  1)
+   i2c_wr32(sd, CLW_CNTRL, MASK_CLW_LANEDISABLE);
+   if (lanes  1)
+   i2c_wr32(sd, D0W_CNTRL, MASK_D0W_LANEDISABLE);
+   if (lanes  2)
+   i2c_wr32(sd, D1W_CNTRL, MASK_D1W_LANEDISABLE);
+   if (lanes  3)
+   i2c_wr32(sd, D2W_CNTRL, MASK_D2W_LANEDISABLE);
+   if (lanes  4)
+   i2c_wr32(sd, D3W_CNTRL, MASK_D3W_LANEDISABLE);
+
+   i2c_wr32(sd, LINEINITCNT, pdata-lineinitcnt);
+   i2c_wr32(sd, LPTXTIMECNT, pdata-lptxtimecnt);
+   i2c_wr32(sd, TCLK_HEADERCNT, pdata-tclk_headercnt);
+   i2c_wr32(sd, THS_HEADERCNT, pdata-ths_headercnt);
+   i2c_wr32(sd, TWAKEUP, pdata-twakeup);
+   i2c_wr32(sd, THS_TRAILCNT, pdata-ths_trailcnt);
+   i2c_wr32(sd, HSTXVREGCNT, pdata-hstxvregcnt);
+
+   i2c_wr32(sd, HSTXVREGEN,
+   ((lanes  0) ? MASK_CLM_HSTXVREGEN : 0x0) |
+   ((lanes  0) ? MASK_D0M_HSTXVREGEN : 0x0) |
+   ((lanes  1) ? MASK_D1M_HSTXVREGEN : 0x0) |
+   ((lanes  2) ? MASK_D2M_HSTXVREGEN : 0x0) |
+   ((lanes  3) ? MASK_D3M_HSTXVREGEN : 0x0));
+
+   i2c_wr32(sd, TXOPTIONCNTRL, MASK_CONTCLKMODE);

Since anything below can't be undone without pulling CTXRST, I propose
to split tc358743_set_csi into tc358743_set_csi (above) and
tc358743_start_csi (below).

To make this driver work with the Synopsys DesignWare MIPI CSI-2 Host
Controller, there needs to be a time when the lanes are in stop state
first, so the host can synchronize. I'd then like to call start_csi in
s_stream only.


With help from Toshiba we have now implemented start and stop of the CSI 
interface without pulling CTXRST. You can see our solution in the next 
RFC, and I would appreciate if you could test if that works fine for you 
as well!


Regards,
Mats Randgaard
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2015-02-17 Thread Philipp Zabel
Hi Mats,

Am Montag, den 15.12.2014, 19:21 +0100 schrieb matra...@cisco.com:
[...]
 +static void tc358743_set_pll(struct v4l2_subdev *sd)
 +{
 + struct tc358743_state *state = to_state(sd);
 + struct tc358743_platform_data *pdata = state-pdata;
 + u16 pllctl0 = i2c_rd16(sd, PLLCTL0);
 + u16 pllctl0_new = SET_PLL_PRD(pdata-pll_prd) |
 + SET_PLL_FBD(pdata-pll_fbd);
 +
 + v4l2_dbg(2, debug, sd, %s:\n, __func__);
 +
 + /* Only rewrite when needed, since rewriting triggers another format
 +  * change event. */
 + if (pllctl0 != pllctl0_new) {
 + u32 hsck = (pdata-refclk_hz * pdata-pll_prd) / pdata-pll_fbd;

This is the wrong way around. refclk_hz is divided by pll_prd to get the
PLL input clock. The PLL then multiplies by pll_fbd. Example:

refclk_hz = 2700, pll_prd = 4, pll_fbd = 88
-- hsck = refclk_hz / pll_prd * pll_fbd = 594 MHz, pll_frs should be 0.

[...]
 +static unsigned tc358743_num_csi_lanes_needed(struct v4l2_subdev *sd)
 +{
 + struct tc358743_state *state = to_state(sd);
 + struct v4l2_bt_timings *bt = state-timings.bt;
 + u32 bits_pr_pixel =
 + (state-mbus_fmt_code == MEDIA_BUS_FMT_UYVY8_1X16) ?  16 : 24;
 + u32 bps = bt-width * bt-height * fps(bt) * bits_pr_pixel;

I think this calculation should include the blanking intervals.

 +static void tc358743_set_csi(struct v4l2_subdev *sd)
 +{
 + struct tc358743_state *state = to_state(sd);
 + struct tc358743_platform_data *pdata = state-pdata;
 + unsigned lanes = tc358743_num_csi_lanes_needed(sd);
 +
 + v4l2_dbg(3, debug, sd, %s:\n, __func__);
 +
 + tc358743_reset(sd, MASK_CTXRST);
 +
 + if (lanes  1)
 + i2c_wr32(sd, CLW_CNTRL, MASK_CLW_LANEDISABLE);
 + if (lanes  1)
 + i2c_wr32(sd, D0W_CNTRL, MASK_D0W_LANEDISABLE);
 + if (lanes  2)
 + i2c_wr32(sd, D1W_CNTRL, MASK_D1W_LANEDISABLE);
 + if (lanes  3)
 + i2c_wr32(sd, D2W_CNTRL, MASK_D2W_LANEDISABLE);
 + if (lanes  4)
 + i2c_wr32(sd, D3W_CNTRL, MASK_D3W_LANEDISABLE);
 +
 + i2c_wr32(sd, LINEINITCNT, pdata-lineinitcnt);
 + i2c_wr32(sd, LPTXTIMECNT, pdata-lptxtimecnt);
 + i2c_wr32(sd, TCLK_HEADERCNT, pdata-tclk_headercnt);
 + i2c_wr32(sd, THS_HEADERCNT, pdata-ths_headercnt);
 + i2c_wr32(sd, TWAKEUP, pdata-twakeup);
 + i2c_wr32(sd, THS_TRAILCNT, pdata-ths_trailcnt);
 + i2c_wr32(sd, HSTXVREGCNT, pdata-hstxvregcnt);
 +
 + i2c_wr32(sd, HSTXVREGEN,
 + ((lanes  0) ? MASK_CLM_HSTXVREGEN : 0x0) |
 + ((lanes  0) ? MASK_D0M_HSTXVREGEN : 0x0) |
 + ((lanes  1) ? MASK_D1M_HSTXVREGEN : 0x0) |
 + ((lanes  2) ? MASK_D2M_HSTXVREGEN : 0x0) |
 + ((lanes  3) ? MASK_D3M_HSTXVREGEN : 0x0));
 +
 + i2c_wr32(sd, TXOPTIONCNTRL, MASK_CONTCLKMODE);

Since anything below can't be undone without pulling CTXRST, I propose
to split tc358743_set_csi into tc358743_set_csi (above) and
tc358743_start_csi (below).

To make this driver work with the Synopsys DesignWare MIPI CSI-2 Host
Controller, there needs to be a time when the lanes are in stop state
first, so the host can synchronize. I'd then like to call start_csi in
s_stream only.

 + i2c_wr32(sd, STARTCNTRL, MASK_START);
 + i2c_wr32(sd, CSI_START, MASK_STRT);
 +
 + i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET |
 + MASK_ADDRESS_CSI_CONTROL |
 + MASK_CSI_MODE |
 + MASK_TXHSMD |
 + ((lanes == 4) ? MASK_NOL_4 :
 +  (lanes == 3) ? MASK_NOL_3 :
 +  (lanes == 2) ? MASK_NOL_2 : MASK_NOL_1));
 +
 + i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET |
 + MASK_ADDRESS_CSI_ERR_INTENA | MASK_TXBRK | MASK_QUNK |
 + MASK_WCER | MASK_INER);
 +
 + i2c_wr32(sd, CSI_CONFW, MASK_MODE_CLEAR |
 + MASK_ADDRESS_CSI_ERR_HALT | MASK_TXBRK | MASK_QUNK);
 +
 + i2c_wr32(sd, CSI_CONFW, MASK_MODE_SET |
 + MASK_ADDRESS_CSI_INT_ENA | MASK_INTER);
 +}
[...]

regards
Philipp

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2015-01-08 Thread Mats Randgaard (matrandg)

Thanks for testing the driver!

On 01/08/2015 06:12 PM, Philipp Zabel wrote:

Hi Mats,

Am Montag, den 15.12.2014, 19:21 +0100 schrieb matra...@cisco.com:

From: Mats Randgaard matra...@cisco.com

The driver is tested on our hardware and all the implemented features
works as expected.

Missing features:
- CEC support
- HDCP repeater support
- IR support

Signed-off-by: Mats Randgaard matra...@cisco.com
---
  MAINTAINERS|6 +
  drivers/media/i2c/Kconfig  |   12 +
  drivers/media/i2c/Makefile |1 +
  drivers/media/i2c/tc358743.c   | 1768 
  drivers/media/i2c/tc358743_regs.h  |  670 ++
  include/media/tc358743.h   |   89 ++
  include/uapi/linux/v4l2-controls.h |4 +
  7 files changed, 2550 insertions(+)
  create mode 100644 drivers/media/i2c/tc358743.c
  create mode 100644 drivers/media/i2c/tc358743_regs.h
  create mode 100644 include/media/tc358743.h


[...]

diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
new file mode 100644
index 000..a86cbe0
--- /dev/null
+++ b/drivers/media/i2c/tc358743.c

[...]

+/* --- CUSTOM CTRLS --- */
+
+static const struct v4l2_ctrl_config tc358743_ctrl_audio_sampling_rate = {
+   .id = TC358743_CID_AUDIO_SAMPLING_RATE,
+   .name = Audio sampling rate,
+   .type = V4L2_CTRL_TYPE_INTEGER,
+   .min = 0,
+   .max = 768000,
+   .step = 1,
+   .def = 0,
+   .flags = V4L2_CTRL_FLAG_READ_ONLY,
+};
+
+static const struct v4l2_ctrl_config tc358743_ctrl_audio_present = {
+   .id = TC358743_CID_AUDIO_PRESENT,
+   .name = Audio present,
+   .type = V4L2_CTRL_TYPE_BOOLEAN,

If I don't add
+   .max = 1,
+   .step = 1,
here, I get -ERANGE from v4l2_ctrl_new_custom for this control.


The product I use for testing of this driver has a really old kernel 
where this validation of the boolean controls is missing. I'll fix this 
in the next revision of this driver.


Thanks,

Mats Randgaard



regards
Philipp


--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2015-01-08 Thread Philipp Zabel
Hi Mats,

Am Montag, den 15.12.2014, 19:21 +0100 schrieb matra...@cisco.com:
 From: Mats Randgaard matra...@cisco.com
 
 The driver is tested on our hardware and all the implemented features
 works as expected.
 
 Missing features:
 - CEC support
 - HDCP repeater support
 - IR support
 
 Signed-off-by: Mats Randgaard matra...@cisco.com
 ---
  MAINTAINERS|6 +
  drivers/media/i2c/Kconfig  |   12 +
  drivers/media/i2c/Makefile |1 +
  drivers/media/i2c/tc358743.c   | 1768 
 
  drivers/media/i2c/tc358743_regs.h  |  670 ++
  include/media/tc358743.h   |   89 ++
  include/uapi/linux/v4l2-controls.h |4 +
  7 files changed, 2550 insertions(+)
  create mode 100644 drivers/media/i2c/tc358743.c
  create mode 100644 drivers/media/i2c/tc358743_regs.h
  create mode 100644 include/media/tc358743.h
 
[...]
 diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
 new file mode 100644
 index 000..a86cbe0
 --- /dev/null
 +++ b/drivers/media/i2c/tc358743.c
[...]
 +/* --- CUSTOM CTRLS --- */
 +
 +static const struct v4l2_ctrl_config tc358743_ctrl_audio_sampling_rate = {
 + .id = TC358743_CID_AUDIO_SAMPLING_RATE,
 + .name = Audio sampling rate,
 + .type = V4L2_CTRL_TYPE_INTEGER,
 + .min = 0,
 + .max = 768000,
 + .step = 1,
 + .def = 0,
 + .flags = V4L2_CTRL_FLAG_READ_ONLY,
 +};
 +
 +static const struct v4l2_ctrl_config tc358743_ctrl_audio_present = {
 + .id = TC358743_CID_AUDIO_PRESENT,
 + .name = Audio present,
 + .type = V4L2_CTRL_TYPE_BOOLEAN,

If I don't add
+   .max = 1,
+   .step = 1,
here, I get -ERANGE from v4l2_ctrl_new_custom for this control.

regards
Philipp

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2014-12-17 Thread Hans Verkuil
Hi Mats,

Some review comments...

On 12/15/14 19:21, matra...@cisco.com wrote:
 From: Mats Randgaard matra...@cisco.com
 
 The driver is tested on our hardware and all the implemented features
 works as expected.
 
 Missing features:
 - CEC support
 - HDCP repeater support
 - IR support
 
 Signed-off-by: Mats Randgaard matra...@cisco.com
 ---
  MAINTAINERS|6 +
  drivers/media/i2c/Kconfig  |   12 +
  drivers/media/i2c/Makefile |1 +
  drivers/media/i2c/tc358743.c   | 1768 
 
  drivers/media/i2c/tc358743_regs.h  |  670 ++
  include/media/tc358743.h   |   89 ++
  include/uapi/linux/v4l2-controls.h |4 +
  7 files changed, 2550 insertions(+)
  create mode 100644 drivers/media/i2c/tc358743.c
  create mode 100644 drivers/media/i2c/tc358743_regs.h
  create mode 100644 include/media/tc358743.h
 
 diff --git a/MAINTAINERS b/MAINTAINERS
 index 9c49eb6..7608a83 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -9448,6 +9448,12 @@ L: platform-driver-...@vger.kernel.org
  S:   Orphan
  F:   drivers/platform/x86/toshiba_acpi.c
  
 +TOSHIBA TC358743 DRIVER
 +M:   Mats Randgaard matra...@cisco.com
 +L:   linux-media@vger.kernel.org
 +S:   Maintained
 +F:   drivers/media/i2c/tc358743*
 +
  TOSHIBA SMM DRIVER
  M:   Jonathan Buzzard jonat...@buzzard.org.uk
  L:   tlinux-us...@tce.toshiba-dme.co.jp
 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
 index f40b4cf..0103cdf 100644
 --- a/drivers/media/i2c/Kconfig
 +++ b/drivers/media/i2c/Kconfig
 @@ -293,6 +293,18 @@ config VIDEO_SAA7191
 To compile this driver as a module, choose M here: the
 module will be called saa7191.
  
 +config VIDEO_TC358743
 + tristate Toshiba TC358743 decoder
 + depends on VIDEO_V4L2  I2C
 + ---help---
 +   Support for the Toshiba TC358743 HDMI to MIPI CSI-2 bridge
 +
 +   This is a Analog Devices Component/Graphics Digitizer
 +   with 4:1 Multiplexed HDMI Receiver.

Copy-and-paste leftover :-)

 +
 +   To compile this driver as a module, choose M here: the
 +   module will be called tc358743.
 +
  config VIDEO_TVP514X
   tristate Texas Instruments TVP514x video decoder
   depends on VIDEO_V4L2  I2C
 diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
 index 01ae932..b4dea43 100644
 --- a/drivers/media/i2c/Makefile
 +++ b/drivers/media/i2c/Makefile
 @@ -78,3 +78,4 @@ obj-$(CONFIG_VIDEO_SMIAPP_PLL)  += smiapp-pll.o
  obj-$(CONFIG_VIDEO_AK881X)   += ak881x.o
  obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
  obj-$(CONFIG_VIDEO_ML86V7667)+= ml86v7667.o
 +obj-$(CONFIG_VIDEO_TC358743) += tc358743.o
 diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
 new file mode 100644
 index 000..a86cbe0
 --- /dev/null
 +++ b/drivers/media/i2c/tc358743.c
 @@ -0,0 +1,1768 @@
 +/*
 + * tc358743 - Toshiba HDMI to CSI-2 bridge
 + *
 + * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights
 + * reserved.
 + *
 + * This program is free software; you may redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; version 2 of the License.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 + * SOFTWARE.
 + *
 + */
 +
 +/*
 + * References (c = chapter, p = page):
 + * REF_01 - Toshiba, TC358743XBG (H2C), Functional Specification, Rev 0.60
 + * REF_02 - Toshiba, TC358743XBG_HDMI-CSI_Tv11p_nm.xls
 + */
 +
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/i2c.h
 +#include linux/delay.h
 +#include linux/videodev2.h
 +#include linux/workqueue.h
 +#include linux/v4l2-dv-timings.h
 +#include media/v4l2-dv-timings.h
 +#include media/v4l2-device.h
 +#include media/v4l2-ctrls.h
 +#include media/tc358743.h
 +
 +#include tc358743_regs.h
 +
 +static int debug;
 +module_param(debug, int, 0644);
 +MODULE_PARM_DESC(debug, debug level (0-3));
 +
 +MODULE_DESCRIPTION(Toshiba TC358743 HDMI to CSI-2 bridge driver);
 +MODULE_AUTHOR(Ramakrishnan Muthukrishnan r...@rkrishnan.org);
 +MODULE_AUTHOR(Mikhail Khelik mkhe...@cisco.com);
 +MODULE_AUTHOR(Mats Randgaard matra...@cisco.com);
 +MODULE_LICENSE(GPL);
 +
 +static const struct v4l2_dv_timings_cap tc358743_timings_cap = {
 + .type = V4L2_DV_BT_656_1120,
 + /* keep this initialization for compatibility with GCC  4.4.6 */
 + .reserved = { 0 },
 + /* Pixel clock from REF_01 p. 20. Min/max height/width are unknown */
 + 

[RFC v01] Driver for Toshiba TC358743 CSI-2 to HDMI bridge

2014-12-15 Thread matrandg
From: Mats Randgaard matra...@cisco.com

The driver is tested on our hardware and all the implemented features
works as expected.

Missing features:
- CEC support
- HDCP repeater support
- IR support

Signed-off-by: Mats Randgaard matra...@cisco.com
---
 MAINTAINERS|6 +
 drivers/media/i2c/Kconfig  |   12 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/tc358743.c   | 1768 
 drivers/media/i2c/tc358743_regs.h  |  670 ++
 include/media/tc358743.h   |   89 ++
 include/uapi/linux/v4l2-controls.h |4 +
 7 files changed, 2550 insertions(+)
 create mode 100644 drivers/media/i2c/tc358743.c
 create mode 100644 drivers/media/i2c/tc358743_regs.h
 create mode 100644 include/media/tc358743.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 9c49eb6..7608a83 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9448,6 +9448,12 @@ L:   platform-driver-...@vger.kernel.org
 S: Orphan
 F: drivers/platform/x86/toshiba_acpi.c
 
+TOSHIBA TC358743 DRIVER
+M: Mats Randgaard matra...@cisco.com
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/i2c/tc358743*
+
 TOSHIBA SMM DRIVER
 M: Jonathan Buzzard jonat...@buzzard.org.uk
 L: tlinux-us...@tce.toshiba-dme.co.jp
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index f40b4cf..0103cdf 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -293,6 +293,18 @@ config VIDEO_SAA7191
  To compile this driver as a module, choose M here: the
  module will be called saa7191.
 
+config VIDEO_TC358743
+   tristate Toshiba TC358743 decoder
+   depends on VIDEO_V4L2  I2C
+   ---help---
+ Support for the Toshiba TC358743 HDMI to MIPI CSI-2 bridge
+
+ This is a Analog Devices Component/Graphics Digitizer
+ with 4:1 Multiplexed HDMI Receiver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called tc358743.
+
 config VIDEO_TVP514X
tristate Texas Instruments TVP514x video decoder
depends on VIDEO_V4L2  I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 01ae932..b4dea43 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -78,3 +78,4 @@ obj-$(CONFIG_VIDEO_SMIAPP_PLL)+= smiapp-pll.o
 obj-$(CONFIG_VIDEO_AK881X) += ak881x.o
 obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
 obj-$(CONFIG_VIDEO_ML86V7667)  += ml86v7667.o
+obj-$(CONFIG_VIDEO_TC358743)   += tc358743.o
diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
new file mode 100644
index 000..a86cbe0
--- /dev/null
+++ b/drivers/media/i2c/tc358743.c
@@ -0,0 +1,1768 @@
+/*
+ * tc358743 - Toshiba HDMI to CSI-2 bridge
+ *
+ * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights
+ * reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * References (c = chapter, p = page):
+ * REF_01 - Toshiba, TC358743XBG (H2C), Functional Specification, Rev 0.60
+ * REF_02 - Toshiba, TC358743XBG_HDMI-CSI_Tv11p_nm.xls
+ */
+
+#include linux/kernel.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/i2c.h
+#include linux/delay.h
+#include linux/videodev2.h
+#include linux/workqueue.h
+#include linux/v4l2-dv-timings.h
+#include media/v4l2-dv-timings.h
+#include media/v4l2-device.h
+#include media/v4l2-ctrls.h
+#include media/tc358743.h
+
+#include tc358743_regs.h
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, debug level (0-3));
+
+MODULE_DESCRIPTION(Toshiba TC358743 HDMI to CSI-2 bridge driver);
+MODULE_AUTHOR(Ramakrishnan Muthukrishnan r...@rkrishnan.org);
+MODULE_AUTHOR(Mikhail Khelik mkhe...@cisco.com);
+MODULE_AUTHOR(Mats Randgaard matra...@cisco.com);
+MODULE_LICENSE(GPL);
+
+static const struct v4l2_dv_timings_cap tc358743_timings_cap = {
+   .type = V4L2_DV_BT_656_1120,
+   /* keep this initialization for compatibility with GCC  4.4.6 */
+   .reserved = { 0 },
+   /* Pixel clock from REF_01 p. 20. Min/max height/width are unknown */
+   V4L2_INIT_BT_TIMINGS(1, 1, 1, 1, 0, 16500,
+   V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
+   V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
+