Re: [PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-29 Thread Dmitry Baryshkov

On 28/08/2020 17:18, Vinod Koul wrote:

On 28-08-20, 15:04, Dmitry Baryshkov wrote:

+static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
+   enum drm_bridge_attach_flags flags)
+{
+   struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
+   int ret;
+
+   if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
+   dev_err(lt9611uxc->dev, "Fix bridge driver to make connector 
optional!");


Can we support both modes as I have done in lt9611, that way once the
conversion is done we can drop the init part and support conversion.

I have patch for msm driver to set DRM_BRIDGE_ATTACH_NO_CONNECTOR, you
can use that to test


Probably the message text is misleading. The driver as is does not work 
w/o DRM_BRIDGE_ATTACH_NO_CONNECTOR. Do you plan to push that patch into 
upstream tree?



+static int lt9611uxc_hdmi_hw_params(struct device *dev, void *data,
+struct hdmi_codec_daifmt *fmt,
+struct hdmi_codec_params *hparms)
+{
+   /*
+* LT9611UXC will automatically detect rate and sample size, so no need
+* to setup anything here.
+*/
+   return 0;
+}


Do we need dummy function?


Yes, this callback is mandatory (and audio_shutdown).


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


[PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-29 Thread Dmitry Baryshkov
Add support for Lontium LT9611UXC HDMI bridge. Lontium LT9611UXC is a
DSI to HDMI bridge which supports two DSI ports and I2S port as an input
and HDMI port as output. Despite name being similar to LT9611, these
devices are different enough to warrant separate driver.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/bridge/Kconfig |  13 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 777 +
 3 files changed, 791 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/lontium-lt9611uxc.c

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 3e11af4e9f63..8343fb054652 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -61,6 +61,19 @@ config DRM_LONTIUM_LT9611
  HDMI signals
  Please say Y if you have such hardware.
 
+config DRM_LONTIUM_LT9611UXC
+   tristate "Lontium LT9611UXC DSI/HDMI bridge"
+   select SND_SOC_HDMI_CODEC if SND_SOC
+   depends on OF
+   select DRM_PANEL_BRIDGE
+   select DRM_KMS_HELPER
+   select REGMAP_I2C
+   help
+ Driver for Lontium LT9611UXC DSI to HDMI bridge
+ chip driver that converts dual DSI and I2S to
+ HDMI signals
+ Please say Y if you have such hardware.
+
 config DRM_LVDS_CODEC
tristate "Transparent LVDS encoders and decoders support"
depends on OF
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index c589a6a7cbe1..306850a5899b 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o
 obj-$(CONFIG_DRM_CHRONTEL_CH7033) += chrontel-ch7033.o
 obj-$(CONFIG_DRM_DISPLAY_CONNECTOR) += display-connector.o
 obj-$(CONFIG_DRM_LONTIUM_LT9611) += lontium-lt9611.o
+obj-$(CONFIG_DRM_LONTIUM_LT9611UXC) += lontium-lt9611uxc.o
 obj-$(CONFIG_DRM_LVDS_CODEC) += lvds-codec.o
 obj-$(CONFIG_DRM_MEGACHIPS_STDP_GE_B850V3_FW) += 
megachips-stdp-ge-b850v3-fw.o
 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c 
b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
new file mode 100644
index ..fc363b65590d
--- /dev/null
+++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c
@@ -0,0 +1,777 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-2020. Linaro Limited.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define EDID_BLOCK_SIZE128
+#define EDID_NUM_BLOCKS 2
+
+struct lt9611uxc {
+   struct device *dev;
+   struct drm_bridge bridge;
+
+   struct regmap *regmap;
+   /* Protects all accesses to registers by stopping the on-chip MCU */
+   struct mutex ocm_lock;
+
+   struct device_node *dsi0_node;
+   struct device_node *dsi1_node;
+   struct mipi_dsi_device *dsi0;
+   struct mipi_dsi_device *dsi1;
+   struct platform_device *audio_pdev;
+
+   struct gpio_desc *reset_gpio;
+   struct gpio_desc *enable_gpio;
+
+   bool sleep;
+
+   struct regulator_bulk_data supplies[2];
+
+   struct i2c_client *client;
+
+   bool hpd_supported;
+   struct display_timings *timings;
+   u8 edid_buf[EDID_BLOCK_SIZE * EDID_NUM_BLOCKS];
+};
+
+#define LT9611_PAGE_CONTROL0xff
+
+static const struct regmap_range_cfg lt9611uxc_ranges[] = {
+   {
+   .name = "register_range",
+   .range_min =  0,
+   .range_max = 0xd0ff,
+   .selector_reg = LT9611_PAGE_CONTROL,
+   .selector_mask = 0xff,
+   .selector_shift = 0,
+   .window_start = 0,
+   .window_len = 0x100,
+   },
+};
+
+static const struct regmap_config lt9611uxc_regmap_config = {
+   .reg_bits = 8,
+   .val_bits = 8,
+   .max_register = 0x,
+   .ranges = lt9611uxc_ranges,
+   .num_ranges = ARRAY_SIZE(lt9611uxc_ranges),
+};
+
+struct lt9611uxc_mode {
+   u16 hdisplay;
+   u16 vdisplay;
+   u8 vrefresh;
+   u8 lanes;
+   u8 intfs;
+};
+
+static struct lt9611uxc_mode lt9611uxc_modes[] = {
+   { 3840, 2160, 60, 4, 2 }, /* 3840x2160 24bit 60Hz 4Lane 2ports */
+   { 3840, 2160, 30, 4, 2 }, /* 3840x2160 24bit 30Hz 4Lane 2ports */
+   { 1920, 1080, 60, 4, 1 }, /* 1080P 24bit 60Hz 4lane 1port */
+   { 1920, 1080, 30, 3, 1 }, /* 1080P 24bit 30Hz 3lane 1port */
+   { 1920, 1080, 24, 3, 1 },
+   { 1024, 768, 60, 4, 1},
+   { 800, 600, 60, 4, 1},
+   { 720, 480, 60, 4, 1 },
+   { 720, 576, 50, 2, 1 },
+   { 640, 480, 60, 2, 1 },
+};
+
+static struct lt9611uxc *bridge_to_lt9611uxc(struct drm_bridge *bridge)
+{
+   return container_of(bridge, struct lt9611uxc, bridge);
+}
+

Re: [PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-28 Thread Vinod Koul
On 28-08-20, 18:01, Dmitry Baryshkov wrote:
> On 28/08/2020 17:18, Vinod Koul wrote:
> > On 28-08-20, 15:04, Dmitry Baryshkov wrote:
> > > +static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
> > > + enum drm_bridge_attach_flags flags)
> > > +{
> > > + struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
> > > + int ret;
> > > +
> > > + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
> > > + dev_err(lt9611uxc->dev, "Fix bridge driver to make connector 
> > > optional!");
> > 
> > Can we support both modes as I have done in lt9611, that way once the
> > conversion is done we can drop the init part and support conversion.
> > 
> > I have patch for msm driver to set DRM_BRIDGE_ATTACH_NO_CONNECTOR, you
> > can use that to test
> 
> Probably the message text is misleading. The driver as is does not work w/o
> DRM_BRIDGE_ATTACH_NO_CONNECTOR. Do you plan to push that patch into upstream
> tree?

It causes regression in laptop so have removed it ;( I need to fix that
first
The patch is here though and works on rb3 and db410c.
git.linaro.org/people/vinod.koul/kernel.git drm/no_connector

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


Re: [PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-28 Thread Laurent Pinchart
On Fri, Aug 28, 2020 at 05:33:00PM +0300, Laurent Pinchart wrote:
> On Fri, Aug 28, 2020 at 07:48:48PM +0530, Vinod Koul wrote:
> > On 28-08-20, 15:04, Dmitry Baryshkov wrote:
> > 
> > > +#define EDID_BLOCK_SIZE  128
> > > +#define EDID_NUM_BLOCKS 2
> > 
> > tab or space either one, not both ;)
> > 
> > > +static struct mipi_dsi_device *lt9611uxc_attach_dsi(struct lt9611uxc 
> > > *lt9611uxc,
> > > +  struct device_node *dsi_node)
> > 
> > Please align this with open parenthesis of preceding line (checkpatch
> > with --strict option will check this)
> > 
> > > +static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
> > > + enum drm_bridge_attach_flags flags)
> > > +{
> > > + struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
> > > + int ret;
> > > +
> > > + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
> > > + dev_err(lt9611uxc->dev, "Fix bridge driver to make connector 
> > > optional!");
> > 
> > Can we support both modes as I have done in lt9611, that way once the
> > conversion is done we can drop the init part and support conversion.
> 
> I was going to mention that :-) New drivers should support the
> DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.

Please ignore this comment, I just realized that the driver supports
DRM_BRIDGE_ATTACH_NO_CONNECTOR, it's the !DRM_BRIDGE_ATTACH_NO_CONNECTOR
case that is not supported, and that's totally fine.

> > I have patch for msm driver to set DRM_BRIDGE_ATTACH_NO_CONNECTOR, you
> > can use that to test
> > 
> > > +static int lt9611uxc_hdmi_hw_params(struct device *dev, void *data,
> > > +  struct hdmi_codec_daifmt *fmt,
> > > +  struct hdmi_codec_params *hparms)
> > > +{
> > > + /*
> > > +  * LT9611UXC will automatically detect rate and sample size, so no need
> > > +  * to setup anything here.
> > > +  */
> > > + return 0;
> > > +}
> > 
> > Do we need dummy function?

-- 
Regards,

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


Re: [PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-28 Thread Laurent Pinchart
On Fri, Aug 28, 2020 at 07:48:48PM +0530, Vinod Koul wrote:
> On 28-08-20, 15:04, Dmitry Baryshkov wrote:
> 
> > +#define EDID_BLOCK_SIZE128
> > +#define EDID_NUM_BLOCKS 2
> 
> tab or space either one, not both ;)
> 
> > +static struct mipi_dsi_device *lt9611uxc_attach_dsi(struct lt9611uxc 
> > *lt9611uxc,
> > +struct device_node *dsi_node)
> 
> Please align this with open parenthesis of preceding line (checkpatch
> with --strict option will check this)
> 
> > +static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
> > +   enum drm_bridge_attach_flags flags)
> > +{
> > +   struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
> > +   int ret;
> > +
> > +   if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
> > +   dev_err(lt9611uxc->dev, "Fix bridge driver to make connector 
> > optional!");
> 
> Can we support both modes as I have done in lt9611, that way once the
> conversion is done we can drop the init part and support conversion.

I was going to mention that :-) New drivers should support the
DRM_BRIDGE_ATTACH_NO_CONNECTOR flag.

> I have patch for msm driver to set DRM_BRIDGE_ATTACH_NO_CONNECTOR, you
> can use that to test
> 
> > +static int lt9611uxc_hdmi_hw_params(struct device *dev, void *data,
> > +struct hdmi_codec_daifmt *fmt,
> > +struct hdmi_codec_params *hparms)
> > +{
> > +   /*
> > +* LT9611UXC will automatically detect rate and sample size, so no need
> > +* to setup anything here.
> > +*/
> > +   return 0;
> > +}
> 
> Do we need dummy function?

-- 
Regards,

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


Re: [PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-28 Thread Vinod Koul
On 28-08-20, 15:04, Dmitry Baryshkov wrote:

> +#define EDID_BLOCK_SIZE  128
> +#define EDID_NUM_BLOCKS 2

tab or space either one, not both ;)

> +static struct mipi_dsi_device *lt9611uxc_attach_dsi(struct lt9611uxc 
> *lt9611uxc,
> +  struct device_node *dsi_node)

Please align this with open parenthesis of preceding line (checkpatch
with --strict option will check this)

> +static int lt9611uxc_bridge_attach(struct drm_bridge *bridge,
> + enum drm_bridge_attach_flags flags)
> +{
> + struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
> + int ret;
> +
> + if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
> + dev_err(lt9611uxc->dev, "Fix bridge driver to make connector 
> optional!");

Can we support both modes as I have done in lt9611, that way once the
conversion is done we can drop the init part and support conversion.

I have patch for msm driver to set DRM_BRIDGE_ATTACH_NO_CONNECTOR, you
can use that to test

> +static int lt9611uxc_hdmi_hw_params(struct device *dev, void *data,
> +  struct hdmi_codec_daifmt *fmt,
> +  struct hdmi_codec_params *hparms)
> +{
> + /*
> +  * LT9611UXC will automatically detect rate and sample size, so no need
> +  * to setup anything here.
> +  */
> + return 0;
> +}

Do we need dummy function?

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


Re: [PATCH v1 2/2] drm: bridge: add support for lontium LT9611UXC bridge

2020-08-28 Thread kernel test robot
Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]
[also build test WARNING on next-20200828]
[cannot apply to robh/for-next drm-intel/for-linux-next 
tegra-drm/drm/tegra/for-next linus/master drm-exynos/exynos-drm-next 
drm/drm-next v5.9-rc2]
[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/Dmitry-Baryshkov/Add-LT9611UXC-DSI-to-HDMI-bridge-support/20200828-200735
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# save the attached .config to linux build tree
make W=1 ARCH=i386 

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

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/bridge/lontium-lt9611uxc.c: In function 
'lt9611uxc_video_setup':
>> drivers/gpu/drm/bridge/lontium-lt9611uxc.c:322:49: warning: variable 
>> 'vsync_porch' set but not used [-Wunused-but-set-variable]
 322 |  u32 v_total, vactive, vsync_len, vfront_porch, vsync_porch;
 | ^~~
>> drivers/gpu/drm/bridge/lontium-lt9611uxc.c:321:49: warning: variable 
>> 'hsync_porch' set but not used [-Wunused-but-set-variable]
 321 |  u32 h_total, hactive, hsync_len, hfront_porch, hsync_porch;
 | ^~~
   drivers/gpu/drm/bridge/lontium-lt9611uxc.c: At top level:
>> drivers/gpu/drm/bridge/lontium-lt9611uxc.c:473:14: warning: no previous 
>> prototype for 'lt9611uxc_bridge_get_edid' [-Wmissing-prototypes]
 473 | struct edid *lt9611uxc_bridge_get_edid(struct drm_bridge *bridge,
 |  ^

# 
https://github.com/0day-ci/linux/commit/f1b935d064fd8924137d420e75eb050c3d66c22b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Dmitry-Baryshkov/Add-LT9611UXC-DSI-to-HDMI-bridge-support/20200828-200735
git checkout f1b935d064fd8924137d420e75eb050c3d66c22b
vim +/vsync_porch +322 drivers/gpu/drm/bridge/lontium-lt9611uxc.c

   317  
   318  static void lt9611uxc_video_setup(struct lt9611uxc *lt9611uxc,
   319  const struct drm_display_mode *mode)
   320  {
 > 321  u32 h_total, hactive, hsync_len, hfront_porch, hsync_porch;
 > 322  u32 v_total, vactive, vsync_len, vfront_porch, vsync_porch;
   323  
   324  h_total = mode->htotal;
   325  v_total = mode->vtotal;
   326  
   327  hactive = mode->hdisplay;
   328  hsync_len = mode->hsync_end - mode->hsync_start;
   329  hfront_porch = mode->hsync_start - mode->hdisplay;
   330  hsync_porch = hsync_len + mode->htotal - mode->hsync_end;
   331  
   332  vactive = mode->vdisplay;
   333  vsync_len = mode->vsync_end - mode->vsync_start;
   334  vfront_porch = mode->vsync_start - mode->vdisplay;
   335  vsync_porch = vsync_len + mode->vtotal - mode->vsync_end;
   336  
   337  regmap_write(lt9611uxc->regmap, 0xd00d, (u8)(v_total / 256));
   338  regmap_write(lt9611uxc->regmap, 0xd00e, (u8)(v_total % 256));
   339  
   340  regmap_write(lt9611uxc->regmap, 0xd00f, (u8)(vactive / 256));
   341  regmap_write(lt9611uxc->regmap, 0xd010, (u8)(vactive % 256));
   342  
   343  regmap_write(lt9611uxc->regmap, 0xd011, (u8)(h_total / 256));
   344  regmap_write(lt9611uxc->regmap, 0xd012, (u8)(h_total % 256));
   345  
   346  regmap_write(lt9611uxc->regmap, 0xd013, (u8)(hactive / 256));
   347  regmap_write(lt9611uxc->regmap, 0xd014, (u8)(hactive % 256));
   348  
   349  regmap_write(lt9611uxc->regmap, 0xd015, (u8)(vsync_len % 256));
   350  
   351  regmap_update_bits(lt9611uxc->regmap, 0xd016, 0xf, 
(u8)(hsync_len / 256));
   352  regmap_write(lt9611uxc->regmap, 0xd017, (u8)(hsync_len % 256));
   353  
   354  regmap_update_bits(lt9611uxc->regmap, 0xd018, 0xf, 
(u8)(vfront_porch / 256));
   355  regmap_write(lt9611uxc->regmap, 0xd019, (u8)(vfront_porch % 
256));
   356  
   357  regmap_update_bits(lt9611uxc->regmap, 0xd01a, 0xf, 
(u8)(hfront_porch / 256));
   358  regmap_write(lt9611uxc->regmap, 0xd01b, (u8)(hfront_porch % 
256));
   359  }
   360  
   361  static void lt9611uxc_bridge_mode_set(struct drm_bridge *bridge,
   362 const struct drm_display_mode *mode,
   363 const struct drm_display_mode 
*adj_mode)
   364  {
   365  struct lt9611uxc *lt9611uxc = bridge_to_lt9611uxc(bridge);
   366  
   367  if (lt9611uxc->sleep)
   368  lt9611uxc