[PATCH v6] drm/rockchip: hdmi: add Innosilicon HDMI support

2016-01-26 Thread Yakir Yang
Hi Paul,

On 01/26/2016 08:45 AM, Paul Bolle wrote:
> On ma, 2016-01-25 at 09:47 +0800, Yakir Yang wrote:
>> --- a/drivers/gpu/drm/rockchip/Kconfig
>> +++ b/drivers/gpu/drm/rockchip/Kconfig
>> +config ROCKCHIP_INNO_HDMI
>> +tristate "Rockchip specific extensions for Innosilicon HDMI"
>> +depends on DRM_ROCKCHIP
>> +help
>> +  This selects support for Rockchip SoC specific extensions
>> +  for the Innosilicon HDMI driver. If you want to enable
>> +  HDMI on RK3036 based SoC, you should selet this option.
> (Really trivial: start indentation with tabs only, please. And
> s/selet/select/.)
Got it
>> --- /dev/null
>> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
>> + * This software is licensed under the terms of the GNU General
>> Public
>> + * License version 2, as published by the Free Software Foundation,
>> and
>> + * may be copied, distributed, and modified under those terms.
> This states this file is licensed GPL v2 only.
>
>> +MODULE_LICENSE("GPL");
> And, according to include/linux/module.h, this means "GNU Public License
> v2 or later".
>
> So I think there's a (subtle) mismatch between the license ident used
> for this driver and the comment above.

Ah, thanks.

- Yakir

> Thanks,
>
>
> Paul Bolle
>
>
>




[PATCH v6] drm/rockchip: hdmi: add Innosilicon HDMI support

2016-01-26 Thread Paul Bolle
On ma, 2016-01-25 at 09:47 +0800, Yakir Yang wrote:
> --- a/drivers/gpu/drm/rockchip/Kconfig
> +++ b/drivers/gpu/drm/rockchip/Kconfig

> +config ROCKCHIP_INNO_HDMI
> + tristate "Rockchip specific extensions for Innosilicon HDMI"
> +depends on DRM_ROCKCHIP
> +help
> +   This selects support for Rockchip SoC specific extensions
> +   for the Innosilicon HDMI driver. If you want to enable
> +   HDMI on RK3036 based SoC, you should selet this option.

(Really trivial: start indentation with tabs only, please. And
s/selet/select/.)

> --- /dev/null
> +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c

> + * This software is licensed under the terms of the GNU General
> Public
> + * License version 2, as published by the Free Software Foundation,
> and
> + * may be copied, distributed, and modified under those terms.

This states this file is licensed GPL v2 only.

> +MODULE_LICENSE("GPL");

And, according to include/linux/module.h, this means "GNU Public License
v2 or later".

So I think there's a (subtle) mismatch between the license ident used
for this driver and the comment above.

Thanks,


Paul Bolle


[PATCH v6] drm/rockchip: hdmi: add Innosilicon HDMI support

2016-01-25 Thread Yakir Yang
The Innosilicon HDMI is a low power HDMI 1.4 transmitter
IP, and it have been integrated on some rockchip CPUs
(like RK3036, RK312x).

Signed-off-by: Yakir Yang 
---
Changes in v6:
- Rebase the Makefile/Kconfig files which add by Chris's rockchip-mipi driver 
(Caeser)

Changes in v5:
- Use hdmi_infoframe helper functions to packed the infoframe (Russell)
- Remove the unused double wait_for_completion_timeout for ddc transfer 
(Russell)
- Remove the unused local variable in "inno_hdmi_i2c_write()" function (Russell)

Changes in v4:
- Modify the commit title "drm/rockchip: hdmi: ..." (Mark)
- Correct the "DKMS" to "DPMS" (Mark)
- Fix over 80 characters problems (Mark)
- Remove encoder .prepare/.commit helper functions, and move the vop mode
configure function into encoder .enable helper functions. (Mark)

Changes in v3:
- Use encoder enable/disable function, and remove the encoder DPMS function
- Keep HDMI PLL power on in standby mode

Changes in v2:
- Using DRM atomic helper functions for connector init (Mark)
- Remove "hdmi->connector.encoder = encoder;" (Mark)

 drivers/gpu/drm/rockchip/Kconfig |   8 +
 drivers/gpu/drm/rockchip/Makefile|   1 +
 drivers/gpu/drm/rockchip/inno_hdmi.c | 941 +++
 drivers/gpu/drm/rockchip/inno_hdmi.h | 362 ++
 4 files changed, 1312 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/inno_hdmi.c
 create mode 100644 drivers/gpu/drm/rockchip/inno_hdmi.h

diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 8573985..e15bf47 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -35,3 +35,11 @@ config ROCKCHIP_DW_MIPI_DSI
 for the Synopsys DesignWare HDMI driver. If you want to
 enable MIPI DSI on RK3288 based SoC, you should selet this
 option.
+
+config ROCKCHIP_INNO_HDMI
+   tristate "Rockchip specific extensions for Innosilicon HDMI"
+depends on DRM_ROCKCHIP
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Innosilicon HDMI driver. If you want to enable
+ HDMI on RK3036 based SoC, you should selet this option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index f6a809a..df8fbef 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -8,5 +8,6 @@ rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += 
rockchip_drm_fbdev.o

 obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
 obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
+obj-$(CONFIG_ROCKCHIP_INNO_HDMI) += inno_hdmi.o

 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_vop_reg.o
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c 
b/drivers/gpu/drm/rockchip/inno_hdmi.c
new file mode 100644
index 000..4da3020
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
@@ -0,0 +1,941 @@
+/*
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ *Zheng Yang 
+ *Yakir Yang 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#include "inno_hdmi.h"
+
+#define to_inno_hdmi(x)container_of(x, struct inno_hdmi, x)
+
+struct hdmi_data_info {
+   int vic;
+   bool sink_is_hdmi;
+   bool sink_has_audio;
+   unsigned int enc_in_format;
+   unsigned int enc_out_format;
+   unsigned int colorimetry;
+};
+
+struct inno_hdmi_i2c {
+   struct i2c_adapter adap;
+
+   u8 ddc_addr;
+   u8 segment_addr;
+
+   struct mutex lock;
+   struct completion cmp;
+};
+
+struct inno_hdmi {
+   struct device *dev;
+   struct drm_device *drm_dev;
+
+   int irq;
+   struct clk *pclk;
+   void __iomem *regs;
+
+   struct drm_connectorconnector;
+   struct drm_encoder  encoder;
+
+   struct inno_hdmi_i2c *i2c;
+   struct i2c_adapter *ddc;
+
+   unsigned int tmds_rate;
+
+   struct hdmi_data_info   hdmi_data;
+   struct drm_display_mode previous_mode;
+};
+
+enum {
+   CSC_ITU601_16_235_TO_RGB_0_255_8BIT,
+   CSC_ITU601_0_255_TO_RGB_0_255_8BIT,
+   CSC_ITU709_16_235_TO_RGB_0_255_8BIT,
+   CSC_RGB_0_255_TO_ITU601_16_235_8BIT,
+   CSC_RGB_0_255_TO_ITU709_16_235_8BIT,
+   CSC_RGB_0_255_TO_RGB_16_235_8BIT,
+};
+
+static const char coeff_csc[][24] = {
+   /*
+* YUV2RGB:601 SD mode(Y[16:235