mirror of
https://github.com/Fishwaldo/build.git
synced 2025-07-08 14:08:26 +00:00
[ sunxi-dev ] more patch cleanup
This commit is contained in:
parent
daf372bb77
commit
83c4413801
4 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,403 @@
|
|||
From d1f75332d44f26e734985493c134a727c79cb1f1 Mon Sep 17 00:00:00 2001
|
||||
From: Icenowy Zheng <icenowy@aosc.io>
|
||||
Date: Thu, 18 Oct 2018 15:33:21 +0800
|
||||
Subject: [PATCH 128/146] drm/bridge: extract some Analogix I2C DP common code
|
||||
|
||||
Some code can be shared within different DP bridges by Analogix.
|
||||
|
||||
Extract them to a new module.
|
||||
|
||||
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
|
||||
---
|
||||
drivers/gpu/drm/bridge/analogix/Kconfig | 4 +
|
||||
drivers/gpu/drm/bridge/analogix/Makefile | 2 +
|
||||
.../drm/bridge/analogix/analogix-anx78xx.c | 146 +--------------
|
||||
.../drm/bridge/analogix/analogix-i2c-dptx.c | 169 ++++++++++++++++++
|
||||
.../drm/bridge/analogix/analogix-i2c-dptx.h | 2 +
|
||||
5 files changed, 178 insertions(+), 145 deletions(-)
|
||||
create mode 100644 drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c
|
||||
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
|
||||
index 27b37aa2ea77..eb893b465dd8 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
|
||||
@@ -2,8 +2,12 @@ config DRM_ANALOGIX_DP
|
||||
tristate
|
||||
depends on DRM
|
||||
|
||||
+config DRM_ANALOGIX_DP_I2C
|
||||
+ tristate
|
||||
+
|
||||
config DRM_ANALOGIX_ANX78XX
|
||||
tristate "Analogix ANX78XX bridge"
|
||||
+ select DRM_ANALOGIX_DP_I2C
|
||||
select DRM_KMS_HELPER
|
||||
select REGMAP_I2C
|
||||
---help---
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile b/drivers/gpu/drm/bridge/analogix/Makefile
|
||||
index eb41be845055..c37e2ded8ce3 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/Makefile
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
|
||||
@@ -1,3 +1,5 @@
|
||||
analogix_dp-objs := analogix_dp_core.o analogix_dp_reg.o
|
||||
+analogix_dp_i2c-objs := analogix-i2c-dptx.o
|
||||
obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
|
||||
+obj-$(CONFIG_DRM_ANALOGIX_DP_I2C) += analogix_dp_i2c.o
|
||||
obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
|
||||
index f8433c93f463..bf8291d0ddd0 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
|
||||
@@ -45,8 +45,6 @@
|
||||
#define I2C_IDX_RX_P1 4
|
||||
|
||||
#define XTAL_CLK 270 /* 27M */
|
||||
-#define AUX_CH_BUFFER_SIZE 16
|
||||
-#define AUX_WAIT_TIMEOUT_MS 15
|
||||
|
||||
static const u8 anx78xx_i2c_addresses[] = {
|
||||
[I2C_IDX_TX_P0] = TX_P0,
|
||||
@@ -109,153 +107,11 @@ static int anx78xx_clear_bits(struct regmap *map, u8 reg, u8 mask)
|
||||
return regmap_update_bits(map, reg, mask, 0);
|
||||
}
|
||||
|
||||
-static bool anx78xx_aux_op_finished(struct anx78xx *anx78xx)
|
||||
-{
|
||||
- unsigned int value;
|
||||
- int err;
|
||||
-
|
||||
- err = regmap_read(anx78xx->map[I2C_IDX_TX_P0], SP_DP_AUX_CH_CTRL2_REG,
|
||||
- &value);
|
||||
- if (err < 0)
|
||||
- return false;
|
||||
-
|
||||
- return (value & SP_AUX_EN) == 0;
|
||||
-}
|
||||
-
|
||||
-static int anx78xx_aux_wait(struct anx78xx *anx78xx)
|
||||
-{
|
||||
- unsigned long timeout;
|
||||
- unsigned int status;
|
||||
- int err;
|
||||
-
|
||||
- timeout = jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1;
|
||||
-
|
||||
- while (!anx78xx_aux_op_finished(anx78xx)) {
|
||||
- if (time_after(jiffies, timeout)) {
|
||||
- if (!anx78xx_aux_op_finished(anx78xx)) {
|
||||
- DRM_ERROR("Timed out waiting AUX to finish\n");
|
||||
- return -ETIMEDOUT;
|
||||
- }
|
||||
-
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- usleep_range(1000, 2000);
|
||||
- }
|
||||
-
|
||||
- /* Read the AUX channel access status */
|
||||
- err = regmap_read(anx78xx->map[I2C_IDX_TX_P0], SP_AUX_CH_STATUS_REG,
|
||||
- &status);
|
||||
- if (err < 0) {
|
||||
- DRM_ERROR("Failed to read from AUX channel: %d\n", err);
|
||||
- return err;
|
||||
- }
|
||||
-
|
||||
- if (status & SP_AUX_STATUS) {
|
||||
- DRM_ERROR("Failed to wait for AUX channel (status: %02x)\n",
|
||||
- status);
|
||||
- return -ETIMEDOUT;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static int anx78xx_aux_address(struct anx78xx *anx78xx, unsigned int addr)
|
||||
-{
|
||||
- int err;
|
||||
-
|
||||
- err = regmap_write(anx78xx->map[I2C_IDX_TX_P0], SP_AUX_ADDR_7_0_REG,
|
||||
- addr & 0xff);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- err = regmap_write(anx78xx->map[I2C_IDX_TX_P0], SP_AUX_ADDR_15_8_REG,
|
||||
- (addr & 0xff00) >> 8);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- /*
|
||||
- * DP AUX CH Address Register #2, only update bits[3:0]
|
||||
- * [7:4] RESERVED
|
||||
- * [3:0] AUX_ADDR[19:16], Register control AUX CH address.
|
||||
- */
|
||||
- err = regmap_update_bits(anx78xx->map[I2C_IDX_TX_P0],
|
||||
- SP_AUX_ADDR_19_16_REG,
|
||||
- SP_AUX_ADDR_19_16_MASK,
|
||||
- (addr & 0xf0000) >> 16);
|
||||
-
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
static ssize_t anx78xx_aux_transfer(struct drm_dp_aux *aux,
|
||||
struct drm_dp_aux_msg *msg)
|
||||
{
|
||||
struct anx78xx *anx78xx = container_of(aux, struct anx78xx, aux);
|
||||
- u8 ctrl1 = msg->request;
|
||||
- u8 ctrl2 = SP_AUX_EN;
|
||||
- u8 *buffer = msg->buffer;
|
||||
- int err;
|
||||
-
|
||||
- /* The DP AUX transmit and receive buffer has 16 bytes. */
|
||||
- if (WARN_ON(msg->size > AUX_CH_BUFFER_SIZE))
|
||||
- return -E2BIG;
|
||||
-
|
||||
- /* Zero-sized messages specify address-only transactions. */
|
||||
- if (msg->size < 1)
|
||||
- ctrl2 |= SP_ADDR_ONLY;
|
||||
- else /* For non-zero-sized set the length field. */
|
||||
- ctrl1 |= (msg->size - 1) << SP_AUX_LENGTH_SHIFT;
|
||||
-
|
||||
- if ((msg->request & DP_AUX_I2C_READ) == 0) {
|
||||
- /* When WRITE | MOT write values to data buffer */
|
||||
- err = regmap_bulk_write(anx78xx->map[I2C_IDX_TX_P0],
|
||||
- SP_DP_BUF_DATA0_REG, buffer,
|
||||
- msg->size);
|
||||
- if (err)
|
||||
- return err;
|
||||
- }
|
||||
-
|
||||
- /* Write address and request */
|
||||
- err = anx78xx_aux_address(anx78xx, msg->address);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- err = regmap_write(anx78xx->map[I2C_IDX_TX_P0], SP_DP_AUX_CH_CTRL1_REG,
|
||||
- ctrl1);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- /* Start transaction */
|
||||
- err = regmap_update_bits(anx78xx->map[I2C_IDX_TX_P0],
|
||||
- SP_DP_AUX_CH_CTRL2_REG, SP_ADDR_ONLY |
|
||||
- SP_AUX_EN, ctrl2);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- err = anx78xx_aux_wait(anx78xx);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- msg->reply = DP_AUX_I2C_REPLY_ACK;
|
||||
-
|
||||
- if ((msg->size > 0) && (msg->request & DP_AUX_I2C_READ)) {
|
||||
- /* Read values from data buffer */
|
||||
- err = regmap_bulk_read(anx78xx->map[I2C_IDX_TX_P0],
|
||||
- SP_DP_BUF_DATA0_REG, buffer,
|
||||
- msg->size);
|
||||
- if (err)
|
||||
- return err;
|
||||
- }
|
||||
-
|
||||
- err = anx78xx_clear_bits(anx78xx->map[I2C_IDX_TX_P0],
|
||||
- SP_DP_AUX_CH_CTRL2_REG, SP_ADDR_ONLY);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- return msg->size;
|
||||
+ return anx_aux_transfer(anx78xx->map[I2C_IDX_TX_P0], msg);
|
||||
}
|
||||
|
||||
static int anx78xx_set_hpd(struct anx78xx *anx78xx)
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c
|
||||
new file mode 100644
|
||||
index 000000000000..9cb30962032e
|
||||
--- /dev/null
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c
|
||||
@@ -0,0 +1,169 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright(c) 2017 Icenowy Zheng <icenowy@aosc.io>
|
||||
+ *
|
||||
+ * Based on analogix-anx78xx.c, which is:
|
||||
+ * Copyright(c) 2016, Analogix Semiconductor. All rights reserved.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/regmap.h>
|
||||
+
|
||||
+#include <drm/drm.h>
|
||||
+#include <drm/drm_drv.h>
|
||||
+#include <drm/drm_dp_helper.h>
|
||||
+
|
||||
+#include "analogix-i2c-dptx.h"
|
||||
+
|
||||
+#define AUX_WAIT_TIMEOUT_MS 15
|
||||
+#define AUX_CH_BUFFER_SIZE 16
|
||||
+
|
||||
+static int anx_clear_bits(struct regmap *map, u8 reg, u8 mask)
|
||||
+{
|
||||
+ return regmap_update_bits(map, reg, mask, 0);
|
||||
+}
|
||||
+
|
||||
+static bool anx_aux_op_finished(struct regmap *map_dptx)
|
||||
+{
|
||||
+ unsigned int value;
|
||||
+ int err;
|
||||
+
|
||||
+ err = regmap_read(map_dptx, SP_DP_AUX_CH_CTRL2_REG, &value);
|
||||
+ if (err < 0)
|
||||
+ return false;
|
||||
+
|
||||
+ return (value & SP_AUX_EN) == 0;
|
||||
+}
|
||||
+
|
||||
+static int anx_aux_wait(struct regmap *map_dptx)
|
||||
+{
|
||||
+ unsigned long timeout;
|
||||
+ unsigned int status;
|
||||
+ int err;
|
||||
+
|
||||
+ timeout = jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1;
|
||||
+
|
||||
+ while (!anx_aux_op_finished(map_dptx)) {
|
||||
+ if (time_after(jiffies, timeout)) {
|
||||
+ if (!anx_aux_op_finished(map_dptx)) {
|
||||
+ DRM_ERROR("Timed out waiting AUX to finish\n");
|
||||
+ return -ETIMEDOUT;
|
||||
+ }
|
||||
+
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ usleep_range(1000, 2000);
|
||||
+ }
|
||||
+
|
||||
+ /* Read the AUX channel access status */
|
||||
+ err = regmap_read(map_dptx, SP_AUX_CH_STATUS_REG, &status);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Failed to read from AUX channel: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ if (status & SP_AUX_STATUS) {
|
||||
+ DRM_ERROR("Failed to wait for AUX channel (status: %02x)\n",
|
||||
+ status);
|
||||
+ return -ETIMEDOUT;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int anx_aux_address(struct regmap *map_dptx, unsigned int addr)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ err = regmap_write(map_dptx, SP_AUX_ADDR_7_0_REG, addr & 0xff);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(map_dptx, SP_AUX_ADDR_15_8_REG,
|
||||
+ (addr & 0xff00) >> 8);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /*
|
||||
+ * DP AUX CH Address Register #2, only update bits[3:0]
|
||||
+ * [7:4] RESERVED
|
||||
+ * [3:0] AUX_ADDR[19:16], Register control AUX CH address.
|
||||
+ */
|
||||
+ err = regmap_update_bits(map_dptx, SP_AUX_ADDR_19_16_REG,
|
||||
+ SP_AUX_ADDR_19_16_MASK,
|
||||
+ (addr & 0xf0000) >> 16);
|
||||
+
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+ssize_t anx_aux_transfer(struct regmap *map_dptx, struct drm_dp_aux_msg *msg)
|
||||
+{
|
||||
+ u8 ctrl1 = msg->request;
|
||||
+ u8 ctrl2 = SP_AUX_EN;
|
||||
+ u8 *buffer = msg->buffer;
|
||||
+ int err;
|
||||
+
|
||||
+ /* The DP AUX transmit and receive buffer has 16 bytes. */
|
||||
+ if (WARN_ON(msg->size > AUX_CH_BUFFER_SIZE))
|
||||
+ return -E2BIG;
|
||||
+
|
||||
+ /* Zero-sized messages specify address-only transactions. */
|
||||
+ if (msg->size < 1)
|
||||
+ ctrl2 |= SP_ADDR_ONLY;
|
||||
+ else /* For non-zero-sized set the length field. */
|
||||
+ ctrl1 |= (msg->size - 1) << SP_AUX_LENGTH_SHIFT;
|
||||
+
|
||||
+ if ((msg->request & DP_AUX_I2C_READ) == 0) {
|
||||
+ /* When WRITE | MOT write values to data buffer */
|
||||
+ err = regmap_bulk_write(map_dptx,
|
||||
+ SP_DP_BUF_DATA0_REG, buffer,
|
||||
+ msg->size);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Write address and request */
|
||||
+ err = anx_aux_address(map_dptx, msg->address);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(map_dptx, SP_DP_AUX_CH_CTRL1_REG, ctrl1);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Start transaction */
|
||||
+ err = regmap_update_bits(map_dptx, SP_DP_AUX_CH_CTRL2_REG,
|
||||
+ SP_ADDR_ONLY | SP_AUX_EN, ctrl2);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = anx_aux_wait(map_dptx);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ msg->reply = DP_AUX_I2C_REPLY_ACK;
|
||||
+
|
||||
+ if ((msg->size > 0) && (msg->request & DP_AUX_I2C_READ)) {
|
||||
+ /* Read values from data buffer */
|
||||
+ err = regmap_bulk_read(map_dptx,
|
||||
+ SP_DP_BUF_DATA0_REG, buffer,
|
||||
+ msg->size);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ err = anx_clear_bits(map_dptx, SP_DP_AUX_CH_CTRL2_REG, SP_ADDR_ONLY);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return msg->size;
|
||||
+}
|
||||
+EXPORT_SYMBOL(anx_aux_transfer);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Analogix DisplayPort Transmitter common code");
|
||||
+MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.io>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h
|
||||
index bc0831b127bf..c2ca854613a0 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h
|
||||
@@ -245,4 +245,6 @@
|
||||
/* DP AUX Buffer Data Registers */
|
||||
#define SP_DP_BUF_DATA0_REG 0xf0
|
||||
|
||||
+ssize_t anx_aux_transfer(struct regmap *map_dptx, struct drm_dp_aux_msg *msg);
|
||||
+
|
||||
#endif
|
||||
--
|
||||
2.17.1
|
||||
|
|
@ -0,0 +1,982 @@
|
|||
From 2da065ab8aa3f562a02dfd3df4ad971d1229b136 Mon Sep 17 00:00:00 2001
|
||||
From: Icenowy Zheng <icenowy@aosc.io>
|
||||
Date: Thu, 18 Oct 2018 15:33:23 +0800
|
||||
Subject: [PATCH 130/146] drm/bridge: Add Analogix anx6345 support
|
||||
|
||||
The ANX6345 is an ultra-low power DisplayPower/eDP transmitter designed
|
||||
for portable devices. This driver adds initial support for RGB to eDP
|
||||
mode, without HPD and interrupts, but with possibility to inject EDID.
|
||||
This is a configuration usually seen in eDP applications.
|
||||
|
||||
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
|
||||
---
|
||||
drivers/gpu/drm/bridge/analogix/Kconfig | 11 +
|
||||
drivers/gpu/drm/bridge/analogix/Makefile | 1 +
|
||||
.../drm/bridge/analogix/analogix-anx6345.c | 862 ++++++++++++++++++
|
||||
.../drm/bridge/analogix/analogix-i2c-dptx.c | 2 +-
|
||||
.../drm/bridge/analogix/analogix-i2c-dptx.h | 8 +
|
||||
.../bridge/analogix/analogix-i2c-txcommon.h | 3 +
|
||||
6 files changed, 886 insertions(+), 1 deletion(-)
|
||||
create mode 100644 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
|
||||
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
|
||||
index eb893b465dd8..784ddca83b47 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
|
||||
@@ -15,3 +15,14 @@ config DRM_ANALOGIX_ANX78XX
|
||||
designed for portable devices. The ANX78XX transforms
|
||||
the HDMI output of an application processor to MyDP
|
||||
or DisplayPort.
|
||||
+
|
||||
+config DRM_ANALOGIX_ANX6345
|
||||
+ tristate "Analogix ANX6345 bridge"
|
||||
+ select DRM_ANALOGIX_DP_I2C
|
||||
+ select DRM_KMS_HELPER
|
||||
+ select REGMAP_I2C
|
||||
+ help
|
||||
+ ANX6345 is an ultra-low Full-HD DisplayPort/eDP
|
||||
+ transmitter designed for portable devices. The
|
||||
+ ANX6345 transforms the LVTTL RGB output of an
|
||||
+ application processor to eDP or DisplayPort.
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/Makefile b/drivers/gpu/drm/bridge/analogix/Makefile
|
||||
index c37e2ded8ce3..3af9feab6e17 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/Makefile
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/Makefile
|
||||
@@ -3,3 +3,4 @@ analogix_dp_i2c-objs := analogix-i2c-dptx.o
|
||||
obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix_dp.o
|
||||
obj-$(CONFIG_DRM_ANALOGIX_DP_I2C) += analogix_dp_i2c.o
|
||||
obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o
|
||||
+obj-$(CONFIG_DRM_ANALOGIX_ANX6345) += analogix-anx6345.o
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
|
||||
new file mode 100644
|
||||
index 000000000000..81676407aa6d
|
||||
--- /dev/null
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
|
||||
@@ -0,0 +1,863 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright(c) Icenowy Zheng <icenowy@aosc.io>
|
||||
+ * Based on analogix-anx6345.c, which is:
|
||||
+ * Copyright(c) 2016, Analogix Semiconductor.
|
||||
+ */
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/i2c.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of_gpio.h>
|
||||
+#include <linux/of_platform.h>
|
||||
+#include <linux/regmap.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/gpio/consumer.h>
|
||||
+#include <linux/regulator/consumer.h>
|
||||
+
|
||||
+#include <drm/drm_drv.h>
|
||||
+#include <drm/drm_atomic_helper.h>
|
||||
+#include <drm/drm_crtc.h>
|
||||
+#include <drm/drm_crtc_helper.h>
|
||||
+#include <drm/drm_probe_helper.h>
|
||||
+#include <drm/drm_dp_helper.h>
|
||||
+#include <drm/drm_edid.h>
|
||||
+
|
||||
+#include "analogix-i2c-dptx.h"
|
||||
+#include "analogix-i2c-txcommon.h"
|
||||
+
|
||||
+#define I2C_NUM_ADDRESSES 2
|
||||
+#define I2C_IDX_DPTX 0
|
||||
+#define I2C_IDX_TXCOM 1
|
||||
+
|
||||
+#define XTAL_CLK 270 /* 27M */
|
||||
+
|
||||
+#define POLL_DELAY 50000 /* us */
|
||||
+#define POLL_TIMEOUT 5000000 /* us */
|
||||
+
|
||||
+static const u8 anx6345_i2c_addresses[] = {
|
||||
+ [I2C_IDX_DPTX] = ANALOGIX_I2C_DPTX,
|
||||
+ [I2C_IDX_TXCOM] = ANALOGIX_I2C_TXCOMMON,
|
||||
+};
|
||||
+
|
||||
+struct anx6345_platform_data {
|
||||
+ struct regulator *dvdd12;
|
||||
+ struct regulator *dvdd25;
|
||||
+ struct regulator *vcc_panel;
|
||||
+ struct gpio_desc *gpiod_reset;
|
||||
+};
|
||||
+
|
||||
+struct anx6345 {
|
||||
+ struct drm_dp_aux aux;
|
||||
+ struct drm_bridge bridge;
|
||||
+ struct i2c_client *client;
|
||||
+ struct edid *edid;
|
||||
+ struct drm_connector connector;
|
||||
+ struct drm_dp_link link;
|
||||
+ struct anx6345_platform_data pdata;
|
||||
+ struct mutex lock;
|
||||
+
|
||||
+ /*
|
||||
+ * I2C Slave addresses of ANX6345 are mapped as DPTX and SYS
|
||||
+ */
|
||||
+ struct i2c_client *i2c_clients[I2C_NUM_ADDRESSES];
|
||||
+ struct regmap *map[I2C_NUM_ADDRESSES];
|
||||
+
|
||||
+ u16 chipid;
|
||||
+ u8 dpcd[DP_RECEIVER_CAP_SIZE];
|
||||
+
|
||||
+ bool powered;
|
||||
+};
|
||||
+
|
||||
+static inline struct anx6345 *connector_to_anx6345(struct drm_connector *c)
|
||||
+{
|
||||
+ return container_of(c, struct anx6345, connector);
|
||||
+}
|
||||
+
|
||||
+static inline struct anx6345 *bridge_to_anx6345(struct drm_bridge *bridge)
|
||||
+{
|
||||
+ return container_of(bridge, struct anx6345, bridge);
|
||||
+}
|
||||
+
|
||||
+static int anx6345_set_bits(struct regmap *map, u8 reg, u8 mask)
|
||||
+{
|
||||
+ return regmap_update_bits(map, reg, mask, mask);
|
||||
+}
|
||||
+
|
||||
+static int anx6345_clear_bits(struct regmap *map, u8 reg, u8 mask)
|
||||
+{
|
||||
+ return regmap_update_bits(map, reg, mask, 0);
|
||||
+}
|
||||
+
|
||||
+static ssize_t anx6345_aux_transfer(struct drm_dp_aux *aux,
|
||||
+ struct drm_dp_aux_msg *msg)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = container_of(aux, struct anx6345, aux);
|
||||
+
|
||||
+ return anx_aux_transfer(anx6345->map[I2C_IDX_DPTX], msg);
|
||||
+}
|
||||
+
|
||||
+static int anx6345_dp_link_training(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ unsigned int value;
|
||||
+ u8 dp_bw;
|
||||
+ int err;
|
||||
+
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM],
|
||||
+ SP_POWERDOWN_CTRL_REG,
|
||||
+ SP_TOTAL_PD);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = drm_dp_dpcd_readb(&anx6345->aux, DP_MAX_LINK_RATE, &dp_bw);
|
||||
+ if (err < 0)
|
||||
+ return err;
|
||||
+
|
||||
+ switch (dp_bw) {
|
||||
+ case DP_LINK_BW_1_62:
|
||||
+ case DP_LINK_BW_2_7:
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ DRM_DEBUG_KMS("DP bandwidth (%#02x) not supported\n", dp_bw);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG,
|
||||
+ SP_VIDEO_MUTE);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM],
|
||||
+ SP_VID_CTRL1_REG, SP_VIDEO_EN);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Get DPCD info */
|
||||
+ err = drm_dp_dpcd_read(&anx6345->aux, DP_DPCD_REV,
|
||||
+ &anx6345->dpcd, DP_RECEIVER_CAP_SIZE);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Failed to read DPCD: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Clear channel x SERDES power down */
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_ANALOG_POWER_DOWN_REG, SP_CH0_PD);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Check link capabilities */
|
||||
+ err = drm_dp_link_probe(&anx6345->aux, &anx6345->link);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Failed to probe link capabilities: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Power up the sink */
|
||||
+ err = drm_dp_link_power_up(&anx6345->aux, &anx6345->link);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Failed to power up DisplayPort link: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Possibly enable downspread on the sink */
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_DOWNSPREAD_CTRL1_REG, 0);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ if (anx6345->dpcd[DP_MAX_DOWNSPREAD] & DP_MAX_DOWNSPREAD_0_5) {
|
||||
+ DRM_DEBUG("Enable downspread on the sink\n");
|
||||
+ /* 4000PPM */
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_DOWNSPREAD_CTRL1_REG, 8);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = drm_dp_dpcd_writeb(&anx6345->aux, DP_DOWNSPREAD_CTRL,
|
||||
+ DP_SPREAD_AMP_0_5);
|
||||
+ if (err < 0)
|
||||
+ return err;
|
||||
+ } else {
|
||||
+ err = drm_dp_dpcd_writeb(&anx6345->aux, DP_DOWNSPREAD_CTRL, 0);
|
||||
+ if (err < 0)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Set the lane count and the link rate on the sink */
|
||||
+ if (drm_dp_enhanced_frame_cap(anx6345->dpcd))
|
||||
+ err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_SYSTEM_CTRL_BASE + 4,
|
||||
+ SP_ENHANCED_MODE);
|
||||
+ else
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_SYSTEM_CTRL_BASE + 4,
|
||||
+ SP_ENHANCED_MODE);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ value = drm_dp_link_rate_to_bw_code(anx6345->link.rate);
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_MAIN_LINK_BW_SET_REG, value);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_LANE_COUNT_SET_REG, anx6345->link.num_lanes);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = drm_dp_link_configure(&anx6345->aux, &anx6345->link);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Failed to configure DisplayPort link: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Start training on the source */
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX], SP_DP_LT_CTRL_REG,
|
||||
+ SP_LT_EN);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_read_poll_timeout(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_LT_CTRL_REG,
|
||||
+ value, !(value & SP_DP_LT_INPROGRESS),
|
||||
+ POLL_DELAY, POLL_TIMEOUT);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_tx_initialization(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ int err, i;
|
||||
+
|
||||
+ /* FIXME: hardcode color depth now */
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL2_REG,
|
||||
+ SP_IN_BPC_6BIT << SP_IN_BPC_SHIFT);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX], SP_DP_PLL_CTRL_REG, 0);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_TXCOM],
|
||||
+ SP_ANALOG_DEBUG1_REG, 0);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_LINK_DEBUG_CTRL_REG,
|
||||
+ SP_NEW_PRBS7 | SP_M_VID_DEBUG);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_ANALOG_POWER_DOWN_REG, 0);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Force HPD */
|
||||
+ err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_SYSTEM_CTRL_BASE + 3,
|
||||
+ SP_HPD_FORCE | SP_HPD_CTRL);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ for (i = 0; i < 4; i++) {
|
||||
+ /* 4 lanes */
|
||||
+ err = regmap_write(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_LANE0_LT_CTRL_REG + i, 0);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Reset AUX */
|
||||
+ err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM],
|
||||
+ SP_RESET_CTRL2_REG, SP_AUX_RST);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM],
|
||||
+ SP_RESET_CTRL2_REG, SP_AUX_RST);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ err = anx6345_dp_link_training(anx6345);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void anx6345_poweron(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ struct anx6345_platform_data *pdata = &anx6345->pdata;
|
||||
+ int err;
|
||||
+
|
||||
+ if (WARN_ON(anx6345->powered))
|
||||
+ return;
|
||||
+
|
||||
+ if (pdata->dvdd12) {
|
||||
+ err = regulator_enable(pdata->dvdd12);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to enable DVDD12 regulator: %d\n",
|
||||
+ err);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ usleep_range(1000, 2000);
|
||||
+ }
|
||||
+
|
||||
+ if (pdata->dvdd25) {
|
||||
+ err = regulator_enable(pdata->dvdd25);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to enable DVDD25 regulator: %d\n",
|
||||
+ err);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ usleep_range(5000, 10000);
|
||||
+ }
|
||||
+
|
||||
+ if (pdata->vcc_panel) {
|
||||
+ err = regulator_enable(pdata->vcc_panel);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to enable panel regulator: %d\n",
|
||||
+ err);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ gpiod_set_value_cansleep(pdata->gpiod_reset, 0);
|
||||
+ usleep_range(1000, 2000);
|
||||
+
|
||||
+ gpiod_set_value_cansleep(pdata->gpiod_reset, 1);
|
||||
+
|
||||
+ /* Power on registers module */
|
||||
+ anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG,
|
||||
+ SP_HDCP_PD | SP_AUDIO_PD | SP_VIDEO_PD | SP_LINK_PD);
|
||||
+ anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG,
|
||||
+ SP_REGISTER_PD | SP_TOTAL_PD);
|
||||
+
|
||||
+ anx6345->powered = true;
|
||||
+}
|
||||
+
|
||||
+static void anx6345_poweroff(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ struct anx6345_platform_data *pdata = &anx6345->pdata;
|
||||
+ int err;
|
||||
+
|
||||
+ if (WARN_ON(!anx6345->powered))
|
||||
+ return;
|
||||
+
|
||||
+ gpiod_set_value_cansleep(pdata->gpiod_reset, 1);
|
||||
+ usleep_range(1000, 2000);
|
||||
+
|
||||
+ if (pdata->vcc_panel) {
|
||||
+ err = regulator_disable(pdata->vcc_panel);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to disable panel regulator: %d\n",
|
||||
+ err);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (pdata->dvdd25) {
|
||||
+ err = regulator_disable(pdata->dvdd25);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to disable DVDD25 regulator: %d\n",
|
||||
+ err);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ usleep_range(5000, 10000);
|
||||
+ }
|
||||
+
|
||||
+ if (pdata->dvdd12) {
|
||||
+ err = regulator_disable(pdata->dvdd12);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to disable DVDD12 regulator: %d\n",
|
||||
+ err);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ usleep_range(1000, 2000);
|
||||
+ }
|
||||
+
|
||||
+ anx6345->powered = false;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_start(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ if (!anx6345->powered)
|
||||
+ anx6345_poweron(anx6345);
|
||||
+
|
||||
+ /* Power on needed modules */
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM],
|
||||
+ SP_POWERDOWN_CTRL_REG,
|
||||
+ SP_VIDEO_PD | SP_LINK_PD);
|
||||
+
|
||||
+ err = anx6345_tx_initialization(anx6345);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed transmitter initialization: %d\n", err);
|
||||
+ goto err_poweroff;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * This delay seems to help keep the hardware in a good state. Without
|
||||
+ * it, there are times where it fails silently.
|
||||
+ */
|
||||
+ usleep_range(10000, 15000);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_poweroff:
|
||||
+ DRM_ERROR("Failed DisplayPort transmitter initialization: %d\n", err);
|
||||
+ anx6345_poweroff(anx6345);
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_init_pdata(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ struct anx6345_platform_data *pdata = &anx6345->pdata;
|
||||
+ struct device *dev = &anx6345->client->dev;
|
||||
+
|
||||
+ /* 1.2V digital core power regulator */
|
||||
+ pdata->dvdd12 = devm_regulator_get(dev, "dvdd12");
|
||||
+ if (IS_ERR(pdata->dvdd12)) {
|
||||
+ DRM_ERROR("DVDD12 regulator not found\n");
|
||||
+ return PTR_ERR(pdata->dvdd12);
|
||||
+ }
|
||||
+
|
||||
+ /* 2.5V digital core power regulator */
|
||||
+ pdata->dvdd25 = devm_regulator_get(dev, "dvdd25");
|
||||
+ if (IS_ERR(pdata->dvdd25)) {
|
||||
+ DRM_ERROR("DVDD25 regulator not found\n");
|
||||
+ return PTR_ERR(pdata->dvdd25);
|
||||
+ }
|
||||
+
|
||||
+ /* panel power regulator */
|
||||
+ pdata->vcc_panel = devm_regulator_get(dev, "panel");
|
||||
+ if (IS_ERR(pdata->vcc_panel)) {
|
||||
+ DRM_ERROR("panel regulator not found\n");
|
||||
+ return PTR_ERR(pdata->vcc_panel);
|
||||
+ }
|
||||
+
|
||||
+ /* GPIO for chip reset */
|
||||
+ pdata->gpiod_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
|
||||
+
|
||||
+ return PTR_ERR_OR_ZERO(pdata->gpiod_reset);
|
||||
+}
|
||||
+
|
||||
+static int anx6345_config_dp_output(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ err = anx6345_clear_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG,
|
||||
+ SP_VIDEO_MUTE);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Enable DP output */
|
||||
+ err = anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_VID_CTRL1_REG,
|
||||
+ SP_VIDEO_EN);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /* Force stream valid */
|
||||
+ err = anx6345_set_bits(anx6345->map[I2C_IDX_DPTX],
|
||||
+ SP_DP_SYSTEM_CTRL_BASE + 3,
|
||||
+ SP_STRM_FORCE | SP_STRM_CTRL);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_get_downstream_info(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ u8 value;
|
||||
+ int err;
|
||||
+
|
||||
+ err = drm_dp_dpcd_readb(&anx6345->aux, DP_SINK_COUNT, &value);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Get sink count failed %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ if (!DP_GET_SINK_COUNT(value)) {
|
||||
+ DRM_ERROR("Downstream disconnected\n");
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_probe_edid_from_of(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ const u8 *edidp;
|
||||
+ int len;
|
||||
+
|
||||
+ if (!anx6345->bridge.of_node)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ edidp = of_get_property(anx6345->bridge.of_node, "edid", &len);
|
||||
+ if (!edidp || len != EDID_LENGTH)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ anx6345->edid = devm_kmemdup(&anx6345->client->dev, edidp,
|
||||
+ len, GFP_KERNEL);
|
||||
+
|
||||
+ if (!anx6345->edid)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_get_modes(struct drm_connector *connector)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = connector_to_anx6345(connector);
|
||||
+ int err, num_modes = 0;
|
||||
+
|
||||
+ if (WARN_ON(!anx6345->powered))
|
||||
+ return 0;
|
||||
+
|
||||
+ if (anx6345->edid)
|
||||
+ return drm_add_edid_modes(connector, anx6345->edid);
|
||||
+
|
||||
+ mutex_lock(&anx6345->lock);
|
||||
+
|
||||
+ err = anx6345_get_downstream_info(anx6345);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to get downstream info: %d\n", err);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+
|
||||
+ anx6345->edid = drm_get_edid(connector, &anx6345->aux.ddc);
|
||||
+ if (!anx6345->edid)
|
||||
+ DRM_ERROR("Failed to read EDID from panel\n");
|
||||
+
|
||||
+ if (!anx6345->edid) {
|
||||
+ err = anx6345_probe_edid_from_of(anx6345);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to probe EDID from device tree: &d\n", err);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ err = drm_connector_update_edid_property(connector,
|
||||
+ anx6345->edid);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to update EDID property: %d\n", err);
|
||||
+ goto unlock;
|
||||
+ }
|
||||
+
|
||||
+ num_modes = drm_add_edid_modes(connector, anx6345->edid);
|
||||
+
|
||||
+unlock:
|
||||
+ mutex_unlock(&anx6345->lock);
|
||||
+
|
||||
+ return num_modes;
|
||||
+}
|
||||
+
|
||||
+static const struct drm_connector_helper_funcs anx6345_connector_helper_funcs = {
|
||||
+ .get_modes = anx6345_get_modes,
|
||||
+};
|
||||
+
|
||||
+static enum drm_connector_status anx6345_detect(struct drm_connector *connector,
|
||||
+ bool force)
|
||||
+{
|
||||
+ return connector_status_connected;
|
||||
+}
|
||||
+
|
||||
+static const struct drm_connector_funcs anx6345_connector_funcs = {
|
||||
+ .fill_modes = drm_helper_probe_single_connector_modes,
|
||||
+ .detect = anx6345_detect,
|
||||
+ .destroy = drm_connector_cleanup,
|
||||
+ .reset = drm_atomic_helper_connector_reset,
|
||||
+ .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
|
||||
+ .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
|
||||
+};
|
||||
+
|
||||
+static int anx6345_bridge_attach(struct drm_bridge *bridge)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = bridge_to_anx6345(bridge);
|
||||
+ int err;
|
||||
+
|
||||
+ if (!bridge->encoder) {
|
||||
+ DRM_ERROR("Parent encoder object not found");
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ /* Register aux channel */
|
||||
+ anx6345->aux.name = "DP-AUX";
|
||||
+ anx6345->aux.dev = &anx6345->client->dev;
|
||||
+ anx6345->aux.transfer = anx6345_aux_transfer;
|
||||
+
|
||||
+ err = drm_dp_aux_register(&anx6345->aux);
|
||||
+ if (err < 0) {
|
||||
+ DRM_ERROR("Failed to register aux channel: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ err = drm_connector_init(bridge->dev, &anx6345->connector,
|
||||
+ &anx6345_connector_funcs,
|
||||
+ DRM_MODE_CONNECTOR_eDP);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to initialize connector: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ drm_connector_helper_add(&anx6345->connector,
|
||||
+ &anx6345_connector_helper_funcs);
|
||||
+
|
||||
+ err = drm_connector_register(&anx6345->connector);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to register connector: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ anx6345->connector.polled = DRM_CONNECTOR_POLL_HPD;
|
||||
+
|
||||
+ err = drm_connector_attach_encoder(&anx6345->connector,
|
||||
+ bridge->encoder);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to link up connector to encoder: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static bool anx6345_bridge_mode_fixup(struct drm_bridge *bridge,
|
||||
+ const struct drm_display_mode *mode,
|
||||
+ struct drm_display_mode *adjusted_mode)
|
||||
+{
|
||||
+ if (mode->flags & DRM_MODE_FLAG_INTERLACE)
|
||||
+ return false;
|
||||
+
|
||||
+ /* Max 1200p at 5.4 Ghz, one lane */
|
||||
+ if (mode->clock > 154000)
|
||||
+ return false;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static void anx6345_bridge_disable(struct drm_bridge *bridge)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = bridge_to_anx6345(bridge);
|
||||
+
|
||||
+ /* Power off all modules except configuration registers access */
|
||||
+ anx6345_set_bits(anx6345->map[I2C_IDX_TXCOM], SP_POWERDOWN_CTRL_REG,
|
||||
+ SP_HDCP_PD | SP_AUDIO_PD | SP_VIDEO_PD | SP_LINK_PD);
|
||||
+}
|
||||
+
|
||||
+static void anx6345_bridge_mode_set(struct drm_bridge *bridge,
|
||||
+ const struct drm_display_mode *mode,
|
||||
+ const struct drm_display_mode *adjusted_mode)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = bridge_to_anx6345(bridge);
|
||||
+
|
||||
+ if (WARN_ON(!anx6345->powered))
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+static void anx6345_bridge_enable(struct drm_bridge *bridge)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = bridge_to_anx6345(bridge);
|
||||
+ int err;
|
||||
+
|
||||
+ err = anx6345_start(anx6345);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to initialize: %d\n", err);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ err = anx6345_config_dp_output(anx6345);
|
||||
+ if (err)
|
||||
+ DRM_ERROR("Failed to enable DP output: %d\n", err);
|
||||
+}
|
||||
+
|
||||
+static const struct drm_bridge_funcs anx6345_bridge_funcs = {
|
||||
+ .attach = anx6345_bridge_attach,
|
||||
+ .mode_fixup = anx6345_bridge_mode_fixup,
|
||||
+ .disable = anx6345_bridge_disable,
|
||||
+ .mode_set = anx6345_bridge_mode_set,
|
||||
+ .enable = anx6345_bridge_enable,
|
||||
+};
|
||||
+
|
||||
+static void unregister_i2c_dummy_clients(struct anx6345 *anx6345)
|
||||
+{
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 1; i < ARRAY_SIZE(anx6345->i2c_clients); i++)
|
||||
+ if (anx6345->i2c_clients[i] &&
|
||||
+ anx6345->i2c_clients[i]->addr != anx6345->client->addr)
|
||||
+ i2c_unregister_device(anx6345->i2c_clients[i]);
|
||||
+}
|
||||
+
|
||||
+static const struct regmap_config anx6345_regmap_config = {
|
||||
+ .reg_bits = 8,
|
||||
+ .val_bits = 8,
|
||||
+ .max_register = 0xff,
|
||||
+};
|
||||
+
|
||||
+static const u16 anx6345_chipid_list[] = {
|
||||
+ 0x6345,
|
||||
+};
|
||||
+
|
||||
+static int anx6345_i2c_probe(struct i2c_client *client,
|
||||
+ const struct i2c_device_id *id)
|
||||
+{
|
||||
+ struct anx6345 *anx6345;
|
||||
+ struct anx6345_platform_data *pdata;
|
||||
+ unsigned int i, idl, idh, version;
|
||||
+ bool found = false;
|
||||
+ int err;
|
||||
+
|
||||
+ anx6345 = devm_kzalloc(&client->dev, sizeof(*anx6345), GFP_KERNEL);
|
||||
+ if (!anx6345)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ pdata = &anx6345->pdata;
|
||||
+
|
||||
+ mutex_init(&anx6345->lock);
|
||||
+
|
||||
+#if IS_ENABLED(CONFIG_OF)
|
||||
+ anx6345->bridge.of_node = client->dev.of_node;
|
||||
+#endif
|
||||
+
|
||||
+ anx6345->client = client;
|
||||
+ i2c_set_clientdata(client, anx6345);
|
||||
+
|
||||
+ err = anx6345_init_pdata(anx6345);
|
||||
+ if (err) {
|
||||
+ DRM_ERROR("Failed to initialize pdata: %d\n", err);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ /* Map slave addresses of ANX6345 */
|
||||
+ for (i = 0; i < I2C_NUM_ADDRESSES; i++) {
|
||||
+ if (anx6345_i2c_addresses[i] >> 1 != client->addr)
|
||||
+ anx6345->i2c_clients[i] = i2c_new_dummy(client->adapter,
|
||||
+ anx6345_i2c_addresses[i] >> 1);
|
||||
+ else
|
||||
+ anx6345->i2c_clients[i] = client;
|
||||
+
|
||||
+ if (!anx6345->i2c_clients[i]) {
|
||||
+ err = -ENOMEM;
|
||||
+ DRM_ERROR("Failed to reserve I2C bus %02x\n",
|
||||
+ anx6345_i2c_addresses[i]);
|
||||
+ goto err_unregister_i2c;
|
||||
+ }
|
||||
+
|
||||
+ anx6345->map[i] = devm_regmap_init_i2c(anx6345->i2c_clients[i],
|
||||
+ &anx6345_regmap_config);
|
||||
+ if (IS_ERR(anx6345->map[i])) {
|
||||
+ err = PTR_ERR(anx6345->map[i]);
|
||||
+ DRM_ERROR("Failed regmap initialization %02x\n",
|
||||
+ anx6345_i2c_addresses[i]);
|
||||
+ goto err_unregister_i2c;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Look for supported chip ID */
|
||||
+ anx6345_poweron(anx6345);
|
||||
+
|
||||
+ err = regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_IDL_REG,
|
||||
+ &idl);
|
||||
+ if (err)
|
||||
+ goto err_poweroff;
|
||||
+
|
||||
+ err = regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_IDH_REG,
|
||||
+ &idh);
|
||||
+ if (err)
|
||||
+ goto err_poweroff;
|
||||
+
|
||||
+ anx6345->chipid = (u8)idl | ((u8)idh << 8);
|
||||
+
|
||||
+ err = regmap_read(anx6345->map[I2C_IDX_TXCOM], SP_DEVICE_VERSION_REG,
|
||||
+ &version);
|
||||
+ if (err)
|
||||
+ goto err_poweroff;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(anx6345_chipid_list); i++) {
|
||||
+ if (anx6345->chipid == anx6345_chipid_list[i]) {
|
||||
+ DRM_INFO("Found ANX%x (ver. %d) eDP Transmitter\n",
|
||||
+ anx6345->chipid, version);
|
||||
+ found = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ DRM_ERROR("ANX%x (ver. %d) not supported by this driver\n",
|
||||
+ anx6345->chipid, version);
|
||||
+ err = -ENODEV;
|
||||
+ goto err_poweroff;
|
||||
+ }
|
||||
+
|
||||
+ anx6345->bridge.funcs = &anx6345_bridge_funcs;
|
||||
+
|
||||
+ drm_bridge_add(&anx6345->bridge);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err_poweroff:
|
||||
+ anx6345_poweroff(anx6345);
|
||||
+
|
||||
+err_unregister_i2c:
|
||||
+ unregister_i2c_dummy_clients(anx6345);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int anx6345_i2c_remove(struct i2c_client *client)
|
||||
+{
|
||||
+ struct anx6345 *anx6345 = i2c_get_clientdata(client);
|
||||
+
|
||||
+ drm_bridge_remove(&anx6345->bridge);
|
||||
+
|
||||
+ unregister_i2c_dummy_clients(anx6345);
|
||||
+
|
||||
+ kfree(anx6345->edid);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct i2c_device_id anx6345_id[] = {
|
||||
+ { "anx6345", 0 },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(i2c, anx6345_id);
|
||||
+
|
||||
+#if IS_ENABLED(CONFIG_OF)
|
||||
+static const struct of_device_id anx6345_match_table[] = {
|
||||
+ { .compatible = "analogix,anx6345", },
|
||||
+ { /* sentinel */ },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, anx6345_match_table);
|
||||
+#endif
|
||||
+
|
||||
+static struct i2c_driver anx6345_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "anx6345",
|
||||
+ .of_match_table = of_match_ptr(anx6345_match_table),
|
||||
+ },
|
||||
+ .probe = anx6345_i2c_probe,
|
||||
+ .remove = anx6345_i2c_remove,
|
||||
+ .id_table = anx6345_id,
|
||||
+};
|
||||
+module_i2c_driver(anx6345_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("ANX6345 eDP Transmitter driver");
|
||||
+MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.io>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c
|
||||
index 9cb30962032e..53b0e73d6a24 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.c
|
||||
@@ -117,7 +117,7 @@ ssize_t anx_aux_transfer(struct regmap *map_dptx, struct drm_dp_aux_msg *msg)
|
||||
else /* For non-zero-sized set the length field. */
|
||||
ctrl1 |= (msg->size - 1) << SP_AUX_LENGTH_SHIFT;
|
||||
|
||||
- if ((msg->request & DP_AUX_I2C_READ) == 0) {
|
||||
+ if ((msg->size > 0) && ((msg->request & DP_AUX_I2C_READ) == 0)) {
|
||||
/* When WRITE | MOT write values to data buffer */
|
||||
err = regmap_bulk_write(map_dptx,
|
||||
SP_DP_BUF_DATA0_REG, buffer,
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h
|
||||
index c2ca854613a0..b29a0b3bc23c 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-i2c-dptx.h
|
||||
@@ -75,7 +75,11 @@
|
||||
#define SP_CHA_STA BIT(2)
|
||||
/* Bits for DP System Control Register 3 */
|
||||
#define SP_HPD_STATUS BIT(6)
|
||||
+#define SP_HPD_FORCE BIT(5)
|
||||
+#define SP_HPD_CTRL BIT(4)
|
||||
#define SP_STRM_VALID BIT(2)
|
||||
+#define SP_STRM_FORCE BIT(1)
|
||||
+#define SP_STRM_CTRL BIT(0)
|
||||
/* Bits for DP System Control Register 4 */
|
||||
#define SP_ENHANCED_MODE BIT(3)
|
||||
|
||||
@@ -120,6 +124,9 @@
|
||||
#define SP_LINK_BW_SET_MASK 0x1f
|
||||
#define SP_INITIAL_SLIM_M_AUD_SEL BIT(5)
|
||||
|
||||
+/* DP Lane Count Setting Register */
|
||||
+#define SP_DP_LANE_COUNT_SET_REG 0xa1
|
||||
+
|
||||
/* DP Training Pattern Set Register */
|
||||
#define SP_DP_TRAINING_PATTERN_SET_REG 0xa2
|
||||
|
||||
@@ -133,6 +140,7 @@
|
||||
|
||||
/* DP Link Training Control Register */
|
||||
#define SP_DP_LT_CTRL_REG 0xa8
|
||||
+#define SP_DP_LT_INPROGRESS 0x80
|
||||
#define SP_LT_ERROR_TYPE_MASK 0x70
|
||||
# define SP_LT_NO_ERROR 0x00
|
||||
# define SP_LT_AUX_WRITE_ERROR 0x01
|
||||
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-i2c-txcommon.h b/drivers/gpu/drm/bridge/analogix/analogix-i2c-txcommon.h
|
||||
index 7d683573e970..480c98a225b1 100644
|
||||
--- a/drivers/gpu/drm/bridge/analogix/analogix-i2c-txcommon.h
|
||||
+++ b/drivers/gpu/drm/bridge/analogix/analogix-i2c-txcommon.h
|
||||
@@ -183,6 +183,9 @@
|
||||
#define SP_VBIT BIT(1)
|
||||
#define SP_AUDIO_LAYOUT BIT(0)
|
||||
|
||||
+/* Analog Debug Register 1 */
|
||||
+#define SP_ANALOG_DEBUG1_REG 0xdc
|
||||
+
|
||||
/* Analog Debug Register 2 */
|
||||
#define SP_ANALOG_DEBUG2_REG 0xdd
|
||||
#define SP_FORCE_SW_OFF_BYPASS 0x20
|
||||
--
|
||||
2.17.1
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
Some devices require a higher TS clock frequency to demodulate some
|
||||
muxes. This adds two optional parameters to control the TS clock
|
||||
frequency mode as well as the frequency.
|
||||
|
||||
Signed-off-by: Thomas Hollstegge <thomas.hollstegge@gmail.com>
|
||||
---
|
||||
drivers/media/dvb-frontends/si2168.c | 20 +++++++++++++++++++-
|
||||
drivers/media/dvb-frontends/si2168.h | 8 ++++++++
|
||||
drivers/media/dvb-frontends/si2168_priv.h | 2 ++
|
||||
3 files changed, 29 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c
|
||||
index 324493e..b05e677 100644
|
||||
--- a/drivers/media/dvb-frontends/si2168.c
|
||||
+++ b/drivers/media/dvb-frontends/si2168.c
|
||||
@@ -92,13 +92,15 @@ static int si2168_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
|
||||
dev_dbg(&client->dev, "%s acquire: %d\n", __func__, acquire);
|
||||
|
||||
/* set TS_MODE property */
|
||||
- memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6);
|
||||
+ memcpy(cmd.args, "\x14\x00\x01\x10\x00\x00", 6);
|
||||
if (acquire)
|
||||
cmd.args[4] |= dev->ts_mode;
|
||||
else
|
||||
cmd.args[4] |= SI2168_TS_TRISTATE;
|
||||
if (dev->ts_clock_gapped)
|
||||
cmd.args[4] |= 0x40;
|
||||
+ cmd.args[4] |= (dev->ts_clock_mode & 0x03) << 4;
|
||||
+
|
||||
cmd.wlen = 6;
|
||||
cmd.rlen = 4;
|
||||
ret = si2168_cmd_execute(client, &cmd);
|
||||
@@ -398,6 +400,18 @@ static int si2168_set_frontend(struct dvb_frontend *fe)
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
+ /* set TS frequency */
|
||||
+ if (dev->ts_clock_freq) {
|
||||
+ memcpy(cmd.args, "\x14\x00\x0d\x10", 4);
|
||||
+ cmd.args[4] = ((dev->ts_clock_freq / 10000) >> 0) & 0xff;
|
||||
+ cmd.args[5] = ((dev->ts_clock_freq / 10000) >> 8) & 0xff;
|
||||
+ cmd.wlen = 6;
|
||||
+ cmd.rlen = 4;
|
||||
+ ret = si2168_cmd_execute(client, &cmd);
|
||||
+ if (ret)
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
memcpy(cmd.args, "\x14\x00\x08\x10\xd7\x05", 6);
|
||||
cmd.args[5] |= dev->ts_clock_inv ? 0x00 : 0x10;
|
||||
cmd.wlen = 6;
|
||||
@@ -806,6 +820,10 @@ static int si2168_probe(struct i2c_client *client,
|
||||
dev->ts_mode = config->ts_mode;
|
||||
dev->ts_clock_inv = config->ts_clock_inv;
|
||||
dev->ts_clock_gapped = config->ts_clock_gapped;
|
||||
+ dev->ts_clock_mode = config->ts_clock_mode;
|
||||
+ if (dev->ts_clock_mode == 0)
|
||||
+ dev->ts_clock_mode = SI2168_TS_CLOCK_MODE_AUTO_ADAPT;
|
||||
+ dev->ts_clock_freq = config->ts_clock_freq;
|
||||
dev->spectral_inversion = config->spectral_inversion;
|
||||
|
||||
dev_info(&client->dev, "Silicon Labs Si2168-%c%d%d successfully identified\n",
|
||||
diff --git a/drivers/media/dvb-frontends/si2168.h b/drivers/media/dvb-frontends/si2168.h
|
||||
index d519edd..3f52ee8 100644
|
||||
--- a/drivers/media/dvb-frontends/si2168.h
|
||||
+++ b/drivers/media/dvb-frontends/si2168.h
|
||||
@@ -47,6 +47,14 @@ struct si2168_config {
|
||||
/* TS clock gapped */
|
||||
bool ts_clock_gapped;
|
||||
|
||||
+ /* TS clock mode */
|
||||
+#define SI2168_TS_CLOCK_MODE_AUTO_ADAPT 0x01
|
||||
+#define SI2168_TS_CLOCK_MODE_MANUAL 0x02
|
||||
+ u8 ts_clock_mode;
|
||||
+
|
||||
+ /* TS clock frequency (for manual mode) */
|
||||
+ u32 ts_clock_freq;
|
||||
+
|
||||
/* Inverted spectrum */
|
||||
bool spectral_inversion;
|
||||
};
|
||||
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h
|
||||
index 2d362e1..8173d6c 100644
|
||||
--- a/drivers/media/dvb-frontends/si2168_priv.h
|
||||
+++ b/drivers/media/dvb-frontends/si2168_priv.h
|
||||
@@ -48,6 +48,8 @@ struct si2168_dev {
|
||||
u8 ts_mode;
|
||||
bool ts_clock_inv;
|
||||
bool ts_clock_gapped;
|
||||
+ u8 ts_clock_mode;
|
||||
+ u32 ts_clock_freq;
|
||||
bool spectral_inversion;
|
||||
};
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
Support for newer revisions of the MyGica T230C, shipping with a
|
||||
different USB pid. Although sometimes referred to as T230C2, the device
|
||||
is sold under its original name T230C.
|
||||
|
||||
Besides a slightly different PCB layout and some different minor
|
||||
components, it utilizes the same bridge, demodulator and tuner as the
|
||||
older revision. However, it requires a fixed TS clock frequency of 10
|
||||
MHz to tune to some muxes.
|
||||
|
||||
Tested with various DVB-T2 HEVC and DVB-C channels.
|
||||
|
||||
Signed-off-by: Thomas Hollstegge <thomas.hollstegge@gmail.com>
|
||||
Cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
---
|
||||
drivers/media/usb/dvb-usb-v2/dvbsky.c | 90 +++++++++++++++++++++++++++++++++++
|
||||
include/media/dvb-usb-ids.h | 1 +
|
||||
2 files changed, 91 insertions(+)
|
||||
|
||||
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c b/drivers/media/usb/dvb-usb-v2/dvbsky.c
|
||||
index 1aa88d9..a6d3c08 100644
|
||||
--- a/drivers/media/usb/dvb-usb-v2/dvbsky.c
|
||||
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
|
||||
@@ -581,6 +581,66 @@ static int dvbsky_mygica_t230c_attach(struct dvb_usb_adapter *adap)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int dvbsky_mygica_t230c_v2_attach(struct dvb_usb_adapter *adap)
|
||||
+{
|
||||
+ struct dvbsky_state *state = adap_to_priv(adap);
|
||||
+ struct dvb_usb_device *d = adap_to_d(adap);
|
||||
+ struct i2c_adapter *i2c_adapter;
|
||||
+ struct i2c_client *client_demod, *client_tuner;
|
||||
+ struct i2c_board_info info;
|
||||
+ struct si2168_config si2168_config;
|
||||
+ struct si2157_config si2157_config;
|
||||
+
|
||||
+ /* attach demod */
|
||||
+ memset(&si2168_config, 0, sizeof(si2168_config));
|
||||
+ si2168_config.i2c_adapter = &i2c_adapter;
|
||||
+ si2168_config.fe = &adap->fe[0];
|
||||
+ si2168_config.ts_mode = SI2168_TS_PARALLEL;
|
||||
+ si2168_config.ts_clock_inv = 1;
|
||||
+ si2168_config.ts_clock_mode = SI2168_TS_CLOCK_MODE_MANUAL;
|
||||
+ si2168_config.ts_clock_freq = 10000000;
|
||||
+ memset(&info, 0, sizeof(struct i2c_board_info));
|
||||
+ strlcpy(info.type, "si2168", sizeof(info.type));
|
||||
+ info.addr = 0x64;
|
||||
+ info.platform_data = &si2168_config;
|
||||
+
|
||||
+ request_module("si2168");
|
||||
+ client_demod = i2c_new_device(&d->i2c_adap, &info);
|
||||
+ if (!client_demod || !client_demod->dev.driver)
|
||||
+ goto fail_demod_device;
|
||||
+ if (!try_module_get(client_demod->dev.driver->owner))
|
||||
+ goto fail_demod_module;
|
||||
+
|
||||
+ /* attach tuner */
|
||||
+ memset(&si2157_config, 0, sizeof(si2157_config));
|
||||
+ si2157_config.fe = adap->fe[0];
|
||||
+ si2157_config.if_port = 0;
|
||||
+ memset(&info, 0, sizeof(struct i2c_board_info));
|
||||
+ strlcpy(info.type, "si2141", sizeof(info.type));
|
||||
+ info.addr = 0x60;
|
||||
+ info.platform_data = &si2157_config;
|
||||
+
|
||||
+ request_module("si2157");
|
||||
+ client_tuner = i2c_new_device(i2c_adapter, &info);
|
||||
+ if (!client_tuner || !client_tuner->dev.driver)
|
||||
+ goto fail_tuner_device;
|
||||
+ if (!try_module_get(client_tuner->dev.driver->owner))
|
||||
+ goto fail_tuner_module;
|
||||
+
|
||||
+ state->i2c_client_demod = client_demod;
|
||||
+ state->i2c_client_tuner = client_tuner;
|
||||
+ return 0;
|
||||
+
|
||||
+fail_tuner_module:
|
||||
+ i2c_unregister_device(client_tuner);
|
||||
+fail_tuner_device:
|
||||
+ module_put(client_demod->dev.driver->owner);
|
||||
+fail_demod_module:
|
||||
+ i2c_unregister_device(client_demod);
|
||||
+fail_demod_device:
|
||||
+ return -ENODEV;
|
||||
+}
|
||||
+
|
||||
|
||||
static int dvbsky_identify_state(struct dvb_usb_device *d, const char **name)
|
||||
{
|
||||
@@ -758,6 +818,32 @@ static struct dvb_usb_device_properties mygica_t230c_props = {
|
||||
}
|
||||
};
|
||||
|
||||
+static struct dvb_usb_device_properties mygica_t230c_v2_props = {
|
||||
+ .driver_name = KBUILD_MODNAME,
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .adapter_nr = adapter_nr,
|
||||
+ .size_of_priv = sizeof(struct dvbsky_state),
|
||||
+
|
||||
+ .generic_bulk_ctrl_endpoint = 0x01,
|
||||
+ .generic_bulk_ctrl_endpoint_response = 0x81,
|
||||
+ .generic_bulk_ctrl_delay = DVBSKY_MSG_DELAY,
|
||||
+
|
||||
+ .i2c_algo = &dvbsky_i2c_algo,
|
||||
+ .frontend_attach = dvbsky_mygica_t230c_v2_attach,
|
||||
+ .init = dvbsky_init,
|
||||
+ .get_rc_config = dvbsky_get_rc_config,
|
||||
+ .streaming_ctrl = dvbsky_streaming_ctrl,
|
||||
+ .identify_state = dvbsky_identify_state,
|
||||
+
|
||||
+ .num_adapters = 1,
|
||||
+ .adapter = {
|
||||
+ {
|
||||
+ .stream = DVB_USB_STREAM_BULK(0x82, 8, 4096),
|
||||
+ }
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+
|
||||
static const struct usb_device_id dvbsky_id_table[] = {
|
||||
{ DVB_USB_DEVICE(0x0572, 0x6831,
|
||||
&dvbsky_s960_props, "DVBSky S960/S860", RC_MAP_DVBSKY) },
|
||||
@@ -793,6 +880,9 @@ static const struct usb_device_id dvbsky_id_table[] = {
|
||||
{ DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C,
|
||||
&mygica_t230c_props, "MyGica Mini DVB-T2 USB Stick T230C",
|
||||
RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
|
||||
+ { DVB_USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_T230C_V2,
|
||||
+ &mygica_t230c_v2_props, "MyGica Mini DVB-T2 USB Stick T230C v2",
|
||||
+ RC_MAP_TOTAL_MEDIA_IN_HAND_02) },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
|
||||
diff --git a/include/media/dvb-usb-ids.h b/include/media/dvb-usb-ids.h
|
||||
index f9e73b4..d606248 100644
|
||||
--- a/include/media/dvb-usb-ids.h
|
||||
+++ b/include/media/dvb-usb-ids.h
|
||||
@@ -387,7 +387,8 @@
|
||||
#define USB_PID_MYGICA_D689 0xd811
|
||||
#define USB_PID_MYGICA_T230 0xc688
|
||||
#define USB_PID_MYGICA_T230C 0xc689
|
||||
#define USB_PID_MYGICA_T230C2 0xc68a
|
||||
+#define USB_PID_MYGICA_T230C_V2 0xc68a
|
||||
#define USB_PID_ELGATO_EYETV_DIVERSITY 0x0011
|
||||
#define USB_PID_ELGATO_EYETV_DTT 0x0021
|
||||
#define USB_PID_ELGATO_EYETV_DTT_2 0x003f
|
Loading…
Add table
Add a link
Reference in a new issue