[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1806a8e26f5d106ec5ba24c9a861f375b3500b88.1597833138.git.mchehab+huawei@kernel.org>
Date: Wed, 19 Aug 2020 13:45:40 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linuxarm@...wei.com, mauro.chehab@...wei.com,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
John Stultz <john.stultz@...aro.org>,
Manivannan Sadhasivam <mani@...nel.org>,
Daniel Vetter <daniel@...ll.ch>,
dri-devel <dri-devel@...ts.freedesktop.org>,
Xiubin Zhang <zhangxiubin1@...wei.com>,
Andrzej Hajda <a.hajda@...sung.com>,
Tomi Valkeinen <tomi.valkeinen@...com>,
Bogdan Togorean <bogdan.togorean@...log.com>,
Rob Clark <robdclark@...omium.org>,
Laurentiu Palcu <laurentiu.palcu@....com>,
Neil Armstrong <narmstrong@...libre.com>,
Liwei Cai <cailiwei@...ilicon.com>,
linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org
Subject: [PATCH 12/49] staging: hikey9xx/gpu: get rid of adv7535 fork
The OOT had a fork of adv7535 with some changes for it to
work with a failing EDID retrival I/O.
Get rid of it, as we'll be using the upstream driver.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
drivers/staging/hikey9xx/gpu/hdmi/adv7535.c | 1678 -----------------
drivers/staging/hikey9xx/gpu/hdmi/adv7535.h | 351 ----
.../staging/hikey9xx/gpu/hdmi/adv7535_audio.c | 313 ---
3 files changed, 2342 deletions(-)
delete mode 100644 drivers/staging/hikey9xx/gpu/hdmi/adv7535.c
delete mode 100644 drivers/staging/hikey9xx/gpu/hdmi/adv7535.h
delete mode 100644 drivers/staging/hikey9xx/gpu/hdmi/adv7535_audio.c
diff --git a/drivers/staging/hikey9xx/gpu/hdmi/adv7535.c b/drivers/staging/hikey9xx/gpu/hdmi/adv7535.c
deleted file mode 100644
index 04c1e7b9ca8e..000000000000
--- a/drivers/staging/hikey9xx/gpu/hdmi/adv7535.c
+++ /dev/null
@@ -1,1678 +0,0 @@
-/*
- * Analog Devices ADV7511 HDMI transmitter driver
- *
- * Copyright 2012 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/device.h>
-#include <linux/gpio/consumer.h>
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/regmap.h>
-#include <linux/slab.h>
-#include <linux/of_graph.h>
-
-#include <drm/drmP.h>
-#include <drm/drm_crtc_helper.h>
-#include <drm/drm_edid.h>
-#include <drm/drm_encoder_slave.h>
-#include <drm/drm_atomic.h>
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_mipi_dsi.h>
-
-#include <linux/regulator/consumer.h>
-#include <linux/regulator/driver.h>
-#include <linux/regulator/machine.h>
-
-#include "adv7535.h"
-
-//#define HPD_ENABLE 1
-#define HPD_ENABLE 0
-//#define TEST_COLORBAR_DISPLAY
-#ifdef CONFIG_HDMI_ADV7511_AUDIO
-extern int adv7511_audio_init(struct device *dev);
-#endif
-static struct adv7511 *encoder_to_adv7511(struct drm_encoder *encoder)
-{
- return to_encoder_slave(encoder)->slave_priv;
-}
-
-/* ADI recommended values for proper operation. */
-static const struct reg_sequence adv7511_fixed_registers[] = {
- { 0x98, 0x03 },
- { 0x9a, 0xe0 },
- { 0x9c, 0x30 },
- { 0x9d, 0x61 },
- { 0xa2, 0xa4 },
- { 0xa3, 0xa4 },
- { 0xe0, 0xd0 },
- { 0xf9, 0x00 },
- { 0x55, 0x02 },
-};
-
-/* ADI recommended values for proper operation. */
-static const struct reg_sequence adv7533_fixed_registers[] = {
- { 0x16, 0x20 },
- { 0x9a, 0xe0 },
- { 0xba, 0x70 },
- { 0xde, 0x82 },
- { 0xe4, 0x40 },
- { 0xe5, 0x80 },
-};
-
-static const struct reg_sequence adv7533_cec_fixed_registers[] = {
- { 0x15, 0xd0 },
- { 0x17, 0xd0 },
- { 0x24, 0x20 },
- { 0x57, 0x11 },
- { 0x05, 0xc8 },
-};
-
-/* -----------------------------------------------------------------------------
- * Register access
- */
-
-static const uint8_t adv7511_register_defaults[] = {
- 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00 */
- 0x00, 0x00, 0x01, 0x0e, 0xbc, 0x18, 0x01, 0x13,
- 0x25, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10 */
- 0x46, 0x62, 0x04, 0xa8, 0x00, 0x00, 0x1c, 0x84,
- 0x1c, 0xbf, 0x04, 0xa8, 0x1e, 0x70, 0x02, 0x1e, /* 20 */
- 0x00, 0x00, 0x04, 0xa8, 0x08, 0x12, 0x1b, 0xac,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 30 */
- 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xb0,
- 0x00, 0x50, 0x90, 0x7e, 0x79, 0x70, 0x00, 0x00, /* 40 */
- 0x00, 0xa8, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x0d, 0x00, 0x00, 0x00, 0x00, /* 50 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 60 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 70 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 80 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, /* 90 */
- 0x0b, 0x02, 0x00, 0x18, 0x5a, 0x60, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x80, 0x08, 0x04, 0x00, 0x00, /* a0 */
- 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x14,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c0 */
- 0x00, 0x03, 0x00, 0x00, 0x02, 0x00, 0x01, 0x04,
- 0x30, 0xff, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, /* d0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01,
- 0x80, 0x75, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, /* e0 */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x11, 0x00, /* f0 */
- 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-static bool adv7511_register_volatile(struct device *dev, unsigned int reg)
-{
- switch (reg) {
- case ADV7511_REG_CHIP_REVISION:
- case ADV7511_REG_SPDIF_FREQ:
- case ADV7511_REG_CTS_AUTOMATIC1:
- case ADV7511_REG_CTS_AUTOMATIC2:
- case ADV7511_REG_VIC_DETECTED:
- case ADV7511_REG_VIC_SEND:
- case ADV7511_REG_AUX_VIC_DETECTED:
- case ADV7511_REG_STATUS:
- case ADV7511_REG_GC(1):
- case ADV7511_REG_INT(0):
- case ADV7511_REG_INT(1):
- case ADV7511_REG_PLL_STATUS:
- case ADV7511_REG_AN(0):
- case ADV7511_REG_AN(1):
- case ADV7511_REG_AN(2):
- case ADV7511_REG_AN(3):
- case ADV7511_REG_AN(4):
- case ADV7511_REG_AN(5):
- case ADV7511_REG_AN(6):
- case ADV7511_REG_AN(7):
- case ADV7511_REG_HDCP_STATUS:
- case ADV7511_REG_BCAPS:
- case ADV7511_REG_BKSV(0):
- case ADV7511_REG_BKSV(1):
- case ADV7511_REG_BKSV(2):
- case ADV7511_REG_BKSV(3):
- case ADV7511_REG_BKSV(4):
- case ADV7511_REG_DDC_STATUS:
- case ADV7511_REG_BSTATUS(0):
- case ADV7511_REG_BSTATUS(1):
- case ADV7511_REG_CHIP_ID_HIGH:
- case ADV7511_REG_CHIP_ID_LOW:
- return true;
- }
-
- return false;
-}
-
-static const struct regmap_config adv7511_regmap_config = {
- .reg_bits = 8,
- .val_bits = 8,
-
- .max_register = 0xff,
- .cache_type = REGCACHE_RBTREE,
- .reg_defaults_raw = adv7511_register_defaults,
- .num_reg_defaults_raw = ARRAY_SIZE(adv7511_register_defaults),
-
- .volatile_reg = adv7511_register_volatile,
-};
-
-static const struct regmap_config adv7533_cec_regmap_config = {
- .reg_bits = 8,
- .val_bits = 8,
-
- .max_register = 0xff,
- .cache_type = REGCACHE_RBTREE,
-};
-
-static const struct regmap_config adv7533_packet_regmap_config = {
- .reg_bits = 8,
- .val_bits = 8,
-
- .max_register = 0xff,
- .cache_type = REGCACHE_RBTREE,
-};
-
-
-/* -----------------------------------------------------------------------------
- * Hardware configuration
- */
-
-static void adv7511_set_colormap(struct adv7511 *adv7511, bool enable,
- const uint16_t *coeff,
- unsigned int scaling_factor)
-{
- unsigned int i;
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(1),
- ADV7511_CSC_UPDATE_MODE, ADV7511_CSC_UPDATE_MODE);
-
- if (enable) {
- for (i = 0; i < 12; ++i) {
- regmap_update_bits(adv7511->regmap,
- ADV7511_REG_CSC_UPPER(i),
- 0x1f, coeff[i] >> 8);
- regmap_write(adv7511->regmap,
- ADV7511_REG_CSC_LOWER(i),
- coeff[i] & 0xff);
- }
- }
-
- if (enable)
- regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(0),
- 0xe0, 0x80 | (scaling_factor << 5));
- else
- regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(0),
- 0x80, 0x00);
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_CSC_UPPER(1),
- ADV7511_CSC_UPDATE_MODE, 0);
-}
-
-int adv7511_packet_enable(struct adv7511 *adv7511, unsigned int packet)
-{
- if (packet & 0xff)
- regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE0,
- packet, 0xff);
-
- if (packet & 0xff00) {
- packet >>= 8;
- regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE1,
- packet, 0xff);
- }
-
- return 0;
-}
-
-int adv7511_packet_disable(struct adv7511 *adv7511, unsigned int packet)
-{
- if (packet & 0xff)
- regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE0,
- packet, 0x00);
-
- if (packet & 0xff00) {
- packet >>= 8;
- regmap_update_bits(adv7511->regmap, ADV7511_REG_PACKET_ENABLE1,
- packet, 0x00);
- }
-
- return 0;
-}
-
-/* Coefficients for adv7511 color space conversion */
-static const uint16_t adv7511_csc_ycbcr_to_rgb[] = {
- 0x0734, 0x04ad, 0x0000, 0x1c1b,
- 0x1ddc, 0x04ad, 0x1f24, 0x0135,
- 0x0000, 0x04ad, 0x087c, 0x1b77,
-};
-
-static void adv7511_set_config_csc(struct adv7511 *adv7511,
- struct drm_connector *connector,
- bool rgb)
-{
- struct adv7511_video_config config;
- bool output_format_422, output_format_ycbcr;
- unsigned int mode;
- uint8_t infoframe[17];
-
- if (adv7511->edid)
- config.hdmi_mode = drm_detect_hdmi_monitor(adv7511->edid);
- else
- config.hdmi_mode = false;
-
- hdmi_avi_infoframe_init(&config.avi_infoframe);
-
- config.avi_infoframe.scan_mode = HDMI_SCAN_MODE_UNDERSCAN;
-
- if (rgb) {
- config.csc_enable = false;
- config.avi_infoframe.colorspace = HDMI_COLORSPACE_RGB;
- } else {
- config.csc_scaling_factor = ADV7511_CSC_SCALING_4;
- config.csc_coefficents = adv7511_csc_ycbcr_to_rgb;
-
- if ((connector->display_info.color_formats &
- DRM_COLOR_FORMAT_YCRCB422) &&
- config.hdmi_mode) {
- config.csc_enable = false;
- config.avi_infoframe.colorspace =
- HDMI_COLORSPACE_YUV422;
- } else {
- config.csc_enable = true;
- config.avi_infoframe.colorspace = HDMI_COLORSPACE_RGB;
- }
- }
-
- if (config.hdmi_mode) {
- mode = ADV7511_HDMI_CFG_MODE_HDMI;
-
- switch (config.avi_infoframe.colorspace) {
- case HDMI_COLORSPACE_YUV444:
- output_format_422 = false;
- output_format_ycbcr = true;
- break;
- case HDMI_COLORSPACE_YUV422:
- output_format_422 = true;
- output_format_ycbcr = true;
- break;
- default:
- output_format_422 = false;
- output_format_ycbcr = false;
- break;
- }
- } else {
- mode = ADV7511_HDMI_CFG_MODE_DVI;
- output_format_422 = false;
- output_format_ycbcr = false;
- }
-
- adv7511_packet_disable(adv7511, ADV7511_PACKET_ENABLE_AVI_INFOFRAME);
-
- adv7511_set_colormap(adv7511, config.csc_enable,
- config.csc_coefficents,
- config.csc_scaling_factor);
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG1, 0x81,
- (output_format_422 << 7) | output_format_ycbcr);
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_HDCP_HDMI_CFG,
- ADV7511_HDMI_CFG_MODE_MASK, mode);
-
- hdmi_avi_infoframe_pack(&config.avi_infoframe, infoframe,
- sizeof(infoframe));
-
- /* The AVI infoframe id is not configurable */
- regmap_bulk_write(adv7511->regmap, ADV7511_REG_AVI_INFOFRAME_VERSION,
- infoframe + 1, sizeof(infoframe) - 1);
-
- adv7511_packet_enable(adv7511, ADV7511_PACKET_ENABLE_AVI_INFOFRAME);
-}
-
-static void adv7511_set_link_config(struct adv7511 *adv7511,
- const struct adv7511_link_config *config)
-{
- /*
- * The input style values documented in the datasheet don't match the
- * hardware register field values :-(
- */
- static const unsigned int input_styles[4] = { 0, 2, 1, 3 };
-
- unsigned int clock_delay;
- unsigned int color_depth;
- unsigned int input_id;
-
- clock_delay = (config->clock_delay + 1200) / 400;
- color_depth = config->input_color_depth == 8 ? 3
- : (config->input_color_depth == 10 ? 1 : 2);
-
- /* TODO Support input ID 6 */
- if (config->input_colorspace != HDMI_COLORSPACE_YUV422)
- input_id = config->input_clock == ADV7511_INPUT_CLOCK_DDR
- ? 5 : 0;
- else if (config->input_clock == ADV7511_INPUT_CLOCK_DDR)
- input_id = config->embedded_sync ? 8 : 7;
- else if (config->input_clock == ADV7511_INPUT_CLOCK_2X)
- input_id = config->embedded_sync ? 4 : 3;
- else
- input_id = config->embedded_sync ? 2 : 1;
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_I2C_FREQ_ID_CFG, 0xf,
- input_id);
- regmap_update_bits(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG1, 0x7e,
- (color_depth << 4) |
- (input_styles[config->input_style] << 2));
- regmap_write(adv7511->regmap, ADV7511_REG_VIDEO_INPUT_CFG2,
- config->input_justification << 3);
- regmap_write(adv7511->regmap, ADV7511_REG_TIMING_GEN_SEQ,
- config->sync_pulse << 2);
-
- regmap_write(adv7511->regmap, 0xba, clock_delay << 5);
-
- adv7511->embedded_sync = config->embedded_sync;
- adv7511->hsync_polarity = config->hsync_polarity;
- adv7511->vsync_polarity = config->vsync_polarity;
- adv7511->rgb = config->input_colorspace == HDMI_COLORSPACE_RGB;
-}
-
-static void adv7511_dsi_config_tgen(struct adv7511 *adv7511)
-{
- struct drm_display_mode *mode = &adv7511->curr_mode;
- u8 clock_div_by_lanes[] = { 6, 4, 3 }; /* 2, 3, 4 lanes */
- unsigned int hsw, hfp, hbp, vsw, vfp, vbp;
-
- hsw = mode->hsync_end - mode->hsync_start;
- hfp = mode->hsync_start - mode->hdisplay;
- hbp = mode->htotal - mode->hsync_end;
- vsw = mode->vsync_end - mode->vsync_start;
- vfp = mode->vsync_start - mode->vdisplay;
- vbp = mode->vtotal - mode->vsync_end;
-
-#ifdef TEST_COLORBAR_DISPLAY
- /* set pixel clock auto mode */
- regmap_write(adv7511->regmap_cec, 0x16,
- 0x00);
-#else
- /* set pixel clock divider mode */
- regmap_write(adv7511->regmap_cec, 0x16,
- clock_div_by_lanes[adv7511->num_dsi_lanes - 2] << 3);
-#endif
-
- /* horizontal porch params */
- regmap_write(adv7511->regmap_cec, 0x28, mode->htotal >> 4);
- regmap_write(adv7511->regmap_cec, 0x29, (mode->htotal << 4) & 0xff);
- regmap_write(adv7511->regmap_cec, 0x2a, hsw >> 4);
- regmap_write(adv7511->regmap_cec, 0x2b, (hsw << 4) & 0xff);
- regmap_write(adv7511->regmap_cec, 0x2c, hfp >> 4);
- regmap_write(adv7511->regmap_cec, 0x2d, (hfp << 4) & 0xff);
- regmap_write(adv7511->regmap_cec, 0x2e, hbp >> 4);
- regmap_write(adv7511->regmap_cec, 0x2f, (hbp << 4) & 0xff);
-
- /* vertical porch params */
- regmap_write(adv7511->regmap_cec, 0x30, mode->vtotal >> 4);
- regmap_write(adv7511->regmap_cec, 0x31, (mode->vtotal << 4) & 0xff);
- regmap_write(adv7511->regmap_cec, 0x32, vsw >> 4);
- regmap_write(adv7511->regmap_cec, 0x33, (vsw << 4) & 0xff);
- regmap_write(adv7511->regmap_cec, 0x34, vfp >> 4);
- regmap_write(adv7511->regmap_cec, 0x35, (vfp << 4) & 0xff);
- regmap_write(adv7511->regmap_cec, 0x36, vbp >> 4);
- regmap_write(adv7511->regmap_cec, 0x37, (vbp << 4) & 0xff);
-}
-
-static void adv7511_dsi_receiver_dpms(struct adv7511 *adv7511)
-{
- if (adv7511->type != ADV7533)
- return;
-
- if (adv7511->powered) {
- struct mipi_dsi_device *dsi = adv7511->dsi;
-
- adv7511_dsi_config_tgen(adv7511);
-
- /* set number of dsi lanes */
- regmap_write(adv7511->regmap_cec, 0x1c, dsi->lanes << 4);
-
-#ifdef TEST_COLORBAR_DISPLAY
- /* reset internal timing generator */
- regmap_write(adv7511->regmap_cec, 0x27, 0xcb);
- regmap_write(adv7511->regmap_cec, 0x27, 0x8b);
- regmap_write(adv7511->regmap_cec, 0x27, 0xcb);
-#else
- /* disable internal timing generator */
- regmap_write(adv7511->regmap_cec, 0x27, 0x0b);
-#endif
-
-
- /* enable hdmi */
- regmap_write(adv7511->regmap_cec, 0x03, 0x89);
-#ifdef TEST_COLORBAR_DISPLAY
- /*enable test mode */
- regmap_write(adv7511->regmap_cec, 0x55, 0x80);//display colorbar
-#else
- /* disable test mode */
- regmap_write(adv7511->regmap_cec, 0x55, 0x00);
-#endif
- /* disable test mode */
- //regmap_write(adv7511->regmap_cec, 0x55, 0x00);
- /* SPD */
- {
- static const unsigned char spd_if[] = {
- 0x83, 0x01, 25, 0x00,
- 'L', 'i', 'n', 'a', 'r', 'o', 0, 0,
- '9', '6', 'b', 'o', 'a', 'r', 'd', 's',
- ':', 'H', 'i', 'k', 'e', 'y', 0, 0,
- };
- int n;
-
- for (n = 0; n < sizeof(spd_if); n++)
- regmap_write(adv7511->regmap_packet, n, spd_if[n]);
-
- /* enable send SPD */
- regmap_update_bits(adv7511->regmap, 0x40, BIT(6), BIT(6));
- }
-
- /* force audio */
- /* hide Audio infoframe updates */
- regmap_update_bits(adv7511->regmap, 0x4a, BIT(5), BIT(5));
-
- /* i2s, internal mclk, mclk-256 */
- regmap_update_bits(adv7511->regmap, 0x0a, 0x1f, 1);
- regmap_update_bits(adv7511->regmap, 0x0b, 0xe0, 0);
- /* enable i2s, use i2s format, sample rate from i2s */
- regmap_update_bits(adv7511->regmap, 0x0c, 0xc7, BIT(2));
- /* 16 bit audio */
- regmap_update_bits(adv7511->regmap, 0x0d, 0xff, 16);
- /* 16-bit audio */
- regmap_update_bits(adv7511->regmap, 0x14, 0x0f, 2 << 4);
- /* 48kHz */
- regmap_update_bits(adv7511->regmap, 0x15, 0xf0, 2 << 4);
- /* enable N/CTS, enable Audio sample packets */
- regmap_update_bits(adv7511->regmap, 0x44, BIT(5), BIT(5));
- /* N = 6144 */
- regmap_write(adv7511->regmap, 1, (6144 >> 16) & 0xf);
- regmap_write(adv7511->regmap, 2, (6144 >> 8) & 0xff);
- regmap_write(adv7511->regmap, 3, (6144) & 0xff);
- /* automatic cts */
- regmap_update_bits(adv7511->regmap, 0x0a, BIT(7), 0);
- /* enable N/CTS */
- regmap_update_bits(adv7511->regmap, 0x44, BIT(6), BIT(6));
- /* not copyrighted */
- regmap_update_bits(adv7511->regmap, 0x12, BIT(5), BIT(5));
-
- /* left source */
- regmap_update_bits(adv7511->regmap, 0x0e, 7 << 3, 0);
- /* right source */
- regmap_update_bits(adv7511->regmap, 0x0e, 7 << 0, 1);
- /* number of channels: sect 4.5.4: set to 0 */
- regmap_update_bits(adv7511->regmap, 0x73, 7, 1);
- /* number of channels: sect 4.5.4: set to 0 */
- regmap_update_bits(adv7511->regmap, 0x73, 0xf0, 1 << 4);
- /* sample rate: 48kHz */
- regmap_update_bits(adv7511->regmap, 0x74, 7 << 2, 3 << 2);
- /* channel allocation reg: sect 4.5.4: set to 0 */
- regmap_update_bits(adv7511->regmap, 0x76, 0xff, 0);
- /* enable audio infoframes */
- regmap_update_bits(adv7511->regmap, 0x44, BIT(3), BIT(3));
-
- /* AV mute disable */
- regmap_update_bits(adv7511->regmap, 0x4b, BIT(7) | BIT(6), BIT(7));
-
- /* use Audio infoframe updated info */
- regmap_update_bits(adv7511->regmap, 0x4a, BIT(5), 0);
- } else {
- regmap_write(adv7511->regmap_cec, 0x03, 0x0b);
- regmap_write(adv7511->regmap_cec, 0x27, 0x0b);
- }
-}
-
-static void adv7511_power_on(struct adv7511 *adv7511)
-{
- adv7511->current_edid_segment = -1;
-
- regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
- ADV7511_INT0_EDID_READY);
- regmap_write(adv7511->regmap, ADV7511_REG_INT(1),
- ADV7511_INT1_DDC_ERROR);
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
- ADV7511_POWER_POWER_DOWN, 0);
-
- /*
- * Per spec it is allowed to pulse the HDP signal to indicate that the
- * EDID information has changed. Some monitors do this when they wakeup
- * from standby or are enabled. When the HDP goes low the adv7511 is
- * reset and the outputs are disabled which might cause the monitor to
- * go to standby again. To avoid this we ignore the HDP pin for the
- * first few seconds after enabling the output.
- */
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2,
- ADV7511_REG_POWER2_HDP_SRC_MASK,
- ADV7511_REG_POWER2_HDP_SRC_NONE);
-
- /*
- * Most of the registers are reset during power down or when HPD is low.
- */
- regcache_sync(adv7511->regmap);
-
- if (adv7511->type == ADV7533)
- regmap_register_patch(adv7511->regmap_cec,
- adv7533_cec_fixed_registers,
- ARRAY_SIZE(adv7533_cec_fixed_registers));
- adv7511->powered = true;
-
- adv7511_dsi_receiver_dpms(adv7511);
-}
-
-static void adv7511_power_off(struct adv7511 *adv7511)
-{
- /* TODO: setup additional power down modes */
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
- ADV7511_POWER_POWER_DOWN,
- ADV7511_POWER_POWER_DOWN);
- regcache_mark_dirty(adv7511->regmap);
-
- adv7511->powered = false;
-
- adv7511_dsi_receiver_dpms(adv7511);
-}
-
-/* -----------------------------------------------------------------------------
- * Interrupt and hotplug detection
- */
-
-#if HPD_ENABLE
-static bool adv7511_hpd(struct adv7511 *adv7511)
-{
- unsigned int irq0;
- int ret;
-
- ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0);
- if (ret < 0)
- return false;
-
- if (irq0 & ADV7511_INT0_HDP) {
- regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
- ADV7511_INT0_HDP);
- return true;
- }
-
- return false;
-}
-#endif
-
-static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
-{
- unsigned int irq0, irq1;
- int ret;
-
- ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0);
- if (ret < 0)
- return ret;
-
- ret = regmap_read(adv7511->regmap, ADV7511_REG_INT(1), &irq1);
- if (ret < 0)
- return ret;
-
- regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
- regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);
-
- if (process_hpd && irq0 & ADV7511_INT0_HDP && adv7511->encoder)
- drm_helper_hpd_irq_event(adv7511->encoder->dev);
-
- if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
- adv7511->edid_read = true;
-
- if (adv7511->i2c_main->irq)
- wake_up_all(&adv7511->wq);
- }
-
- return 0;
-}
-
-static irqreturn_t adv7511_irq_handler(int irq, void *devid)
-{
- struct adv7511 *adv7511 = devid;
- int ret;
-
- ret = adv7511_irq_process(adv7511, true);
- return ret < 0 ? IRQ_NONE : IRQ_HANDLED;
-}
-
-/* -----------------------------------------------------------------------------
- * EDID retrieval
- */
-
-static int adv7511_wait_for_edid(struct adv7511 *adv7511, int timeout)
-{
- int ret;
-
- if (adv7511->i2c_main->irq) {
- ret = wait_event_interruptible_timeout(adv7511->wq,
- adv7511->edid_read, msecs_to_jiffies(timeout));
- } else {
- for (; timeout > 0; timeout -= 25) {
- ret = adv7511_irq_process(adv7511, false);
- if (ret < 0)
- break;
-
- if (adv7511->edid_read)
- break;
-
- msleep(25);
- }
- }
-
- return adv7511->edid_read ? 0 : -EIO;
-}
-
-static int adv7511_get_edid_block(void *data, u8 *buf, unsigned int block,
- size_t len)
-{
- struct adv7511 *adv7511 = data;
- struct i2c_msg xfer[2];
- uint8_t offset;
- unsigned int i;
- int ret;
-
- if (len > 128)
- return -EINVAL;
-
- if (adv7511->current_edid_segment != block / 2) {
- unsigned int status;
-
- ret = regmap_read(adv7511->regmap, ADV7511_REG_DDC_STATUS,
- &status);
- if (ret < 0)
- return ret;
-
- if (status != 2) {
- adv7511->edid_read = false;
- regmap_write(adv7511->regmap, ADV7511_REG_EDID_SEGMENT,
- block);
- ret = adv7511_wait_for_edid(adv7511, 200);
- if (ret < 0)
- return ret;
- }
-
- /* Break this apart, hopefully more I2C controllers will
- * support 64 byte transfers than 256 byte transfers
- */
-
- xfer[0].addr = adv7511->i2c_edid->addr;
- xfer[0].flags = 0;
- xfer[0].len = 1;
- xfer[0].buf = &offset;
- xfer[1].addr = adv7511->i2c_edid->addr;
- xfer[1].flags = I2C_M_RD;
- xfer[1].len = 64;
- xfer[1].buf = adv7511->edid_buf;
-
- offset = 0;
-
- for (i = 0; i < 4; ++i) {
- ret = i2c_transfer(adv7511->i2c_edid->adapter, xfer,
- ARRAY_SIZE(xfer));
- if (ret < 0)
- return ret;
- else if (ret != 2)
- return -EIO;
-
- xfer[1].buf += 64;
- offset += 64;
- }
-
- adv7511->current_edid_segment = block / 2;
- }
-
- if (block % 2 == 0)
- memcpy(buf, adv7511->edid_buf, len);
- else
- memcpy(buf, adv7511->edid_buf + 128, len);
-
- return 0;
-}
-
-/* -----------------------------------------------------------------------------
- * ADV75xx helpers
- */
-static int adv7511_get_modes(struct adv7511 *adv7511,
- struct drm_connector *connector)
-{
- struct edid *edid;
- unsigned int count;
-
- /* Reading the EDID only works if the device is powered */
- if (!adv7511->powered) {
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2,
- ADV7511_REG_POWER2_HDP_SRC_MASK,
- ADV7511_REG_POWER2_HDP_SRC_NONE);
- regmap_write(adv7511->regmap, ADV7511_REG_INT(0),
- ADV7511_INT0_EDID_READY);
- regmap_write(adv7511->regmap, ADV7511_REG_INT(1),
- ADV7511_INT1_DDC_ERROR);
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
- ADV7511_POWER_POWER_DOWN, 0);
- adv7511->current_edid_segment = -1;
- /* wait some time for edid is ready */
- msleep(200);
- }
-
- edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511);
-
- if (!adv7511->powered)
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER,
- ADV7511_POWER_POWER_DOWN,
- ADV7511_POWER_POWER_DOWN);
-
- kfree(adv7511->edid);
- adv7511->edid = edid;
- if (!edid)
- return 0;
-
- drm_mode_connector_update_edid_property(connector, edid);
- count = drm_add_edid_modes(connector, edid);
-
- adv7511_set_config_csc(adv7511, connector, adv7511->rgb);
-
- return count;
-}
-
-static enum drm_connector_status
-adv7511_detect(struct adv7511 *adv7511,
- struct drm_connector *connector)
-{
- enum drm_connector_status status;
- unsigned int val;
- unsigned int time = 0;
-#if HPD_ENABLE
- bool hpd;
-#endif
- int ret;
-
- ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val);
- if (ret < 0) {
- DRM_ERROR("regmap_read fail, ret = %d \n", ret);
- return connector_status_disconnected;
- }
-
- if (val & ADV7511_STATUS_HPD) {
- DRM_INFO("connected : regmap_read val = 0x%x \n", val);
- status = connector_status_connected;
- } else {
- DRM_INFO("disconnected : regmap_read val = 0x%x \n", val);
- status = connector_status_disconnected;
- }
-
-#if HPD_ENABLE
- hpd = adv7511_hpd(adv7511);
-
- /* The chip resets itself when the cable is disconnected, so in case
- * there is a pending HPD interrupt and the cable is connected there was
- * at least one transition from disconnected to connected and the chip
- * has to be reinitialized. */
- if (status == connector_status_connected && hpd && adv7511->powered) {
- regcache_mark_dirty(adv7511->regmap);
- adv7511_power_on(adv7511);
- adv7511_get_modes(adv7511, connector);
- if (adv7511->status == connector_status_connected)
- status = connector_status_disconnected;
- } else {
- /* Renable HDP sensing */
- regmap_update_bits(adv7511->regmap, ADV7511_REG_POWER2,
- ADV7511_REG_POWER2_HDP_SRC_MASK,
- ADV7511_REG_POWER2_HDP_SRC_BOTH);
- }
-#endif
-
- if (status == connector_status_disconnected) {
- do {
- ret = regmap_read(adv7511->regmap, ADV7511_REG_STATUS, &val);
- if (ret < 0) {
- DRM_ERROR("regmap_read fail, ret = %d \n", ret);
- return connector_status_disconnected;
- }
-
- if (val & ADV7511_STATUS_HPD) {
- DRM_INFO("connected : regmap_read val = 0x%x \n", val);
- status = connector_status_connected;
- } else {
- DRM_INFO("disconnected : regmap_read val = 0x%x \n", val);
- status = connector_status_disconnected;
- }
- time ++;
- mdelay(20);
- } while (status == connector_status_disconnected && time < 10);
- }
-
- if (time >= 10)
- DRM_ERROR("Read connector status timout, time = %d \n", time);
-
- adv7511->status = status;
-
- DRM_INFO("hdmi connector status = %d \n", status);
- return status;
-}
-
-static int adv7511_mode_valid(struct adv7511 *adv7511,
- struct drm_display_mode *mode)
-{
- if (mode->clock > 165000)
- return MODE_CLOCK_HIGH;
- /*
- * some work well modes which want to put in the front of the mode list.
- */
- printk("Checking mode %ix%i@%i clock: %i...",
- mode->hdisplay, mode->vdisplay, drm_mode_vrefresh(mode), mode->clock);
- if ((mode->hdisplay == 1920 && mode->vdisplay == 1080 && mode->clock == 148500) ||
- (mode->hdisplay == 1280 && mode->vdisplay == 800 && mode->clock == 83496) ||
- (mode->hdisplay == 1280 && mode->vdisplay == 720 && mode->clock == 74440) ||
- (mode->hdisplay == 1280 && mode->vdisplay == 720 && mode->clock == 74250) ||
- (mode->hdisplay == 1024 && mode->vdisplay == 768 && mode->clock == 75000) ||
- (mode->hdisplay == 1024 && mode->vdisplay == 768 && mode->clock == 81833) ||
- (mode->hdisplay == 800 && mode->vdisplay == 600 && mode->clock == 40000)) {
- mode->type |= DRM_MODE_TYPE_PREFERRED;
- printk("OK\n");
- return MODE_OK;
- }
- printk("BAD\n");
- return MODE_BAD;
-}
-
-static void adv7511_mode_set(struct adv7511 *adv7511,
- struct drm_display_mode *mode,
- struct drm_display_mode *adj_mode)
-{
- unsigned int low_refresh_rate;
- unsigned int hsync_polarity = 0;
- unsigned int vsync_polarity = 0;
-
- if (adv7511->embedded_sync) {
- unsigned int hsync_offset, hsync_len;
- unsigned int vsync_offset, vsync_len;
-
- hsync_offset = adj_mode->crtc_hsync_start -
- adj_mode->crtc_hdisplay;
- vsync_offset = adj_mode->crtc_vsync_start -
- adj_mode->crtc_vdisplay;
- hsync_len = adj_mode->crtc_hsync_end -
- adj_mode->crtc_hsync_start;
- vsync_len = adj_mode->crtc_vsync_end -
- adj_mode->crtc_vsync_start;
-
- /* The hardware vsync generator has a off-by-one bug */
- vsync_offset += 1;
-
- regmap_write(adv7511->regmap, ADV7511_REG_HSYNC_PLACEMENT_MSB,
- ((hsync_offset >> 10) & 0x7) << 5);
- regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(0),
- (hsync_offset >> 2) & 0xff);
- regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(1),
- ((hsync_offset & 0x3) << 6) |
- ((hsync_len >> 4) & 0x3f));
- regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(2),
- ((hsync_len & 0xf) << 4) |
- ((vsync_offset >> 6) & 0xf));
- regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(3),
- ((vsync_offset & 0x3f) << 2) |
- ((vsync_len >> 8) & 0x3));
- regmap_write(adv7511->regmap, ADV7511_REG_SYNC_DECODER(4),
- vsync_len & 0xff);
-
- hsync_polarity = !(adj_mode->flags & DRM_MODE_FLAG_PHSYNC);
- vsync_polarity = !(adj_mode->flags & DRM_MODE_FLAG_PVSYNC);
- } else {
- enum adv7511_sync_polarity mode_hsync_polarity;
- enum adv7511_sync_polarity mode_vsync_polarity;
-
- /**
- * If the input signal is always low or always high we want to
- * invert or let it passthrough depending on the polarity of the
- * current mode.
- **/
- if (adj_mode->flags & DRM_MODE_FLAG_NHSYNC)
- mode_hsync_polarity = ADV7511_SYNC_POLARITY_LOW;
- else
- mode_hsync_polarity = ADV7511_SYNC_POLARITY_HIGH;
-
- if (adj_mode->flags & DRM_MODE_FLAG_NVSYNC)
- mode_vsync_polarity = ADV7511_SYNC_POLARITY_LOW;
- else
- mode_vsync_polarity = ADV7511_SYNC_POLARITY_HIGH;
-
- if (adv7511->hsync_polarity != mode_hsync_polarity &&
- adv7511->hsync_polarity !=
- ADV7511_SYNC_POLARITY_PASSTHROUGH)
- hsync_polarity = 1;
-
- if (adv7511->vsync_polarity != mode_vsync_polarity &&
- adv7511->vsync_polarity !=
- ADV7511_SYNC_POLARITY_PASSTHROUGH)
- vsync_polarity = 1;
- }
-
- if (mode->vrefresh <= 24000)
- low_refresh_rate = ADV7511_LOW_REFRESH_RATE_24HZ;
- else if (mode->vrefresh <= 25000)
- low_refresh_rate = ADV7511_LOW_REFRESH_RATE_25HZ;
- else if (mode->vrefresh <= 30000)
- low_refresh_rate = ADV7511_LOW_REFRESH_RATE_30HZ;
- else
- low_refresh_rate = ADV7511_LOW_REFRESH_RATE_NONE;
-
- regmap_update_bits(adv7511->regmap, 0xfb,
- 0x6, low_refresh_rate << 1);
- regmap_update_bits(adv7511->regmap, 0x17,
- 0x60, (vsync_polarity << 6) | (hsync_polarity << 5));
-
- if (adv7511->type == ADV7533 && adv7511->num_dsi_lanes == 4) {
- struct mipi_dsi_device *dsi = adv7511->dsi;
- int lanes, ret;
-
- if (adj_mode->clock > 80000)
- lanes = 4;
- else
- lanes = 3;
-
- if (lanes != dsi->lanes) {
- mipi_dsi_detach(dsi);
- dsi->lanes = lanes;
- ret = mipi_dsi_attach(dsi);
- if (ret) {
- DRM_ERROR("Failed to change host lanes\n");
- return;
- }
- }
- }
-
- drm_mode_copy(&adv7511->curr_mode, adj_mode);
-
- /*
- * TODO Test first order 4:2:2 to 4:4:4 up conversion method, which is
- * supposed to give better results.
- */
-
- adv7511->f_tmds = mode->clock;
-}
-
-/* -----------------------------------------------------------------------------
- * Encoder operations
- */
-
-static int adv7511_encoder_get_modes(struct drm_encoder *encoder,
- struct drm_connector *connector)
-{
- struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-
- return adv7511_get_modes(adv7511, connector);
-}
-
-static void adv7511_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
- struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-
- if (mode == DRM_MODE_DPMS_ON)
- adv7511_power_on(adv7511);
- else
- adv7511_power_off(adv7511);
-}
-
-static enum drm_connector_status
-adv7511_encoder_detect(struct drm_encoder *encoder,
- struct drm_connector *connector)
-{
- struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-
- return adv7511_detect(adv7511, connector);
-}
-
-static int adv7511_encoder_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
-{
- struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-
- return adv7511_mode_valid(adv7511, mode);
-}
-
-static void adv7511_encoder_mode_set(struct drm_encoder *encoder,
- struct drm_display_mode *mode,
- struct drm_display_mode *adj_mode)
-{
- struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-
- adv7511_mode_set(adv7511, mode, adj_mode);
-}
-
-static struct drm_encoder_slave_funcs adv7511_encoder_funcs = {
- .dpms = adv7511_encoder_dpms,
- .mode_valid = adv7511_encoder_mode_valid,
- .mode_set = adv7511_encoder_mode_set,
- .detect = adv7511_encoder_detect,
- .get_modes = adv7511_encoder_get_modes,
-};
-
-/* -----------------------------------------------------------------------------
- * Bridge and connector functions
- */
-
-static struct adv7511 *connector_to_adv7511(struct drm_connector *connector)
-{
- return container_of(connector, struct adv7511, connector);
-}
-
-/* Connector helper functions */
-static int adv7533_connector_get_modes(struct drm_connector *connector)
-{
- struct adv7511 *adv = connector_to_adv7511(connector);
-
- return adv7511_get_modes(adv, connector);
-}
-
-static struct drm_encoder *
-adv7533_connector_best_encoder(struct drm_connector *connector)
-{
- struct adv7511 *adv = connector_to_adv7511(connector);
-
- return adv->bridge.encoder;
-}
-
-static enum drm_mode_status
-adv7533_connector_mode_valid(struct drm_connector *connector,
- struct drm_display_mode *mode)
-{
- struct adv7511 *adv = connector_to_adv7511(connector);
-
- return adv7511_mode_valid(adv, mode);
-}
-
-static struct drm_connector_helper_funcs adv7533_connector_helper_funcs = {
- .get_modes = adv7533_connector_get_modes,
- .best_encoder = adv7533_connector_best_encoder,
- .mode_valid = adv7533_connector_mode_valid,
-};
-
-static enum drm_connector_status
-adv7533_connector_detect(struct drm_connector *connector, bool force)
-{
- struct adv7511 *adv = connector_to_adv7511(connector);
-
- return adv7511_detect(adv, connector);
-}
-
-static struct drm_connector_funcs adv7533_connector_funcs = {
- .dpms = drm_atomic_helper_connector_dpms,
- .fill_modes = drm_helper_probe_single_connector_modes,
- .detect = adv7533_connector_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,
-};
-
-/* Bridge funcs */
-static struct adv7511 *bridge_to_adv7511(struct drm_bridge *bridge)
-{
- return container_of(bridge, struct adv7511, bridge);
-}
-
-static void adv7533_bridge_pre_enable(struct drm_bridge *bridge)
-{
- struct adv7511 *adv = bridge_to_adv7511(bridge);
-
- adv7511_power_on(adv);
-}
-
-static void adv7533_bridge_post_disable(struct drm_bridge *bridge)
-{
- struct adv7511 *adv = bridge_to_adv7511(bridge);
-
-#if HPD_ENABLE
- if (!adv->powered)
- return;
-#endif
-
- adv7511_power_off(adv);
-}
-
-static void adv7533_bridge_enable(struct drm_bridge *bridge)
-{
-}
-
-static void adv7533_bridge_disable(struct drm_bridge *bridge)
-{
-}
-
-static void adv7533_bridge_mode_set(struct drm_bridge *bridge,
- struct drm_display_mode *mode,
- struct drm_display_mode *adj_mode)
-{
- struct adv7511 *adv = bridge_to_adv7511(bridge);
-
- adv7511_mode_set(adv, mode, adj_mode);
-}
-
-static int adv7533_attach_dsi(struct adv7511 *adv7511)
-{
- struct device *dev = &adv7511->i2c_main->dev;
- struct mipi_dsi_device *dsi;
- struct mipi_dsi_host *host;
- int ret;
- const struct mipi_dsi_device_info info = { .type = "adv7533",
- .channel = 0,
- .node = NULL,
- };
-
- host = of_find_mipi_dsi_host_by_node(adv7511->host_node);
- if (!host) {
- dev_err(dev, "failed to find dsi host\n");
- return -EPROBE_DEFER;
- }
-
- dsi = mipi_dsi_device_register_full(host, &info);
- if (IS_ERR(dsi)) {
- dev_err(dev, "failed to create dummy dsi device\n");
- ret = PTR_ERR(dsi);
- goto err_dsi_device;
- }
-
- adv7511->dsi = dsi;
-
- dsi->lanes = adv7511->num_dsi_lanes;
- dsi->format = MIPI_DSI_FMT_RGB888;
- dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE
- | MIPI_DSI_MODE_EOT_PACKET | MIPI_DSI_MODE_VIDEO_HSE;
-
- ret = mipi_dsi_attach(dsi);
- if (ret < 0) {
- dev_err(dev, "failed to attach dsi to host\n");
- goto err_dsi_attach;
- }
-
- return 0;
-
-err_dsi_attach:
- mipi_dsi_device_unregister(dsi);
-err_dsi_device:
- return ret;
-}
-
-static int adv7533_bridge_attach(struct drm_bridge *bridge)
-{
- struct adv7511 *adv = bridge_to_adv7511(bridge);
- int ret;
-
- adv->encoder = bridge->encoder;
-
- if (!bridge->encoder) {
- DRM_ERROR("Parent encoder object not found");
- return -ENODEV;
- }
-
-#if HPD_ENABLE
- adv->connector.polled = DRM_CONNECTOR_POLL_HPD;
-#endif
-
- ret = drm_connector_init(bridge->dev, &adv->connector,
- &adv7533_connector_funcs, DRM_MODE_CONNECTOR_HDMIA);
- if (ret) {
- DRM_ERROR("Failed to initialize connector with drm\n");
- return ret;
- }
- drm_connector_helper_add(&adv->connector,
- &adv7533_connector_helper_funcs);
- drm_mode_connector_attach_encoder(&adv->connector, adv->encoder);
-
-#if HPD_ENABLE
- drm_helper_hpd_irq_event(adv->connector.dev);
-#endif
-
- adv7533_attach_dsi(adv);
-
- return ret;
-}
-
-static struct drm_bridge_funcs adv7533_bridge_funcs = {
- .pre_enable = adv7533_bridge_pre_enable,
- .enable = adv7533_bridge_enable,
- .disable = adv7533_bridge_disable,
- .post_disable = adv7533_bridge_post_disable,
- .mode_set = adv7533_bridge_mode_set,
- .attach = adv7533_bridge_attach,
-};
-
-/* =========================================================*/
-static int adv7533_init_regulators(struct adv7511 *adv75xx, struct device *dev)
-{
- int ret;
-
- adv75xx->vdd = devm_regulator_get(dev, "vdd");
- if (IS_ERR(adv75xx->vdd)) {
- ret = PTR_ERR(adv75xx->vdd);
- dev_err(dev, "failed to get vdd regulator %d\n", ret);
- return ret;
- }
-
- adv75xx->v1p2 = devm_regulator_get(dev, "v1p2");
- if (IS_ERR(adv75xx->v1p2)) {
- ret = PTR_ERR(adv75xx->v1p2);
- dev_err(dev, "failed to get v1p2 regulator %d\n", ret);
- return ret;
- }
-
- ret = regulator_set_voltage(adv75xx->vdd, 1800000, 1800000);
- if (ret) {
- dev_err(dev, "failed to set avdd voltage %d\n", ret);
- return ret;
- }
-
-
- DRM_INFO(" adv75xx->vdd = %d \n", regulator_get_voltage(adv75xx->vdd));
- /*ret = regulator_set_voltage(adv75xx->v1p2, 1200000, 1200000);
- if (ret) {
- dev_err(dev, "failed to set v1p2 voltage %d\n", ret);
- return ret;
- }*/
-
- /* keep the regulators always on */
- ret = regulator_enable(adv75xx->vdd);
- if (ret) {
- dev_err(dev, "failed to enable vdd %d\n", ret);
- return ret;
- }
-
- /*ret = regulator_enable(adv75xx->v1p2);
- if (ret) {
- dev_err(dev, "failed to enable v1p2 %d\n", ret);
- //return ret;
- }*/
-
- return 0;
-}
-
-/* -----------------------------------------------------------------------------
- * Probe & remove
- */
-
-static int adv7511_parse_dt(struct device_node *np,
- struct adv7511_link_config *config)
-{
- const char *str;
- int ret;
-
- of_property_read_u32(np, "adi,input-depth", &config->input_color_depth);
- if (config->input_color_depth != 8 && config->input_color_depth != 10 &&
- config->input_color_depth != 12)
- return -EINVAL;
-
- ret = of_property_read_string(np, "adi,input-colorspace", &str);
- if (ret < 0)
- return ret;
-
- if (!strcmp(str, "rgb"))
- config->input_colorspace = HDMI_COLORSPACE_RGB;
- else if (!strcmp(str, "yuv422"))
- config->input_colorspace = HDMI_COLORSPACE_YUV422;
- else if (!strcmp(str, "yuv444"))
- config->input_colorspace = HDMI_COLORSPACE_YUV444;
- else
- return -EINVAL;
-
- ret = of_property_read_string(np, "adi,input-clock", &str);
- if (ret < 0)
- return ret;
-
- if (!strcmp(str, "1x"))
- config->input_clock = ADV7511_INPUT_CLOCK_1X;
- else if (!strcmp(str, "2x"))
- config->input_clock = ADV7511_INPUT_CLOCK_2X;
- else if (!strcmp(str, "ddr"))
- config->input_clock = ADV7511_INPUT_CLOCK_DDR;
- else
- return -EINVAL;
-
- if (config->input_colorspace == HDMI_COLORSPACE_YUV422 ||
- config->input_clock != ADV7511_INPUT_CLOCK_1X) {
- ret = of_property_read_u32(np, "adi,input-style",
- &config->input_style);
- if (ret)
- return ret;
-
- if (config->input_style < 1 || config->input_style > 3)
- return -EINVAL;
-
- ret = of_property_read_string(np, "adi,input-justification",
- &str);
- if (ret < 0)
- return ret;
-
- if (!strcmp(str, "left"))
- config->input_justification =
- ADV7511_INPUT_JUSTIFICATION_LEFT;
- else if (!strcmp(str, "evenly"))
- config->input_justification =
- ADV7511_INPUT_JUSTIFICATION_EVENLY;
- else if (!strcmp(str, "right"))
- config->input_justification =
- ADV7511_INPUT_JUSTIFICATION_RIGHT;
- else
- return -EINVAL;
-
- } else {
- config->input_style = 1;
- config->input_justification = ADV7511_INPUT_JUSTIFICATION_LEFT;
- }
-
- of_property_read_u32(np, "adi,clock-delay", &config->clock_delay);
- if (config->clock_delay < -1200 || config->clock_delay > 1600)
- return -EINVAL;
-
- config->embedded_sync = of_property_read_bool(np, "adi,embedded-sync");
-
- /* Hardcode the sync pulse configurations for now. */
- config->sync_pulse = ADV7511_INPUT_SYNC_PULSE_NONE;
- config->vsync_polarity = ADV7511_SYNC_POLARITY_PASSTHROUGH;
- config->hsync_polarity = ADV7511_SYNC_POLARITY_PASSTHROUGH;
-
- return 0;
-}
-
-static int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv7511)
-{
- u32 num_lanes;
- struct device_node *endpoint;
-
- of_property_read_u32(np, "adi,dsi-lanes", &num_lanes);
-
- if (num_lanes < 1 || num_lanes > 4)
- return -EINVAL;
-
- adv7511->num_dsi_lanes = num_lanes;
-
- endpoint = of_graph_get_next_endpoint(np, NULL);
- if (!endpoint) {
- DRM_ERROR("adv dsi input endpoint not found\n");
- return -ENODEV;
- }
-
- adv7511->host_node = of_graph_get_remote_port_parent(endpoint);
- if (!adv7511->host_node) {
- DRM_ERROR("dsi host node not found\n");
- of_node_put(endpoint);
- return -ENODEV;
- }
-
- of_node_put(endpoint);
- of_node_put(adv7511->host_node);
-
- /* TODO: Check if these need to be parsed by DT or not */
- adv7511->rgb = true;
- adv7511->embedded_sync = false;
-
- return 0;
-}
-
-static const int edid_i2c_addr = 0x7e;
-static const int packet_i2c_addr = 0x70;
-static const int cec_i2c_addr = 0x78;
-
-static const struct of_device_id adv7511_of_ids[] = {
- { .compatible = "adi,adv7511", .data = (void *) ADV7511 },
- { .compatible = "adi,adv7511w", .data = (void *) ADV7511 },
- { .compatible = "adi,adv7513", .data = (void *) ADV7511 },
- { .compatible = "adi,adv7533", .data = (void *) ADV7533 },
- { }
-};
-MODULE_DEVICE_TABLE(of, adv7511_of_ids);
-
-static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
-{
- struct adv7511_link_config link_config;
- struct adv7511 *adv7511;
- struct device *dev = &i2c->dev;
- unsigned int val;
- int ret;
-
- if (!dev->of_node)
- return -EINVAL;
-
- adv7511 = devm_kzalloc(dev, sizeof(*adv7511), GFP_KERNEL);
- if (!adv7511)
- return -ENOMEM;
-
- adv7511->powered = false;
- adv7511->status = connector_status_disconnected;
-
- if (dev->of_node) {
- const struct of_device_id *of_id;
-
- of_id = of_match_node(adv7511_of_ids, dev->of_node);
- adv7511->type = (enum adv7511_type) of_id->data;
- } else {
- adv7511->type = id->driver_data;
- }
-
- DRM_INFO("adv match_node ok \n");
- memset(&link_config, 0, sizeof(link_config));
-
- if (adv7511->type == ADV7511)
- ret = adv7511_parse_dt(dev->of_node, &link_config);
- else
- ret = adv7533_parse_dt(dev->of_node, adv7511);
- if (ret)
- return ret;
-
- DRM_INFO("adv parse_dt ok , adv7511->type = %d <0--ADV7511, 1--ADV7533>\n", adv7511->type);
-
- if (adv7511->type == ADV7533) {
- ret = adv7533_init_regulators(adv7511, dev); // adv7533 vdd--1.8v v1p2--1.2v
- if (ret)
- return ret;
- }
- DRM_INFO("adv7533_init_regulators ok \n");
- /*
- * The power down GPIO is optional. If present, toggle it from active to
- * inactive to wake up the encoder.
- */
- adv7511->gpio_pd = devm_gpiod_get_optional(dev, "pd", GPIOD_OUT_HIGH);
- if (IS_ERR(adv7511->gpio_pd))
- return PTR_ERR(adv7511->gpio_pd);
-
- if (adv7511->gpio_pd) {
- mdelay(5);
- gpiod_set_value_cansleep(adv7511->gpio_pd, 0);
- }
-
- DRM_INFO("adv get gpio_pd ok \n");
-
- adv7511->regmap = devm_regmap_init_i2c(i2c, &adv7511_regmap_config);
- if (IS_ERR(adv7511->regmap))
- return PTR_ERR(adv7511->regmap);
-
- DRM_INFO("adv devm_regmap_init_i2c ok \n");
- ret = regmap_read(adv7511->regmap, ADV7511_REG_CHIP_REVISION, &val);
- if (ret)
- return ret;
- dev_dbg(dev, "Rev. %d\n", val);
- DRM_INFO("regmap_read ok, regmap_read Rev.= %d \n", val);
-
- if (adv7511->type == ADV7511) {
- ret = regmap_register_patch(adv7511->regmap,
- adv7511_fixed_registers,
- ARRAY_SIZE(adv7511_fixed_registers));
- if (ret)
- return ret;
- } else {
- ret = regmap_register_patch(adv7511->regmap,
- adv7533_fixed_registers,
- ARRAY_SIZE(adv7533_fixed_registers));
- if (ret)
- return ret;
- }
-
- regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, edid_i2c_addr);
- regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR,
- packet_i2c_addr);
- regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, cec_i2c_addr);
- adv7511_packet_disable(adv7511, 0xffff);
-
- adv7511->i2c_main = i2c;
-
- adv7511->i2c_packet = i2c_new_dummy(i2c->adapter, packet_i2c_addr >> 1);
- if (!adv7511->i2c_packet)
- return -ENOMEM;
-
- adv7511->i2c_edid = i2c_new_dummy(i2c->adapter, edid_i2c_addr >> 1);
- if (!adv7511->i2c_edid)
- goto err_i2c_unregister_packet;
-
- adv7511->i2c_cec = i2c_new_dummy(i2c->adapter, cec_i2c_addr >> 1);
- if (!adv7511->i2c_cec) {
- ret = -ENOMEM;
- goto err_i2c_unregister_edid;
- }
-
- adv7511->regmap_cec = devm_regmap_init_i2c(adv7511->i2c_cec,
- &adv7533_cec_regmap_config);
- if (IS_ERR(adv7511->regmap_cec)) {
- ret = PTR_ERR(adv7511->regmap_cec);
- goto err_i2c_unregister_cec;
- }
-
- adv7511->regmap_packet = devm_regmap_init_i2c(adv7511->i2c_packet,
- &adv7533_packet_regmap_config);
- if (IS_ERR(adv7511->regmap_packet)) {
- ret = PTR_ERR(adv7511->regmap_packet);
- goto err_i2c_unregister_cec;
- }
-
- if (adv7511->type == ADV7533) {
- ret = regmap_register_patch(adv7511->regmap_cec,
- adv7533_cec_fixed_registers,
- ARRAY_SIZE(adv7533_cec_fixed_registers));
- if (ret)
- return ret;
- }
-
- if (i2c->irq) {
- init_waitqueue_head(&adv7511->wq);
-
- ret = devm_request_threaded_irq(dev, i2c->irq, NULL,
- adv7511_irq_handler,
- IRQF_ONESHOT, dev_name(dev),
- adv7511);
- if (ret)
- goto err_i2c_unregister_cec;
- }
-
- /* CEC is unused for now */
- regmap_write(adv7511->regmap, ADV7511_REG_CEC_CTRL,
- ADV7511_CEC_CTRL_POWER_DOWN);
-
- adv7511_power_off(adv7511);
-
- i2c_set_clientdata(i2c, adv7511);
-
- if (adv7511->type == ADV7511)
- adv7511_set_link_config(adv7511, &link_config);
-
- if (adv7511->type == ADV7533) {
- adv7511->bridge.funcs = &adv7533_bridge_funcs;
- adv7511->bridge.of_node = dev->of_node;
-
- ret = drm_bridge_add(&adv7511->bridge);
- if (ret) {
- dev_err(dev, "failed to add adv7533 bridge\n");
- goto err_i2c_unregister_cec;
- }
- }
-#ifdef CONFIG_HDMI_ADV7511_AUDIO
- adv7511_audio_init(dev);
-#endif
- return 0;
-
-err_i2c_unregister_cec:
- i2c_unregister_device(adv7511->i2c_cec);
-err_i2c_unregister_edid:
- i2c_unregister_device(adv7511->i2c_edid);
-err_i2c_unregister_packet:
- i2c_unregister_device(adv7511->i2c_packet);
-
- return ret;
-}
-
-static int adv7511_remove(struct i2c_client *i2c)
-{
- struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
-
- //adv7511_audio_exit(&i2c->dev);
- i2c_unregister_device(adv7511->i2c_cec);
- i2c_unregister_device(adv7511->i2c_edid);
-
- kfree(adv7511->edid);
-
- if (adv7511->type == ADV7533) {
- mipi_dsi_detach(adv7511->dsi);
- //mipi_dsi_unregister_device(adv7511->dsi);
- drm_bridge_remove(&adv7511->bridge);
- }
-
- return 0;
-}
-
-static int adv7511_encoder_init(struct i2c_client *i2c, struct drm_device *dev,
- struct drm_encoder_slave *encoder)
-{
-
- struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
-
- if (adv7511->type == ADV7533)
- return -ENODEV;
-
- encoder->slave_priv = adv7511;
- encoder->slave_funcs = &adv7511_encoder_funcs;
-
- adv7511->encoder = &encoder->base;
-
- return 0;
-}
-
-static const struct i2c_device_id adv7511_i2c_ids[] = {
- { "adv7511", ADV7511 },
- { "adv7511w", ADV7511 },
- { "adv7513", ADV7511 },
- { "adv7533", ADV7533 },
- { }
-};
-MODULE_DEVICE_TABLE(i2c, adv7511_i2c_ids);
-
-static struct drm_i2c_encoder_driver adv7511_driver = {
- .i2c_driver = {
- .driver = {
- .name = "adv7511",
- .of_match_table = adv7511_of_ids,
- },
- .id_table = adv7511_i2c_ids,
- .probe = adv7511_probe,
- .remove = adv7511_remove,
- },
-
- .encoder_init = adv7511_encoder_init,
-};
-
-static int __init adv7511_init(void)
-{
- return drm_i2c_encoder_register(THIS_MODULE, &adv7511_driver);
-}
-module_init(adv7511_init);
-
-static void __exit adv7511_exit(void)
-{
- drm_i2c_encoder_unregister(&adv7511_driver);
-}
-module_exit(adv7511_exit);
-
-MODULE_AUTHOR("Lars-Peter Clausen <lars@...afoo.de>");
-MODULE_DESCRIPTION("ADV7511 HDMI transmitter driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/hikey9xx/gpu/hdmi/adv7535.h b/drivers/staging/hikey9xx/gpu/hdmi/adv7535.h
deleted file mode 100644
index b37748c065a7..000000000000
--- a/drivers/staging/hikey9xx/gpu/hdmi/adv7535.h
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Analog Devices ADV7511 HDMI transmitter driver
- *
- * Copyright 2012 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#ifndef __DRM_I2C_ADV7511_H__
-#define __DRM_I2C_ADV7511_H__
-
-#include <linux/hdmi.h>
-#include <drm/drm_crtc_helper.h>
-
-struct regmap;
-struct adv7511;
-
-int adv7511_packet_enable(struct adv7511 *adv7511, unsigned int packet);
-int adv7511_packet_disable(struct adv7511 *adv7511, unsigned int packet);
-
-int adv7511_audio_init(struct device *dev);
-void adv7511_audio_exit(struct device *dev);
-
-#define ADV7511_REG_CHIP_REVISION 0x00
-#define ADV7511_REG_N0 0x01
-#define ADV7511_REG_N1 0x02
-#define ADV7511_REG_N2 0x03
-#define ADV7511_REG_SPDIF_FREQ 0x04
-#define ADV7511_REG_CTS_AUTOMATIC1 0x05
-#define ADV7511_REG_CTS_AUTOMATIC2 0x06
-#define ADV7511_REG_CTS_MANUAL0 0x07
-#define ADV7511_REG_CTS_MANUAL1 0x08
-#define ADV7511_REG_CTS_MANUAL2 0x09
-#define ADV7511_REG_AUDIO_SOURCE 0x0a
-#define ADV7511_REG_AUDIO_CONFIG 0x0b
-#define ADV7511_REG_I2S_CONFIG 0x0c
-#define ADV7511_REG_I2S_WIDTH 0x0d
-#define ADV7511_REG_AUDIO_SUB_SRC0 0x0e
-#define ADV7511_REG_AUDIO_SUB_SRC1 0x0f
-#define ADV7511_REG_AUDIO_SUB_SRC2 0x10
-#define ADV7511_REG_AUDIO_SUB_SRC3 0x11
-#define ADV7511_REG_AUDIO_CFG1 0x12
-#define ADV7511_REG_AUDIO_CFG2 0x13
-#define ADV7511_REG_AUDIO_CFG3 0x14
-#define ADV7511_REG_I2C_FREQ_ID_CFG 0x15
-#define ADV7511_REG_VIDEO_INPUT_CFG1 0x16
-#define ADV7511_REG_CSC_UPPER(x) (0x18 + (x) * 2)
-#define ADV7511_REG_CSC_LOWER(x) (0x19 + (x) * 2)
-#define ADV7511_REG_SYNC_DECODER(x) (0x30 + (x))
-#define ADV7511_REG_DE_GENERATOR (0x35 + (x))
-#define ADV7511_REG_PIXEL_REPETITION 0x3b
-#define ADV7511_REG_VIC_MANUAL 0x3c
-#define ADV7511_REG_VIC_SEND 0x3d
-#define ADV7511_REG_VIC_DETECTED 0x3e
-#define ADV7511_REG_AUX_VIC_DETECTED 0x3f
-#define ADV7511_REG_PACKET_ENABLE0 0x40
-#define ADV7511_REG_POWER 0x41
-#define ADV7511_REG_STATUS 0x42
-#define ADV7511_REG_EDID_I2C_ADDR 0x43
-#define ADV7511_REG_PACKET_ENABLE1 0x44
-#define ADV7511_REG_PACKET_I2C_ADDR 0x45
-#define ADV7511_REG_DSD_ENABLE 0x46
-#define ADV7511_REG_VIDEO_INPUT_CFG2 0x48
-#define ADV7511_REG_INFOFRAME_UPDATE 0x4a
-#define ADV7511_REG_GC(x) (0x4b + (x)) /* 0x4b - 0x51 */
-#define ADV7511_REG_AVI_INFOFRAME_VERSION 0x52
-#define ADV7511_REG_AVI_INFOFRAME_LENGTH 0x53
-#define ADV7511_REG_AVI_INFOFRAME_CHECKSUM 0x54
-#define ADV7511_REG_AVI_INFOFRAME(x) (0x55 + (x)) /* 0x55 - 0x6f */
-#define ADV7511_REG_AUDIO_INFOFRAME_VERSION 0x70
-#define ADV7511_REG_AUDIO_INFOFRAME_LENGTH 0x71
-#define ADV7511_REG_AUDIO_INFOFRAME_CHECKSUM 0x72
-#define ADV7511_REG_AUDIO_INFOFRAME(x) (0x73 + (x)) /* 0x73 - 0x7c */
-#define ADV7511_REG_INT_ENABLE(x) (0x94 + (x))
-#define ADV7511_REG_INT(x) (0x96 + (x))
-#define ADV7511_REG_INPUT_CLK_DIV 0x9d
-#define ADV7511_REG_PLL_STATUS 0x9e
-#define ADV7511_REG_HDMI_POWER 0xa1
-#define ADV7511_REG_HDCP_HDMI_CFG 0xaf
-#define ADV7511_REG_AN(x) (0xb0 + (x)) /* 0xb0 - 0xb7 */
-#define ADV7511_REG_HDCP_STATUS 0xb8
-#define ADV7511_REG_BCAPS 0xbe
-#define ADV7511_REG_BKSV(x) (0xc0 + (x)) /* 0xc0 - 0xc3 */
-#define ADV7511_REG_EDID_SEGMENT 0xc4
-#define ADV7511_REG_DDC_STATUS 0xc8
-#define ADV7511_REG_EDID_READ_CTRL 0xc9
-#define ADV7511_REG_BSTATUS(x) (0xca + (x)) /* 0xca - 0xcb */
-#define ADV7511_REG_TIMING_GEN_SEQ 0xd0
-#define ADV7511_REG_POWER2 0xd6
-#define ADV7511_REG_HSYNC_PLACEMENT_MSB 0xfa
-
-#define ADV7511_REG_SYNC_ADJUSTMENT(x) (0xd7 + (x)) /* 0xd7 - 0xdc */
-#define ADV7511_REG_TMDS_CLOCK_INV 0xde
-#define ADV7511_REG_ARC_CTRL 0xdf
-#define ADV7511_REG_CEC_I2C_ADDR 0xe1
-#define ADV7511_REG_CEC_CTRL 0xe2
-#define ADV7511_REG_CHIP_ID_HIGH 0xf5
-#define ADV7511_REG_CHIP_ID_LOW 0xf6
-
-#define ADV7511_CSC_ENABLE BIT(7)
-#define ADV7511_CSC_UPDATE_MODE BIT(5)
-
-#define ADV7511_INT0_HDP BIT(7)
-#define ADV7511_INT0_VSYNC BIT(5)
-#define ADV7511_INT0_AUDIO_FIFO_FULL BIT(4)
-#define ADV7511_INT0_EDID_READY BIT(2)
-#define ADV7511_INT0_HDCP_AUTHENTICATED BIT(1)
-
-#define ADV7511_INT1_DDC_ERROR BIT(7)
-#define ADV7511_INT1_BKSV BIT(6)
-#define ADV7511_INT1_CEC_TX_READY BIT(5)
-#define ADV7511_INT1_CEC_TX_ARBIT_LOST BIT(4)
-#define ADV7511_INT1_CEC_TX_RETRY_TIMEOUT BIT(3)
-#define ADV7511_INT1_CEC_RX_READY3 BIT(2)
-#define ADV7511_INT1_CEC_RX_READY2 BIT(1)
-#define ADV7511_INT1_CEC_RX_READY1 BIT(0)
-
-#define ADV7511_ARC_CTRL_POWER_DOWN BIT(0)
-
-#define ADV7511_CEC_CTRL_POWER_DOWN BIT(0)
-
-#define ADV7511_POWER_POWER_DOWN BIT(6)
-
-#define ADV7511_HDMI_CFG_MODE_MASK 0x2
-#define ADV7511_HDMI_CFG_MODE_DVI 0x0
-#define ADV7511_HDMI_CFG_MODE_HDMI 0x2
-
-#define ADV7511_AUDIO_SELECT_I2C 0x0
-#define ADV7511_AUDIO_SELECT_SPDIF 0x1
-#define ADV7511_AUDIO_SELECT_DSD 0x2
-#define ADV7511_AUDIO_SELECT_HBR 0x3
-#define ADV7511_AUDIO_SELECT_DST 0x4
-
-#define ADV7511_I2S_SAMPLE_LEN_16 0x2
-#define ADV7511_I2S_SAMPLE_LEN_20 0x3
-#define ADV7511_I2S_SAMPLE_LEN_18 0x4
-#define ADV7511_I2S_SAMPLE_LEN_22 0x5
-#define ADV7511_I2S_SAMPLE_LEN_19 0x8
-#define ADV7511_I2S_SAMPLE_LEN_23 0x9
-#define ADV7511_I2S_SAMPLE_LEN_24 0xb
-#define ADV7511_I2S_SAMPLE_LEN_17 0xc
-#define ADV7511_I2S_SAMPLE_LEN_21 0xd
-
-#define ADV7511_SAMPLE_FREQ_44100 0x0
-#define ADV7511_SAMPLE_FREQ_48000 0x2
-#define ADV7511_SAMPLE_FREQ_32000 0x3
-#define ADV7511_SAMPLE_FREQ_88200 0x8
-#define ADV7511_SAMPLE_FREQ_96000 0xa
-#define ADV7511_SAMPLE_FREQ_176400 0xc
-#define ADV7511_SAMPLE_FREQ_192000 0xe
-
-#define ADV7511_STATUS_POWER_DOWN_POLARITY BIT(7)
-#define ADV7511_STATUS_HPD BIT(6)
-#define ADV7511_STATUS_MONITOR_SENSE BIT(5)
-#define ADV7511_STATUS_I2S_32BIT_MODE BIT(3)
-
-#define ADV7511_PACKET_ENABLE_N_CTS BIT(8+6)
-#define ADV7511_PACKET_ENABLE_AUDIO_SAMPLE BIT(8+5)
-#define ADV7511_PACKET_ENABLE_AVI_INFOFRAME BIT(8+4)
-#define ADV7511_PACKET_ENABLE_AUDIO_INFOFRAME BIT(8+3)
-#define ADV7511_PACKET_ENABLE_GC BIT(7)
-#define ADV7511_PACKET_ENABLE_SPD BIT(6)
-#define ADV7511_PACKET_ENABLE_MPEG BIT(5)
-#define ADV7511_PACKET_ENABLE_ACP BIT(4)
-#define ADV7511_PACKET_ENABLE_ISRC BIT(3)
-#define ADV7511_PACKET_ENABLE_GM BIT(2)
-#define ADV7511_PACKET_ENABLE_SPARE2 BIT(1)
-#define ADV7511_PACKET_ENABLE_SPARE1 BIT(0)
-
-#define ADV7511_REG_POWER2_HDP_SRC_MASK 0xc0
-#define ADV7511_REG_POWER2_HDP_SRC_BOTH 0x00
-#define ADV7511_REG_POWER2_HDP_SRC_HDP 0x40
-#define ADV7511_REG_POWER2_HDP_SRC_CEC 0x80
-#define ADV7511_REG_POWER2_HDP_SRC_NONE 0xc0
-#define ADV7511_REG_POWER2_TDMS_ENABLE BIT(4)
-#define ADV7511_REG_POWER2_GATE_INPUT_CLK BIT(0)
-
-#define ADV7511_LOW_REFRESH_RATE_NONE 0x0
-#define ADV7511_LOW_REFRESH_RATE_24HZ 0x1
-#define ADV7511_LOW_REFRESH_RATE_25HZ 0x2
-#define ADV7511_LOW_REFRESH_RATE_30HZ 0x3
-
-#define ADV7511_AUDIO_CFG3_LEN_MASK 0x0f
-#define ADV7511_I2C_FREQ_ID_CFG_RATE_MASK 0xf0
-
-#define ADV7511_AUDIO_SOURCE_I2S 0
-#define ADV7511_AUDIO_SOURCE_SPDIF 1
-
-#define ADV7511_I2S_FORMAT_I2S 0
-#define ADV7511_I2S_FORMAT_RIGHT_J 1
-#define ADV7511_I2S_FORMAT_LEFT_J 2
-
-#define ADV7511_PACKET(p, x) ((p) * 0x20 + (x))
-#define ADV7511_PACKET_SDP(x) ADV7511_PACKET(0, x)
-#define ADV7511_PACKET_MPEG(x) ADV7511_PACKET(1, x)
-#define ADV7511_PACKET_ACP(x) ADV7511_PACKET(2, x)
-#define ADV7511_PACKET_ISRC1(x) ADV7511_PACKET(3, x)
-#define ADV7511_PACKET_ISRC2(x) ADV7511_PACKET(4, x)
-#define ADV7511_PACKET_GM(x) ADV7511_PACKET(5, x)
-#define ADV7511_PACKET_SPARE(x) ADV7511_PACKET(6, x)
-
-enum adv7511_input_clock {
- ADV7511_INPUT_CLOCK_1X,
- ADV7511_INPUT_CLOCK_2X,
- ADV7511_INPUT_CLOCK_DDR,
-};
-
-enum adv7511_input_justification {
- ADV7511_INPUT_JUSTIFICATION_EVENLY = 0,
- ADV7511_INPUT_JUSTIFICATION_RIGHT = 1,
- ADV7511_INPUT_JUSTIFICATION_LEFT = 2,
-};
-
-enum adv7511_input_sync_pulse {
- ADV7511_INPUT_SYNC_PULSE_DE = 0,
- ADV7511_INPUT_SYNC_PULSE_HSYNC = 1,
- ADV7511_INPUT_SYNC_PULSE_VSYNC = 2,
- ADV7511_INPUT_SYNC_PULSE_NONE = 3,
-};
-
-/**
- * enum adv7511_sync_polarity - Polarity for the input sync signals
- * @ADV7511_SYNC_POLARITY_PASSTHROUGH: Sync polarity matches that of
- * the currently configured mode.
- * @ADV7511_SYNC_POLARITY_LOW: Sync polarity is low
- * @ADV7511_SYNC_POLARITY_HIGH: Sync polarity is high
- *
- * If the polarity is set to either LOW or HIGH the driver will configure the
- * ADV7511 to internally invert the sync signal if required to match the sync
- * polarity setting for the currently selected output mode.
- *
- * If the polarity is set to PASSTHROUGH, the ADV7511 will route the signal
- * unchanged. This is used when the upstream graphics core already generates
- * the sync signals with the correct polarity.
- */
-enum adv7511_sync_polarity {
- ADV7511_SYNC_POLARITY_PASSTHROUGH,
- ADV7511_SYNC_POLARITY_LOW,
- ADV7511_SYNC_POLARITY_HIGH,
-};
-
-enum adv7511_type {
- ADV7511,
- ADV7533,
-};
-
-struct adv7511 {
- struct i2c_client *i2c_main;
- struct i2c_client *i2c_edid;
- struct i2c_client *i2c_cec;
- struct i2c_client *i2c_packet;
-
- struct regmap *regmap;
- struct regmap *regmap_cec;
- struct regmap *regmap_packet;
- enum drm_connector_status status;
- bool powered;
- struct regulator *vdd;
- struct regulator *v1p2;
-
- struct drm_display_mode curr_mode;
-
- unsigned int f_tmds;
- unsigned int f_audio;
- unsigned int audio_source;
-
- unsigned int current_edid_segment;
- uint8_t edid_buf[256];
- bool edid_read;
-
- wait_queue_head_t wq;
- struct drm_encoder *encoder;
-
- struct drm_connector connector;
- struct drm_bridge bridge;
-
- bool embedded_sync;
- enum adv7511_sync_polarity vsync_polarity;
- enum adv7511_sync_polarity hsync_polarity;
- bool rgb;
-
- struct edid *edid;
-
- struct gpio_desc *gpio_pd;
-
- /* ADV7533 DSI RX related params */
- struct device_node *host_node;
- struct mipi_dsi_device *dsi;
- u8 num_dsi_lanes;
-
- enum adv7511_type type;
-};
-
-/**
- * struct adv7511_link_config - Describes adv7511 hardware configuration
- * @input_color_depth: Number of bits per color component (8, 10 or 12)
- * @input_colorspace: The input colorspace (RGB, YUV444, YUV422)
- * @input_clock: The input video clock style (1x, 2x, DDR)
- * @input_style: The input component arrangement variant
- * @input_justification: Video input format bit justification
- * @clock_delay: Clock delay for the input clock (in ps)
- * @embedded_sync: Video input uses BT.656-style embedded sync
- * @sync_pulse: Select the sync pulse
- * @vsync_polarity: vsync input signal configuration
- * @hsync_polarity: hsync input signal configuration
- */
-struct adv7511_link_config {
- unsigned int input_color_depth;
- enum hdmi_colorspace input_colorspace;
- enum adv7511_input_clock input_clock;
- unsigned int input_style;
- enum adv7511_input_justification input_justification;
-
- int clock_delay;
-
- bool embedded_sync;
- enum adv7511_input_sync_pulse sync_pulse;
- enum adv7511_sync_polarity vsync_polarity;
- enum adv7511_sync_polarity hsync_polarity;
-};
-
-/**
- * enum adv7511_csc_scaling - Scaling factor for the ADV7511 CSC
- * @ADV7511_CSC_SCALING_1: CSC results are not scaled
- * @ADV7511_CSC_SCALING_2: CSC results are scaled by a factor of two
- * @ADV7511_CSC_SCALING_4: CSC results are scalled by a factor of four
- */
-enum adv7511_csc_scaling {
- ADV7511_CSC_SCALING_1 = 0,
- ADV7511_CSC_SCALING_2 = 1,
- ADV7511_CSC_SCALING_4 = 2,
-};
-
-/**
- * struct adv7511_video_config - Describes adv7511 hardware configuration
- * @csc_enable: Whether to enable color space conversion
- * @csc_scaling_factor: Color space conversion scaling factor
- * @csc_coefficents: Color space conversion coefficents
- * @hdmi_mode: Whether to use HDMI or DVI output mode
- * @avi_infoframe: HDMI infoframe
- */
-struct adv7511_video_config {
- bool csc_enable;
- enum adv7511_csc_scaling csc_scaling_factor;
- const uint16_t *csc_coefficents;
-
- bool hdmi_mode;
- struct hdmi_avi_infoframe avi_infoframe;
-};
-
-#endif /* __DRM_I2C_ADV7511_H__ */
diff --git a/drivers/staging/hikey9xx/gpu/hdmi/adv7535_audio.c b/drivers/staging/hikey9xx/gpu/hdmi/adv7535_audio.c
deleted file mode 100644
index 8357ce5f53c6..000000000000
--- a/drivers/staging/hikey9xx/gpu/hdmi/adv7535_audio.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Analog Devices ADV7511 HDMI transmitter driver
- *
- * Copyright 2012 Analog Devices Inc.
- *
- * Licensed under the GPL-2.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/pm.h>
-#include <linux/i2c.h>
-#include <linux/spi/spi.h>
-#include <linux/slab.h>
-#include <sound/core.h>
-#include <sound/pcm.h>
-#include <sound/pcm_params.h>
-#include <sound/soc.h>
-#include <sound/initval.h>
-#include <sound/tlv.h>
-
-#include "adv7535.h"
-
-static const struct snd_soc_dapm_widget adv7511_dapm_widgets[] = {
- SND_SOC_DAPM_OUTPUT("TMDS"),
- SND_SOC_DAPM_AIF_IN("AIFIN", "Playback", 0, SND_SOC_NOPM, 0, 0),
-};
-
-static const struct snd_soc_dapm_route adv7511_routes[] = {
- { "TMDS", NULL, "AIFIN" },
-};
-
-static void adv7511_calc_cts_n(unsigned int f_tmds, unsigned int fs,
- unsigned int *cts, unsigned int *n)
-{
- switch (fs) {
- case 32000:
- *n = 4096;
- break;
- case 44100:
- *n = 6272;
- break;
- case 48000:
- *n = 6144;
- break;
- }
-
- *cts = ((f_tmds * *n) / (128 * fs)) * 1000;
-}
-
-static int adv7511_update_cts_n(struct adv7511 *adv7511)
-{
- unsigned int cts = 0;
- unsigned int n = 0;
-
- adv7511_calc_cts_n(adv7511->f_tmds, adv7511->f_audio, &cts, &n);
-
- regmap_write(adv7511->regmap, ADV7511_REG_N0, (n >> 16) & 0xf);
- regmap_write(adv7511->regmap, ADV7511_REG_N1, (n >> 8) & 0xff);
- regmap_write(adv7511->regmap, ADV7511_REG_N2, n & 0xff);
-
- regmap_write(adv7511->regmap, ADV7511_REG_CTS_MANUAL0,
- (cts >> 16) & 0xf);
- regmap_write(adv7511->regmap, ADV7511_REG_CTS_MANUAL1,
- (cts >> 8) & 0xff);
- regmap_write(adv7511->regmap, ADV7511_REG_CTS_MANUAL2,
- cts & 0xff);
-
- return 0;
-}
-
-static int adv7511_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params,
- struct snd_soc_dai *dai)
-{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_codec *codec = rtd->codec;
- struct adv7511 *adv7511 = snd_soc_codec_get_drvdata(codec);
- unsigned int rate;
- unsigned int len;
- switch (params_rate(params)) {
- case 32000:
- rate = ADV7511_SAMPLE_FREQ_32000;
- break;
- case 44100:
- rate = ADV7511_SAMPLE_FREQ_44100;
- break;
- case 48000:
- rate = ADV7511_SAMPLE_FREQ_48000;
- break;
- case 88200:
- rate = ADV7511_SAMPLE_FREQ_88200;
- break;
- case 96000:
- rate = ADV7511_SAMPLE_FREQ_96000;
- break;
- case 176400:
- rate = ADV7511_SAMPLE_FREQ_176400;
- break;
- case 192000:
- rate = ADV7511_SAMPLE_FREQ_192000;
- break;
- default:
- return -EINVAL;
- }
-
- switch (params_format(params)) {
- case SNDRV_PCM_FORMAT_S16_LE:
- len = ADV7511_I2S_SAMPLE_LEN_16;
- break;
- case SNDRV_PCM_FORMAT_S18_3LE:
- len = ADV7511_I2S_SAMPLE_LEN_18;
- break;
- case SNDRV_PCM_FORMAT_S20_3LE:
- len = ADV7511_I2S_SAMPLE_LEN_20;
- break;
- case SNDRV_PCM_FORMAT_S24_LE:
- len = ADV7511_I2S_SAMPLE_LEN_24;
- break;
- default:
- return -EINVAL;
- }
-
- adv7511->f_audio = params_rate(params);
-
- adv7511_update_cts_n(adv7511);
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_AUDIO_CFG3,
- ADV7511_AUDIO_CFG3_LEN_MASK, len);
- regmap_update_bits(adv7511->regmap, ADV7511_REG_I2C_FREQ_ID_CFG,
- ADV7511_I2C_FREQ_ID_CFG_RATE_MASK, rate << 4);
- regmap_write(adv7511->regmap, 0x73, 0x1);
-
- return 0;
-}
-
-static int adv7511_set_dai_fmt(struct snd_soc_dai *codec_dai,
- unsigned int fmt)
-{
- struct snd_soc_codec *codec = codec_dai->codec;
- struct adv7511 *adv7511 = snd_soc_codec_get_drvdata(codec);
- unsigned int audio_source, i2s_format = 0;
- unsigned int invert_clock;
-
- switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
- case SND_SOC_DAIFMT_I2S:
- audio_source = ADV7511_AUDIO_SOURCE_I2S;
- i2s_format = ADV7511_I2S_FORMAT_I2S;
- break;
- case SND_SOC_DAIFMT_RIGHT_J:
- audio_source = ADV7511_AUDIO_SOURCE_I2S;
- i2s_format = ADV7511_I2S_FORMAT_RIGHT_J;
- break;
- case SND_SOC_DAIFMT_LEFT_J:
- audio_source = ADV7511_AUDIO_SOURCE_I2S;
- i2s_format = ADV7511_I2S_FORMAT_LEFT_J;
- break;
-// case SND_SOC_DAIFMT_SPDIF:
-// audio_source = ADV7511_AUDIO_SOURCE_SPDIF;
-// break;
- default:
- return -EINVAL;
- }
-
- switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
- case SND_SOC_DAIFMT_CBS_CFS:
- break;
- default:
- return -EINVAL;
- }
-
- switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
- case SND_SOC_DAIFMT_NB_NF:
- invert_clock = 0;
- break;
- case SND_SOC_DAIFMT_IB_NF:
- invert_clock = 1;
- break;
- default:
- return -EINVAL;
- }
-
- regmap_update_bits(adv7511->regmap, ADV7511_REG_AUDIO_SOURCE, 0x70,
- audio_source << 4);
- regmap_update_bits(adv7511->regmap, ADV7511_REG_AUDIO_CONFIG, BIT(6),
- invert_clock << 6);
- regmap_update_bits(adv7511->regmap, ADV7511_REG_I2S_CONFIG, 0x03,
- i2s_format);
-
- adv7511->audio_source = audio_source;
-
- return 0;
-}
-
-static int adv7511_set_bias_level(struct snd_soc_codec *codec,
- enum snd_soc_bias_level level)
-{
- struct adv7511 *adv7511 = snd_soc_codec_get_drvdata(codec);
- struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
-
- switch (level) {
- case SND_SOC_BIAS_ON:
- switch (adv7511->audio_source) {
- case ADV7511_AUDIO_SOURCE_I2S:
- break;
- case ADV7511_AUDIO_SOURCE_SPDIF:
- regmap_update_bits(adv7511->regmap,
- ADV7511_REG_AUDIO_CONFIG, BIT(7),
- BIT(7));
- break;
- }
- break;
- case SND_SOC_BIAS_PREPARE:
- if (dapm->bias_level == SND_SOC_BIAS_STANDBY) {
- adv7511_packet_enable(adv7511,
- ADV7511_PACKET_ENABLE_AUDIO_SAMPLE);
- adv7511_packet_enable(adv7511,
- ADV7511_PACKET_ENABLE_AUDIO_INFOFRAME);
- adv7511_packet_enable(adv7511,
- ADV7511_PACKET_ENABLE_N_CTS);
- } else {
- adv7511_packet_disable(adv7511,
- ADV7511_PACKET_ENABLE_AUDIO_SAMPLE);
- adv7511_packet_disable(adv7511,
- ADV7511_PACKET_ENABLE_AUDIO_INFOFRAME);
- adv7511_packet_disable(adv7511,
- ADV7511_PACKET_ENABLE_N_CTS);
- }
- break;
- case SND_SOC_BIAS_STANDBY:
- regmap_update_bits(adv7511->regmap, ADV7511_REG_AUDIO_CONFIG,
- BIT(7), 0);
- break;
- case SND_SOC_BIAS_OFF:
- break;
- }
- dapm->bias_level = level;
- return 0;
-}
-
-#define ADV7511_RATES (SNDRV_PCM_RATE_32000 |\
- SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
- SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |\
- SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000)
-
-#define ADV7511_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE |\
- SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE)
-
-static const struct snd_soc_dai_ops adv7511_dai_ops = {
- .hw_params = adv7511_hw_params,
- /*.set_sysclk = adv7511_set_dai_sysclk,*/
- .set_fmt = adv7511_set_dai_fmt,
-};
-
-static struct snd_soc_dai_driver adv7511_dai = {
- .name = "adv7511",
- .playback = {
- .stream_name = "Playback",
- .channels_min = 2,
- .channels_max = 2,
- .rates = ADV7511_RATES,
- .formats = ADV7511_FORMATS,
- },
- .ops = &adv7511_dai_ops,
-};
-
-static int adv7511_suspend(struct snd_soc_codec *codec)
-{
- return adv7511_set_bias_level(codec, SND_SOC_BIAS_OFF);
-}
-
-static int adv7511_resume(struct snd_soc_codec *codec)
-{
- return adv7511_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-}
-
-static int adv7511_probe(struct snd_soc_codec *codec)
-{
- return adv7511_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
-}
-
-static int adv7511_remove(struct snd_soc_codec *codec)
-{
- adv7511_set_bias_level(codec, SND_SOC_BIAS_OFF);
- return 0;
-}
-
-static struct snd_soc_codec_driver adv7511_codec_driver = {
- .probe = adv7511_probe,
- .remove = adv7511_remove,
- .suspend = adv7511_suspend,
- .resume = adv7511_resume,
- .set_bias_level = adv7511_set_bias_level,
- .component_driver = {
- .dapm_widgets = adv7511_dapm_widgets,
- .num_dapm_widgets = ARRAY_SIZE(adv7511_dapm_widgets),
- .dapm_routes = adv7511_routes,
- .num_dapm_routes = ARRAY_SIZE(adv7511_routes),
- },
-};
-
-int adv7511_audio_init(struct device *dev)
-{
- return snd_soc_register_codec(dev, &adv7511_codec_driver,
- &adv7511_dai, 1);
-}
-
-void adv7511_audio_exit(struct device *dev)
-{
- snd_soc_unregister_codec(dev);
-}
--
2.26.2
Powered by blists - more mailing lists