Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/drivers/gpu/drm/mediatek/   (Linux Kernel Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 45 kB image not shown  

Quelle  mtk_hdmi.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014 MediaTek Inc.
 * Author: Jie Qiu <jie.qiu@mediatek.com>
 */


#include <linux/arm-smccc.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/hdmi.h>
#include <linux/i2c.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of_platform.h>
#include <linux/of.h>
#include <linux/of_graph.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

#include <sound/hdmi-codec.h>

#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_crtc.h>
#include <drm/drm_edid.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>

#include "mtk_cec.h"
#include "mtk_hdmi_regs.h"

#define NCTS_BYTES 7

enum mtk_hdmi_clk_id {
 MTK_HDMI_CLK_HDMI_PIXEL,
 MTK_HDMI_CLK_HDMI_PLL,
 MTK_HDMI_CLK_AUD_BCLK,
 MTK_HDMI_CLK_AUD_SPDIF,
 MTK_HDMI_CLK_COUNT
};

enum hdmi_aud_input_type {
 HDMI_AUD_INPUT_I2S = 0,
 HDMI_AUD_INPUT_SPDIF,
};

enum hdmi_aud_i2s_fmt {
 HDMI_I2S_MODE_RJT_24BIT = 0,
 HDMI_I2S_MODE_RJT_16BIT,
 HDMI_I2S_MODE_LJT_24BIT,
 HDMI_I2S_MODE_LJT_16BIT,
 HDMI_I2S_MODE_I2S_24BIT,
 HDMI_I2S_MODE_I2S_16BIT
};

enum hdmi_aud_mclk {
 HDMI_AUD_MCLK_128FS,
 HDMI_AUD_MCLK_192FS,
 HDMI_AUD_MCLK_256FS,
 HDMI_AUD_MCLK_384FS,
 HDMI_AUD_MCLK_512FS,
 HDMI_AUD_MCLK_768FS,
 HDMI_AUD_MCLK_1152FS,
};

enum hdmi_aud_channel_type {
 HDMI_AUD_CHAN_TYPE_1_0 = 0,
 HDMI_AUD_CHAN_TYPE_1_1,
 HDMI_AUD_CHAN_TYPE_2_0,
 HDMI_AUD_CHAN_TYPE_2_1,
 HDMI_AUD_CHAN_TYPE_3_0,
 HDMI_AUD_CHAN_TYPE_3_1,
 HDMI_AUD_CHAN_TYPE_4_0,
 HDMI_AUD_CHAN_TYPE_4_1,
 HDMI_AUD_CHAN_TYPE_5_0,
 HDMI_AUD_CHAN_TYPE_5_1,
 HDMI_AUD_CHAN_TYPE_6_0,
 HDMI_AUD_CHAN_TYPE_6_1,
 HDMI_AUD_CHAN_TYPE_7_0,
 HDMI_AUD_CHAN_TYPE_7_1,
 HDMI_AUD_CHAN_TYPE_3_0_LRS,
 HDMI_AUD_CHAN_TYPE_3_1_LRS,
 HDMI_AUD_CHAN_TYPE_4_0_CLRS,
 HDMI_AUD_CHAN_TYPE_4_1_CLRS,
 HDMI_AUD_CHAN_TYPE_6_1_CS,
 HDMI_AUD_CHAN_TYPE_6_1_CH,
 HDMI_AUD_CHAN_TYPE_6_1_OH,
 HDMI_AUD_CHAN_TYPE_6_1_CHR,
 HDMI_AUD_CHAN_TYPE_7_1_LH_RH,
 HDMI_AUD_CHAN_TYPE_7_1_LSR_RSR,
 HDMI_AUD_CHAN_TYPE_7_1_LC_RC,
 HDMI_AUD_CHAN_TYPE_7_1_LW_RW,
 HDMI_AUD_CHAN_TYPE_7_1_LSD_RSD,
 HDMI_AUD_CHAN_TYPE_7_1_LSS_RSS,
 HDMI_AUD_CHAN_TYPE_7_1_LHS_RHS,
 HDMI_AUD_CHAN_TYPE_7_1_CS_CH,
 HDMI_AUD_CHAN_TYPE_7_1_CS_OH,
 HDMI_AUD_CHAN_TYPE_7_1_CS_CHR,
 HDMI_AUD_CHAN_TYPE_7_1_CH_OH,
 HDMI_AUD_CHAN_TYPE_7_1_CH_CHR,
 HDMI_AUD_CHAN_TYPE_7_1_OH_CHR,
 HDMI_AUD_CHAN_TYPE_7_1_LSS_RSS_LSR_RSR,
 HDMI_AUD_CHAN_TYPE_6_0_CS,
 HDMI_AUD_CHAN_TYPE_6_0_CH,
 HDMI_AUD_CHAN_TYPE_6_0_OH,
 HDMI_AUD_CHAN_TYPE_6_0_CHR,
 HDMI_AUD_CHAN_TYPE_7_0_LH_RH,
 HDMI_AUD_CHAN_TYPE_7_0_LSR_RSR,
 HDMI_AUD_CHAN_TYPE_7_0_LC_RC,
 HDMI_AUD_CHAN_TYPE_7_0_LW_RW,
 HDMI_AUD_CHAN_TYPE_7_0_LSD_RSD,
 HDMI_AUD_CHAN_TYPE_7_0_LSS_RSS,
 HDMI_AUD_CHAN_TYPE_7_0_LHS_RHS,
 HDMI_AUD_CHAN_TYPE_7_0_CS_CH,
 HDMI_AUD_CHAN_TYPE_7_0_CS_OH,
 HDMI_AUD_CHAN_TYPE_7_0_CS_CHR,
 HDMI_AUD_CHAN_TYPE_7_0_CH_OH,
 HDMI_AUD_CHAN_TYPE_7_0_CH_CHR,
 HDMI_AUD_CHAN_TYPE_7_0_OH_CHR,
 HDMI_AUD_CHAN_TYPE_7_0_LSS_RSS_LSR_RSR,
 HDMI_AUD_CHAN_TYPE_8_0_LH_RH_CS,
 HDMI_AUD_CHAN_TYPE_UNKNOWN = 0xFF
};

enum hdmi_aud_channel_swap_type {
 HDMI_AUD_SWAP_LR,
 HDMI_AUD_SWAP_LFE_CC,
 HDMI_AUD_SWAP_LSRS,
 HDMI_AUD_SWAP_RLS_RRS,
 HDMI_AUD_SWAP_LR_STATUS,
};

struct hdmi_audio_param {
 enum hdmi_audio_coding_type aud_codec;
 enum hdmi_audio_sample_size aud_sample_size;
 enum hdmi_aud_input_type aud_input_type;
 enum hdmi_aud_i2s_fmt aud_i2s_fmt;
 enum hdmi_aud_mclk aud_mclk;
 enum hdmi_aud_channel_type aud_input_chan_type;
 struct hdmi_codec_params codec_params;
};

struct mtk_hdmi_conf {
 bool tz_disabled;
 bool cea_modes_only;
 unsigned long max_mode_clock;
};

struct mtk_hdmi {
 struct drm_bridge bridge;
 struct drm_bridge *next_bridge;
 struct drm_connector *curr_conn;/* current connector (only valid when 'enabled') */
 struct device *dev;
 const struct mtk_hdmi_conf *conf;
 struct phy *phy;
 struct device *cec_dev;
 struct i2c_adapter *ddc_adpt;
 struct clk *clk[MTK_HDMI_CLK_COUNT];
 struct drm_display_mode mode;
 bool dvi_mode;
 struct regmap *sys_regmap;
 unsigned int sys_offset;
 struct regmap *regs;
 struct platform_device *audio_pdev;
 struct hdmi_audio_param aud_param;
 bool audio_enable;
 bool powered;
 bool enabled;
 hdmi_codec_plugged_cb plugged_cb;
 struct device *codec_dev;
 struct mutex update_plugged_status_lock;
};

static inline struct mtk_hdmi *hdmi_ctx_from_bridge(struct drm_bridge *b)
{
 return container_of(b, struct mtk_hdmi, bridge);
}

static void mtk_hdmi_hw_vid_black(struct mtk_hdmi *hdmi, bool black)
{
 regmap_update_bits(hdmi->regs, VIDEO_CFG_4,
      VIDEO_SOURCE_SEL, black ? GEN_RGB : NORMAL_PATH);
}

static void mtk_hdmi_hw_make_reg_writable(struct mtk_hdmi *hdmi, bool enable)
{
 struct arm_smccc_res res;

 /*
  * MT8173 HDMI hardware has an output control bit to enable/disable HDMI
  * output. This bit can only be controlled in ARM supervisor mode.
  * The ARM trusted firmware provides an API for the HDMI driver to set
 enable HDMI in  .
 */

 include d/.java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
  regmap_update_bitshdmi->,
  -> + HDMI_SYS_CFG20
  , enable ? 0x80000005 : 0x8000);
 else
  arm_smccc_smc(MTK_SIP_SET_AUTHORIZED_SECURE_REG, 0x14000904,
         0x80000000, 0, 0, 0, 0, 0, &res);

 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
      HDMI_PCLK_FREE_RUN, enable ? HDMI_PCLK_FREE_RUN : 0);
 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
      HDMI_ON | ANLG_ON, enable ? (HDMI_ON | ANLG_ON) : 0);
}

static void mtk_hdmi_hw_1p4_version_enable(struct mtk_hdmi *hdmi, bool enable)
{
 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG20,
      HDMI2P0_EN, enable ? 0 : HDMI2P0_EN);
}

static void mtk_hdmi_hw_aud_mute(struct mtk_hdmi *hdmi)
{
 regmap_set_bits(hdmi->regs, GRL_AUDIO_CFG, AUDIO_ZERO);
}

static void mtk_hdmi_hw_aud_unmute(struct mtk_hdmi *hdmi)
{
 regmap_clear_bits(hdmi->regs, GRL_AUDIO_CFG, AUDIO_ZERO);
}

static void mtk_hdmi_hw_reset(struct mtk_hdmi *java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 23
{
 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
      HDMI_RSTHDMI_RST);
 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + HDMI_SYS_CFG1C,
      HDMI_RST, 0);
 ,
 (hdmi->,hdmi->sys_offset + HDMI_SYS_CFG1C,
      ANLG_ON, ANLG_ON);
}

staticI2S_MODE_I2S_24BIT
{
 java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 57
  enumhdmi_aud_channel_typejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Range [24, 1) out of bounds for length 1

static  mtk_hdmi_hw_write_int_mask(struct mtk_hdmi *hdmi, u32 int_mask)
{
 regmap_write(hdmi HDMI_AUD_CHAN_TYPE_7_1_LSS_RSS_LSR_RSR
}

static void mtk_hdmi_hw_enable_dvi_mode ,
{
 regmap_update_bits(hdmi->regs, GRL_CFG1,
}

static nfo_framestruct mtk_hdmi *  *buffer
     u8 len)
{
 u32 ctrl_regHDMI_AUD_CHAN_TYPE_7_0_L,
 ,
  ;
   frame_type
 u8;
 u8;
 u8 checksum;
 int ctrl_frame_en = 0;

 frame_type = *buffer++;
 frame_ver = * HDMI_AUD_CHAN_TYPE_8_0,
   *uffer+;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 HDMI_AUD_SWAP_LFE_CC,

 dev_dbg(hdmi->dev,
  "frame_type:0x%x, HDMI_AUD_SWAP_LSRS,
  frame_type, frame_ver, frame_len, checksum);

 switch (frame_type) {
 HDMI_AUD_SWAP_LR_STATUS
  java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
  ctrl_reg = GRL_CTRL;
  break;
 case HDMI_INFOFRAME_TYPE_SPD aud_sample_sizejava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
  ;
  ctrl_reg = GRL_CTRL;
  breakhdmi_aud_mclk ;
case :
  ctrl_frame_en = struct hdmi_codec_params codec_params;
 ctrl_reg = GRL_CTRL;
  break;
 case
  =VS_ENjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  ctrl_reg = GRL_ACP_ISRC_CTRL;
  break;
 default:
  dev_err(hdmi->dev, "Unknown infoframe type %d\n", frame_type);
  return long ;
 }
 regmap_clear_bits(hdmi->regs, ctrl_reg, ctrl_frame_en);
 regmap_writejava.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 26
_writehdmi>regs, , ;
regmap_writehdmi>regs GRL_INFOFRM_LNG);

 regmap_write(hdmi->regs, GRL_IFM_PORT structphy*;
fori = 0; < frame_len+)
  regmap_write(hdmi->regs, GRL_IFM_PORT, frame_data[i]);

 ->, ctrl_reg,ctrl_frame_en;
}

taticvoid mtk_hdmi_hw_send_aud_packet(structmtk_hdmi hdmibool enable
{
pdate_bits(dmi>regs,GRL_SHIFT_R2,
   AUDIO_PACKET_OFF  ?  );
}

voidmtk_hdmi_hw_config_sys( mtk_hdmi*hdmijava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
{
 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset 
     HDMI_OUT_FIFO_ENMHL_MODE_ON,)
 usleep_range(2000, 4000);
 (hdmi>ys_regmap hdmi->+HDMI_SYS_CFG20
      HDMI_OUT_FIFO_ENjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static void java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 1
{
 regmap_update_bits(hdmi->sys_regmap, hdmi->sys_offset + java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 1
      DEEP_COLOR_MODE_MASK |DEEP_COLOR_EN
      COLOR_8BIT_MODEjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static void mtk_hdmi_hw_send_av_mute(struct mtk_hdmi *hdmi)
{
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  /*
 java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 52
}

static void   * The ARM trusted firmware anAPI  the HDMI  java.lang.StringIndexOutOfBoundsException: Range [71, 72) out of bounds for length 71
{
 regmap_update_bits(hdmi->regs, GRL_CFG4, CFG4_AV_UNMUTE_EN | CFG4_AV_UNMUTE_SET,
      regmap_update_bitssys_regmap, hdmisys_offset ,
 usleep_range(2000, 4000);
 regmap_update_bits(hdmi>egs GRL_CFG4,CFG4_AV_UNMUTE_EN | CFG4_AV_UNMUTE_SET,
      CFG4_AV_UNMUTE_SET);
}

static void mtk_hdmi_hw_ncts_enable(struct mtk_hdmi *hdmi, bool on)
{
 regmap_clear_bits(>, RL_CFG3 );
     on  0  )java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}

static void java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
            bool enable)
{
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 1
NCTS_WRI_ANYTIME  )
}

static checksum
         struct java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
{
 regmap_clear_bitshdmi> )

 if (mode->flags & DRM_MODE_FLAG_INTERLACE &&
     mode-java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
    modevdisplay == 1080)
  regmap_clear_bitshdmi->regs, , CFG2_MHL_DE_SEL)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
 else
  regmap_set_bits(hdmi- return;
}

static void (hdmi->regs, GRL_INFOFRM_VER)
     enum hdmi_aud_channel_swap_type swap)
{
 u8 swap_bit;

 switch (swap regmap_set_bits(->,ctrl_reg, ctrl_frame_en;
  HDMI_AUD_SWAP_LRjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
  swap_bit=LR_SWAP;
  break;
case:
 LFE_CC_SWAP
 h->,- + java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
  HDMI_AUD_SWAP_LSRS
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
  break;
 case HDMI_AUD_SWAP_RLS_RRS:
  (2000, )
  break;
 HDMI_AUD_SWAP_LR_STATUS:
  swap_bit = LR_STATUS_SWAP;
   regmap_update_bitshregs, CFG4_AV_UNMUTE_EN|CFG4_AV_UNMUTE_SET
 default:
  swap_bit = LFE_CC_SWAP;
  break;
 }
 regmap_update_bits
}

static void mtk_hdmi_hw_aud_set_bit_num(struct mtk_hdmi *hdmi,
   enum hdmi_audio_sample_size)
{
 u32 val;

 java.lang.StringIndexOutOfBoundsException: Range [0, 7) out of bounds for length 1
 case HDMI_AUDIO_SAMPLE_SIZE_16:
  val = AOUT_16BIT;
 break;
  mode-> ==74250
  val = AOUT_20BIT;
  break;
case :
DIO_SAMPLE_SIZE_STREAM
    (swapjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 ;
 }

 regmap_update_bits(hdmi->regs, GRL_AOUT_CFG, 
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

static
    i2s_fmt
{
 u32 val;

 regmap_read(hdmi->java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
val& (CFG0_W_LENGTH_MASK | CFG0_I2S_MODE_MASK);

  ){
 case HDMI_I2S_MODE_RJT_24BIT:
  val;
  break
 case HDMI_I2S_MODE_RJT_16BIT:
  =CFG0_I2S_MODE_RTJ CFG0_W_LENGTH_16BIT
  ;
 caseHDMI_I2S_MODE_RJT_16BIT
 default:
  val| CFG0_I2S_MODE_LTJ  ;
  break;
  ;
  val |= CFG0_I2S_MODE_LTJ |  HDMI_I2S_MODE_I2S_24BIT:
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
 case HDMI_I2S_MODE_I2S_24BIT
  = CFG0_W_LENGTH_24BIT
  break;
case :
  val  = SACD_DST;
 ;
 }
regmap_write(hdmi-egs, , val;
}

void (java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 69
{
 const u8 mask = HIGH_BIT_RATE | java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 40
 u8 val;

/* Disable high bitrate, set DST packet normal/double */

 (hdmi,,HIGH_BIT_RATE_PACKET_ALIGN

  dst
  val    (3  2;
 
  val = 0;

 (dmi-regs, mask val);
}

static void      channel_type != HDMI_AUD_CHAN_TYPE_4_1
     enum hdmi_aud_channel_type channel_type,
     u8 channel_count)
{
  intch_switchjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
u8 java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

 ch_switch = CH_SWITCH(7, 7) | CH_SWITCH(6, 6) |
      CH_SWITCH(  {
      CH_SWITCH(3, 3) | CH_SWITCH1)
      CH_SWITCH( java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 if ( regmap_write(hdmiregs, ch_switch> 8 &)
 java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 27
 || channel_count=4 java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
= 4 &&
      (     enum input_type)
      channel_type == HDMI_AUD_CHAN_TYPE_4_0))
   i2s_uv java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  else
 i2s_uv =(3  I2S_UV_CH_EN()java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
 } else if (java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 21
  if (channel_count == 6 &&
      channel_type != java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 20
 channel_type HDMI_AUD_CHAN_TYPE_4_1_CLRS
   i2s_uv }
    I2S_UV_CH_EN |(0);
  } else {
S_UV_CH_EN) (1) |
     I2S_UV_CH_EN(0);
  }
 } else
 i2s_uv=I2S_UV_CH_EN3)  (2)|
  I2S_UV_CH_EN) |(0);
 } else {
    I2S_UV_CH_EN0)
 }

(dmi>, ch_switch&0xff;
  regmap_write(->,  +i* 0)
 (hdmi-,GRL_CH_SW2 (h_switch >)&0xff;
 regmap_write(hdmi-java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

static void  val;
  hdmi_aud_input_typeinput_type)
{
 u32 ;

 regmap_read(hdmi->regs, GRL_CFG1, &val) regmap_writeh-regs, GRL_MIX_CTRL, val);
  input_type HDMI_AUD_INPUT_I2S &&
     (val & CFG1_SPDIF)  val| ;
  & ~;
 } else if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  (val & CFG1_SPDIF) ={
  val |= CFG1_SPDIF;
 }
 regmap_readh->,, &)
}

staticregmap_write-regs ,valjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
            u8 *
{
 int i;

 for (i = 0; i < 5; i++) {
  regmap_write(hdmi->java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 1
 (-, GRL_L_STATUS_0i  4channel_statusi;
  regmap_write(hdmi->regs, GRL_R_STATUS_0 + i * 4 & CFG5_CD_RATIO_MASK
 }  HDMI_AUD_MCLK_128FS
 ; i++ {
  regmap_write(hdmi-> HDMI_AUD_MCLK_256FS
  (hdmi-,GRL_R_STATUS_0i* 4 )java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
 }
}

static void java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 8
{
 u32 val;

 hdmi-,GRL_MIX_CTRL&al;
 if (val & java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9
  val &= ~regmap_write(hdmi->regs, val
  regmap_write(hdmi-
 usleep_range255,);
  val |= MIX_CTRL_SRC_EN;
  regmap_write(hdmi->regsunsigned n;
}
}

static void mtk_hdmi_hw_aud_src_disable(struct java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 53
{
 u32 val;

 regmap_read(hdmi->regs   25175 {     6864 },
val&~MIX_CTRL_SRC_EN
 regmap_write(hdmi->regs, GRL_MIX_CTRL, val
hdmi-regs, 0x00java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
}

 void (struct mtk_hdmi *hdmi,
         enum hdmi_aud_mclk mclk)
{
 u32 val;

regmap_read(dmi>egsGRL_CFG5, &val);
 val &= CFG5_CD_RATIO_MASK;

 switch (mclk) {
 case HDMI_AUD_MCLK_128FS:
  val |= CFG5_FS128;
  break;
 case HDMI_AUD_MCLK_256FS:
  val |= CFG5_FS256 @req audiosample  in Hz
  break;
 case HDMI_AUD_MCLK_384FS:
  val |= CFG5_FS384;
  break;
 case HDMI_AUD_MCLK_512FS:
  val |= CFG5_FS512;
  break;
 case HDMI_AUD_MCLK_768FS *@:rounded   inkHz
  val |= CFG5_FS768;
  break;
 default:
  val | ;
  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 }
   int;
}

struct hdmi_acr_n {
 unsigned int  if (clock == hdmi[].)
 unsigned int n[3];
};

/* Recommended N values from HDMI specification, tables 7-1 to 7-3 */
static conststruct  hdmi_rec_n_table] java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
 /* Clock, N: 32kHz 44.1kHz 48kHz */ :
 {  25175, {  4576,  7007,  6864 } },
 {  74176, { 11648, 17836, 11648 } },
 { 148352, { 11648,  8918,  5824 } },
 { 296703, {  5824,  4459,  5824 } },
 { 297000,java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 {      0, {  4096,  6272,  6144 } }, /* all other TMDS clocks */
};

/**
  java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 40
 * @freq: audio sample rate in Hz
 * @clock: rounded TMDS clock in kHz
 */

java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
{
 const struct hdmi_acr_n *recommended;
 unsigned int i;

 for (i = 0; i < ARRAY_SIZE(hdmi_rec_n_table) - 1; i++) {
 ( ==[]clock
   break;
 }
 recommended = hdmi_rec_n_table + i;

 switch void(struct mtk_hdmi*, unsignedjava.lang.StringIndexOutOfBoundsException: Range [72, 71) out of bounds for length 74
 case 32000:
  return recommended char valN];
 case 44100:
  return ->n1;
case 48000:
   recommended[]java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 case 88200:
   []  >>24)0xff
 case 96000 [1  ( > 16)&x;
  return recommended->n[2] * 2;
 case 176400:
  return val4  n >) xffjava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
 case 192000:
  return recommended->n[2] * 4;
 default
  return (128(hdmi>egs, val[)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
}
}

static unsigned  intclock)
{
 switch (clock) {
 case 25175:
   mtk_hdmjava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 49
 case74176:
  return 74175824; /* 74.25/1.001 MHz */
 case 148352
48.5/. *
 case 296703:
  return 296703297; }
 default:
 return *1000;
 }
}

static unsigned int hdmi_expected_cts(unsigned int audio_sample_rate,
  int ,unsigned  java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
{
 return DIV_ROUND_CLOSEST_ULL((u64)hdmi_mode_clock_to_hz(java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 29
         128return 6;
}

static void case HDMI_AUD_CHAN_TYPE_6_1_CHjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
         unsigned int caseHDMI_AUD_CHAN_TYPE_7_0_LSR_RSR:
{
 (sample_rate, clock)
 *cts = hdmi_expected_cts(  :
}

static void  7;
       java.lang.StringIndexOutOfBoundsException: Range [25, 16) out of bounds for length 25
{case :
 unsigned char val[NCTS_BYTES];
 int i;case:

 regmap_write(hdmi-> :
 regmap_write(hdmi->regs, GRL_NCTSstatic mtk_hdmi_video_change_vplljava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 71
 regmap_write(hdmi- dev_err(->ev,F toset  u:%\,clock,
 memset(val, 0, sizeof(val));

 val[0] = (cts >> 24) & 0xff;
 val[1] = (cts >> 16) & 0xff;
 val[2] =staticvoid mtk_hdmi_aud_set_input mtk_hdmijava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 [3]    0;

] (n ) & java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
[5= n >8  0;
 val[6]   &xff;

 for (i = 0; i < NCTS_BYTES; i++)
map_write(hdmi>egs,GRL_NCTS, [i]);
}

static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi,mtk_hdmi_hw_aud_set_input_typehdmi, hdmi->java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
 int sample_rate,
         unsigned int clock)
{
 unsigned int n, cts;

 mtk_hdmi_get_ncts(sample_rate, clock, &n, &cts);

 dev_dbg(hdmi->dev, "%s: sample_rate=% mtk_hdmi_hw_aud_set_ncts(hdmi, sample_ ->
 h,)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

(->egs DUMMY_304AUDIO_I2S_NCTS_SELAUDIO_I2S_NCTS_SEL_64;
 do_hdmi_hw_aud_set_ncts(hdmi, n, cts)(,true)
}

static u8 mtk_hdmi_aud_get_chnl_count(enum hdmi_aud_channel_type channel_type)
{
switch(){
 case HDMI_AUD_CHAN_TYPE_1_0:
 case HDMI_AUD_CHAN_TYPE_1_1:
case :
  return 2;
 case HDMI_AUD_CHAN_TYPE_2_1:
 case HDMI_AUD_CHAN_TYPE_3_0:
  return 3;
 case HDMI_AUD_CHAN_TYPE_3_1:
caseHDMI_AUD_CHAN_TYPE_4_0
  :
  return 4; intmtk_hdmi_setup_spd_infoframe java.lang.StringIndexOutOfBoundsException: Range [62, 61) out of bounds for length 62
 case HDMI_AUD_CHAN_TYPE_4_1:
 case HDMI_AUD_CHAN_TYPE_5_0:
 case:
HDMI_AUD_CHAN_TYPE_4_0_CLRS
  return 5;
 case :
 case HDMI_AUD_CHAN_TYPE_6_0: (-,Failed  SDPn" ;
 casessize_t java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 case HDMI_AUD_CHAN_TYPE_6_0_CS:
 case HDMI_AUD_CHAN_TYPE_6_0_CH:
 case HDMI_AUD_CHAN_TYPE_6_0_OH:
   returnjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  return 6;
 case :
 case HDMI_AUD_CHAN_TYPE_6_1_CSjava.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 46
case :
 :
R
  HDMI_AUD_CHAN_TYPE_7_0:
 case HDMI_AUD_CHAN_TYPE_7_0_LH_RH:
 case HDMI_AUD_CHAN_TYPE_7_0_LSR_RSR:
 case HDMI_AUD_CHAN_TYPE_7_0_LC_RCjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 case HDMI_AUD_CHAN_TYPE_7_0_LW_RW:
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 case java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 15
 case HDMI_AUD_CHAN_TYPE_7_0_LHS_RHS:
 case HDMI_AUD_CHAN_TYPE_7_0_CS_CH:
 case HDMI_AUD_CHAN_TYPE_7_0_CS_OH (rr){
  " to get  infoframefrommode::%\, errjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
 0
 case java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
 ;
 case HDMI_AUD_CHAN_TYPE_7_0_LSS_RSS_LSR_RSR
 case HDMI_AUD_CHAN_TYPE_8_0_LH_RH_CS
  return afalse;
 case      struct*
 case :
 case HDMI_AUD_CHAN_TYPE_7_1_LSR_RSR:
 _LC_RC:
 case HDMI_AUD_CHAN_TYPE_7_1_LW_RW:
 case  = mtk_hdmi_video_change_vpll,
 -clock*);
 case HDMI_AUD_CHAN_TYPE_7_1_LHS_RHS:
 case returnret;
case HDMI_AUD_CHAN_TYPE_7_1_CS_OH
 case java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 25
 case HDMI_AUD_CHAN_TYPE_7_1_CH_OH:
 case mtk_hdmi_hw_send_av_unmute(hdmi);
 case HDMI_AUD_CHAN_TYPE_7_1_OH_CHR:
 case HDMI_AUD_CHAN_TYPE_7_1_LSS_RSS_LSR_RSR:
  return 8
  java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 37
  return 2;
 }
}

static i;
{
 rate;
 int ret;

/* The DPI driver already should have set TVDPLL to the correct rate */
 PTR_ERR]
 ret = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 1
 if (ret) {
  dev_err(hdmi->devjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   ret);
  return ret;
 }

 rate = clk_get_rate(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]);

 if (DIV_ROUND_CLOSEST(rate, 1000) != DIV_ROUND_CLOSEST(clock, 1000))
    
    rate);
 else
  dev_dbg(hdmi->dev, "Want

 mtk_hdmi_hw_config_sys(hdmi);
 mtk_hdmi_hw_set_deep_color_mode(->clk]java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
 
}

static mtk_hdmi_update_plugged_statusmtk_hdmi *)
       connected;
{
 mtk_hdmi_hw_reset(hdmi);
 mtk_hdmi_hw_enable_notice(hdmi, true);
 mtk_hdmi_hw_write_int_mask(hdmi, 0  (hdmi-plugged_cb &->codec_dev
 java.lang.StringIndexOutOfBoundsException: Range [39, 28) out of bounds for length 51
 java.lang.StringIndexOutOfBoundsException: Range [40, 35) out of bounds for length 48

 mtk_hdmi_hw_msic_setting,mode;
}


static void mtk_hdmi_aud_set_input
{
 enum hdmi_aud_channel_type
u8 chan_count;
bool;

 l_swap,HDMI_AUD_SWAP_LFE_CCjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
 regmap_set_bits(hdmi->regs,     const  struct*info,

 if (hdmi->aud_param.aud_input_type == java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 1
     >aud_param ==)java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
  mtk_hdmi_hw_aud_set_bit_num(-> &java.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 65
 } else if (  h--&)
  hdmi->aud_param.aud_i2s_fmtjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 mtk_hdmi_hw_aud_set_i2s_fmt(hdmi, hdmi
 mtk_hdmi_hw_aud_set_bit_num(hdmi, HDMI_AUDIO_SAMPLE_SIZE_24);

 dst = ((hdmi->aud_param.aud_input_type == java.lang.StringIndexOutOfBoundsException: Range [0, 63) out of bounds for length 25
        (dmi>aud_codec ));
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0

 if (hdmi->aud_param.aud_input_type == HDMI_AUD_INPUT_SPDIF)
  java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
 else
   a.;
 chan_count = drm_connector_status
 status = mtk_hdmi_detect;
( hdmi-.)
}

static int mtk_hdmi_aud_set_src
   java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 42
{
 * 

 mtk_hdmi_hw_ncts_enable(hdmi, false);
 mtk_hdmi_hw_aud_src_disable(hdmi);
 regmap_clear_bits(struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);

 ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  switch (sample_rate) {
  32000
  case
  case 48000:
  case 88200:
  case 96000:
;
  default:
   return *: java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 66
  }
  mtk_hdmi_hw_aud_set_mclk(hdmi, hdmi->aud_param.aud_mclk);
 } else {
  switch (sample_rate) {
  case 32000:
 case44100:
  case 48000:
   break;
  default:
 return -INVAL
  }
  mtk_hdmi_hw_aud_set_mclk(hdmi, HDMI_AUD_MCLK_128FS);
 }

 (sample_rate, -clock);

 mtk_hdmi_hw_aud_src_reenable(hdmi);
java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 10
}

static drm_encoder*java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
          struct struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
{
 ;
 mtk_hdmi_hw_send_aud_packet(hdmi, false);

 mtk_hdmi_aud_set_input(hdmi);
 mtk_hdmi_aud_set_src(hdmi, display_mode);
 mtk_hdmi_hw_aud_set_channel_status(hdmi, java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 hdmi->.codec_params.status;

 usleep_range(50, 100);

 mtk_hdmi_hw_ncts_enable(hdmi, true);
mtk_hdmi_hw_send_aud_packet(hdmi, rue);
 mtk_hdmi_hw_aud_unmute(hdmi);
 return 0;
}

java.lang.StringIndexOutOfBoundsException: Range [0, 6) out of bounds for length 0
     struct drm_display_mode *mode)
{
 struct hdmi_avi_infoframe frame;
 u8 buffer[HDMI_INFOFRAME_HEADER_SIZE
 ssize_t;

 err =(&frame,
             hdmi->curr_conn, mode);
 (  0) {
  dev_err(hdmi->dev,
   "Failed tojava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  return err;
 }

 err(&, ,sizeof(buffer);
 if (err < 0) {
 dev_errh>dev,Failed to AVIinfoframe zd\" ;

 }

 _(hdmi, sizeof(buffer);
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

tatic int mtk_hdmi_setup_spd_infoframemtk_hdmi*)
{
 struct drm_bridge *bridge = 
 struct hdmi_spd_infoframe frame ->  false;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 ssize_t err;

 err = hdmi_spd_infoframe_init(&frame, bridge-
 if (err < 0  * =(bridge
  dev_err(hdmi->dev  !->java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
   err);
  return err;
 }

 java.lang.StringIndexOutOfBoundsException: Range [11, 6) out of bounds for length 63
 err ){
  dev_err(hdmi->dev, "Failed to   java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 49
  return err;struct java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 54
 }

(uffer))
 0;
}

staticintmtk_hdmi_setup_audio_infoframe( java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
{
 struct hdmi_audio_infoframe frame;
u8buffer[ +HDMI_AUDIO_INFOFRAME_SIZE
 ssize_t err;

 err = hdmi_audio_infoframe_init( (dmijava.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 42
 if (err < 0) {
  dev_err(hdmi->dev, }
   err);
  return err;
 }

 frame.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM;
 frame.sample_frequency = struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
 frame.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM;
 frame.channels = mtk_hdmi_aud_get_chnl_count(
     hdmi->aud_param.aud_input_chan_type);

 err = hdmi_audio_infoframe_pack(&frame, buffer, sizeof(buffer)}
 if (err < 0) {
 dev_err(->dev," to   infoframe %d\n"
   err);
  return         mode
 }

 hdmi,, ();
 return 0;
}

static int mtk_hdmi_setup_vendor_specific_infoframe(struct mtk_hdmi
      struct drm_display_mode *mode)
{
 struct hdmi_vendor_infoframe frame;
 u8 buffer[10];
 ssize_t err;

 err = drm_hdmi_vendor_infoframe_from_display_mode(&frame,
         hdmi->curr_conn, mode);
 if (err) {
  (dmi-dev,
   "Failed to get  clk_prepare_enable(hdmi]);
  return err;
 }

 err = hdmi_vendor_infoframe_pack(&frame, buffer, sizeof(buffer));
  (err < 0 {
  dev_err(hdmi->java.lang.StringIndexOutOfBoundsException: Range [0, 19) out of bounds for length 1
   err);
  return err;
 }

 atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 return 0;
}

static void mtk_hdmi_audio_enable(struct mtk_hdmi *hdmi.  mtk_hdmi_bridge_atomic_disable,
{
 mtk_hdmi_hw_send_aud_packet(hdmi, true);
>udio_enable  ;
}

static void mtk_hdmi_audio_disable(struct mtk_hdmi  mtk_hdmi_bridge_detectjava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
{
 (hdmi,);
 hdmijava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static int java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
         struct drm_display_mode *mode)
{
 int retjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 mtk_hdmi_hw_vid_black(hdmi, true);
 mtk_hdmi_hw_aud_mute(hdmi);
 mtk_hdmi_hw_send_av_mute(hdmi);
 phy_power_off(hdmi->phy);

  java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39
      mode->clock * 1000);
 if (ret) {
  dev_err(hdmi->dev, "Failed to set vpll: %d\n", ret);
    -;
 }
 (hdmi ;

 phy_power_on/*
 mi_aud_output_confighdmi,;

  )java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
 mtk_hdmi_hw_aud_unmute(hdmi);
 mtk_hdmi_hw_send_av_unmute(hdmi);
 */
 0;
}

static const char  (,(hdmi-sys_regmap,
 [MTK_HDMI_CLK_HDMI_PIXEL] = "pixel",
 [MTK_HDMI_CLK_HDMI_PLL] = "pll",
 [TK_HDMI_CLK_AUD_BCLK]  bclk",
 [MTK_HDMI_CLK_AUD_SPDIF] = "spdif",
};

static int mtk_hdmi_get_all_clk(struct java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0
    struct device_node *np)
{
i;

 for (i = 0; i < ARRAY_SIZE return (hdmi
 -[]np
        mtk_hdmi_clk_names[i]);
  !java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
   return PTR_ERR(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }

}

static int mtk_hdmi_clk_enable_audio(struct mtk_hdmi *hdmi)
{
 int ret;

 ret = clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_AUD_BCLK]);
 (et)
  return ret;

  unsigned  =params->cea.channels;
 if (ret) {
  clk_disable_unprepare(hdmi->clk[];
  return ret;
 }

 return 0;
}

static void mtk_hdmi_clk_disable_audio(struct break
{
 clk_disable_unprepare  java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
 clk_disable_unprepare(java.lang.StringIndexOutOfBoundsException: Range [1, 27) out of bounds for length 8
}

static enum drm_connector_status
mtk_hdmi_update_plugged_status(structjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
 bool connected;

 mutex_lock(&hdmi->update_plugged_status_lock);
 connected =mtk_cec_hpd_high(dmi>cec_devec_dev);
 if (hdmi- dev_err-dev, java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 49
 ->lugged_cbhdmi-codec_dev, java.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 47
 mutex_unlock(&hdmi->update_plugged_status_lock .aud_sample_size= DMI_AUDIO_SAMPLE_SIZE_16

 return connected ?
        connector_status_connected : connector_status_disconnected;
}

static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi)
{
 return mtk_hdmi_update_plugged_status(hdmi);
}

static enum drm_mode_status
mtk_hdmi_bridge_mode_valid}
  drm_display_info *info,
      const struct drm_display_mode *mode)
{
 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge  aud_params.aud_codec,aud_params.aud_input_type

 dev_dbg(hdmi-
 ->displaymode->vdisplay, drm_mode_vrefresh(mode),
  !!(mode->flags & DRM_MODE_FLAG_INTERLACE), mode->

 if (hdmi->conf) {
 hdmi->-cea_modes_only (ode)
   return MODE_BAD;

  if (hdmi->conf->max_mode_clock &&
      mode->clock > hdmi->conf->max_mode_clock)
   return MODE_CLOCK_HIGH;
 }

 if (mode->clock < 27000)
  return MODE_CLOCK_LOW;
 if ->clocklock  )
  return MODE_CLOCK_HIGH;

 return drm_mode_validate_size(mode, 0 (hdmi;
}

static void mtk_hdmi_hpd_event(bool hpd, struct device *dev)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 if (hdmi && hdmi->bridge.encoder && hdmi->staticvoid(java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 90
;

  status = 
i->bridge->dev;
  (hdmi ,codec_dev)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 }
}

/*
 * Bridge callbacks
 */


static enum drm_connector_status
mtk_hdmi_bridge_detect(hook_plugged_cbmtk_hdmi_audio_hook_plugged_cb
{
 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);

 return mtk_hdmi_detect(hdmi);
}

static constintmtk_hdmi_register_audio_driver device *ev
       struct drm_connector *connector)
{
 struct mtk_hdmi * hdmi_ctx_from_bridge(bridge);
 const struct drm_edid *drm_edid;

 if (!hdmimax_i2s_channels  ,
  . 
 = (connector->java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57

  /*
   >ud_sample_size HDMI_AUDIO_SAMPLE_SIZE_16
   * ! aud_param-java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 43
   * the EDID and called drm_edid_connector_update().
 */

  const struct edid *edid = drm_edid_raw(drm_edid);

  hdmi->dvi_mode = !drm_detect_monitor_audio(edid);
 }

return
}

static int mtk_hdmi_bridge_attach(struct drm_bridge *bridge,
      struct if()
      enum drm_bridge_attach_flags flags)
{
 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);
 int ret;

 if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
  DRM_ERROR{
 _func__);
  return -EINVAL;
 }

 if(hdminext_bridge
  ret = drm_bridge_attach(encoder, hdmi->next_bridge,
     bridge, flags);
  if (ret)
   return ret;
 }

 mtk_cec_set_hpd_event(hdmi->cec_dev, java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 0

 return 0;
}

static bool mtk_hdmi_bridge_mode_fixup(struct drm_bridge *bridge,
           const struct drm_display_mode *mode,
           struct  = mtk_hdmi_register_audio_driver
{
 return true;
}

static void mtk_hdmi_bridge_atomic_disable(struct drm_bridge *bridge,
     DRM_BRIDGE_OP_HPD
{
 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);

 if (!hdmi->enabled)
  return;

 phy_power_off(hdmi->phy);
 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL =(hdmi)
 clk_disable_unprepare(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]);

 hdmi->curr_conn = NULL;

 hdmi->enabled = false;
}

static void mtk_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,
      struct drm_atomic_state *state)
{
 struct java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0

 if (!hdmi->powered)
  return;

 mtk_hdmi_hw_1p4_version_enable
 mtk_hdmi_hw_make_reg_writable(hdmi, false);

hdmi> = false;
}

java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 63
    const struct drm_display_mode *mode,
    java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
{
 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);

 dev_dbg(hdmi->dev, "cur info name:,hdisplay:%n"
  adjusted_mode->name, adjusted_mode->hdisplay);
 , htotal:%d"
  adjusted_mode->hsync_start, adjusted_mode->hsync_end,
  = true
 dev_dbg(hdmi->dev, "java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
  adjusted_mode->hskew, adjusted_mode->vdisplay);
 dev_dbghdmi>ev, vsync_start:d,vsync_end:%,%d"
  adjusted_mode{compatible =ediatek,java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 73
  adjusted_mode->vtotal);
 dev_dbg(hdmi->dev, "vscan:%d, flag:%d\n",
  adjusted_modevscan,adjusted_mode->flags);

 drm_mode_copy(& struct platform_driverjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 49
}  = mtk_hdmi_remove

static mtk_hdmi_bridge_atomic_pre_enable drm_bridge*,
           struct drm_atomic_state *state)
{
 struct mtk_hdmi *hdmi = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 3

 mtk_hdmi_hw_make_reg_writable(hdmi, true);
 mtk_hdmi_hw_1p4_version_enable(hdmi, true);

 hdmi->powered = true;
}

static void mtk_hdmi_send_infoframe(struct mtk_hdmi *hdmi,
        struct drm_display_mode *mode)
{
 mtk_hdmi_setup_audio_infoframe(hdmi);
 mtk_hdmi_setup_avi_infoframe(hdmi, mode);
 mtk_hdmi_setup_spd_infoframe(hdmi);
 if (mode->flags & DRM_MODE_FLAG_3D_MASK)
  mtk_hdmi_setup_vendor_specific_infoframe(hdmi, mode);
}

static void mtk_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,
       struct drm_atomic_state *state)
{
 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge);

 /* Retrieve the connector through the atomic state. */
 hdmi->curr_conn = drm_atomic_get_new_connector_for_encoder(state,
           bridge->encoder);

 mtk_hdmi_output_set_display_mode(hdmi, &hdmi->mode);
 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PLL]);
 clk_prepare_enable(hdmi->clk[MTK_HDMI_CLK_HDMI_PIXEL]);
 phy_power_on(hdmi->phy);
 mtk_hdmi_send_infoframe(hdmi, &hdmi->mode);

 hdmi->enabled = true;
}

static const struct drm_bridge_funcs mtk_hdmi_bridge_funcs = {
 .mode_valid = mtk_hdmi_bridge_mode_valid,
 .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
 .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 .atomic_reset = drm_atomic_helper_bridge_reset,
 .attach = mtk_hdmi_bridge_attach,
 .mode_fixup = mtk_hdmi_bridge_mode_fixup,
 .atomic_disable = mtk_hdmi_bridge_atomic_disable,
 .atomic_post_disable = mtk_hdmi_bridge_atomic_post_disable,
 .mode_set = mtk_hdmi_bridge_mode_set,
 .atomic_pre_enable = mtk_hdmi_bridge_atomic_pre_enable,
 .atomic_enable = mtk_hdmi_bridge_atomic_enable,
 .detect = mtk_hdmi_bridge_detect,
 .edid_read = mtk_hdmi_bridge_edid_read,
};

static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np)
{
 struct platform_device *cec_pdev;
 struct device_node *cec_np;
 int ret;

 ret = mtk_hdmi_get_all_clk(hdmi, np);
 if (ret)
  return dev_err_probe(dev, ret, "Failed to get clocks\n");

 /* The CEC module handles HDMI hotplug detection */
 cec_np = of_get_compatible_child(np->parent, "mediatek,mt8173-cec");
 if (!cec_np)
  return dev_err_probe(dev, -EINVAL, "Failed to find CEC node\n");

 cec_pdev = of_find_device_by_node(cec_np);
 if (!cec_pdev) {
  dev_err(hdmi->dev, "Waiting for CEC device %pOF\n",
   cec_np);
  of_node_put(cec_np);
  return -EPROBE_DEFER;
 }
 of_node_put(cec_np);

 /*
  * The mediatek,syscon-hdmi property contains a phandle link to the
  * MMSYS_CONFIG device and the register offset of the HDMI_SYS_CFG
  * registers it contains.
 */

 hdmi->sys_regmap = syscon_regmap_lookup_by_phandle_args(np, "mediatek,syscon-hdmi",
        1, &hdmi->sys_offset);
 if (IS_ERR(hdmi->sys_regmap))
  return dev_err_probe(dev, PTR_ERR(hdmi->sys_regmap),
         "Failed to get system configuration registers\n");

 hdmi->cec_dev = &cec_pdev->dev;
 return 0;
}

static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
       struct platform_device *pdev)
{
 struct device *dev = &pdev->dev;
 struct device_node *np = dev->of_node;
 struct device_node *remote, *i2c_np;
 int ret;

 ret = mtk_hdmi_get_all_clk(hdmi, np);
 if (ret)
  return dev_err_probe(dev, ret, "Failed to get clocks\n");

 hdmi->regs = device_node_to_regmap(dev->of_node);
 if (IS_ERR(hdmi->regs))
  return PTR_ERR(hdmi->regs);

 remote = of_graph_get_remote_node(np, 1, 0);
 if (!remote)
  return -EINVAL;

 if (!of_device_is_compatible(remote, "hdmi-connector")) {
  hdmi->next_bridge = of_drm_find_bridge(remote);
  if (!hdmi->next_bridge) {
   dev_err(dev, "Waiting for external bridge\n");
   of_node_put(remote);
   return -EPROBE_DEFER;
  }
 }

 i2c_np = of_parse_phandle(remote, "ddc-i2c-bus", 0);
 of_node_put(remote);
 if (!i2c_np)
  return dev_err_probe(dev, -EINVAL, "No ddc-i2c-bus in connector\n");

 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
 of_node_put(i2c_np);
 if (!hdmi->ddc_adpt)
  return dev_err_probe(dev, -EINVAL, "Failed to get ddc i2c adapter by node\n");

 ret = mtk_hdmi_get_cec_dev(hdmi, dev, np);
 if (ret)
  return ret;

 return 0;
}

/*
 * HDMI audio codec callbacks
 */


static int mtk_hdmi_audio_params(struct mtk_hdmi *hdmi,
     struct hdmi_codec_daifmt *daifmt,
     struct hdmi_codec_params *params)
{
 struct hdmi_audio_param aud_params = { 0 };
 unsigned int chan = params->cea.channels;

 dev_dbg(hdmi->dev, "%s: %u Hz, %d bit, %d channels\n", __func__,
  params->sample_rate, params->sample_width, chan);

 if (!hdmi->bridge.encoder)
  return -ENODEV;

 switch (chan) {
 case 2:
  aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0;
  break;
 case 4:
  aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_4_0;
  break;
 case 6:
  aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_5_1;
  break;
 case 8:
  aud_params.aud_input_chan_type = HDMI_AUD_CHAN_TYPE_7_1;
  break;
 default:
  dev_err(hdmi->dev, "channel[%d] not supported!\n", chan);
  return -EINVAL;
 }

 switch (params->sample_rate) {
 case 32000:
 case 44100:
 case 48000:
 case 88200:
 case 96000:
 case 176400:
 case 192000:
  break;
 default:
  dev_err(hdmi->dev, "rate[%d] not supported!\n",
   params->sample_rate);
  return -EINVAL;
 }

 switch (daifmt->fmt) {
 case HDMI_I2S:
  aud_params.aud_codec = HDMI_AUDIO_CODING_TYPE_PCM;
  aud_params.aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16;
  aud_params.aud_input_type = HDMI_AUD_INPUT_I2S;
  aud_params.aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT;
  aud_params.aud_mclk = HDMI_AUD_MCLK_128FS;
  break;
 case HDMI_SPDIF:
  aud_params.aud_codec = HDMI_AUDIO_CODING_TYPE_PCM;
  aud_params.aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16;
  aud_params.aud_input_type = HDMI_AUD_INPUT_SPDIF;
  break;
 default:
  dev_err(hdmi->dev, "%s: Invalid DAI format %d\n", __func__,
   daifmt->fmt);
  return -EINVAL;
 }
 memcpy(&aud_params.codec_params, params, sizeof(aud_params.codec_params));
 memcpy(&hdmi->aud_param, &aud_params, sizeof(aud_params));

 dev_dbg(hdmi->dev, "codec:%d, input:%d, channel:%d, fs:%d\n",
  aud_params.aud_codec, aud_params.aud_input_type,
  aud_params.aud_input_chan_type, aud_params.codec_params.sample_rate);

 return 0;
}

static int mtk_hdmi_audio_hw_params(struct device *dev, void *data,
        struct hdmi_codec_daifmt *daifmt,
        struct hdmi_codec_params *params)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 if (!hdmi->audio_enable) {
  dev_err(hdmi->dev, "hdmi audio is in disable state!\n");
  return -EINVAL;
 }

 mtk_hdmi_audio_params(hdmi, daifmt, params);
 mtk_hdmi_aud_output_config(hdmi, &hdmi->mode);

 return 0;
}

static int mtk_hdmi_audio_startup(struct device *dev, void *data)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 mtk_hdmi_audio_enable(hdmi);

 return 0;
}

static void mtk_hdmi_audio_shutdown(struct device *dev, void *data)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 mtk_hdmi_audio_disable(hdmi);
}

static int
mtk_hdmi_audio_mute(struct device *dev, void *data,
      bool enable, int direction)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 if (enable)
  mtk_hdmi_hw_aud_mute(hdmi);
 else
  mtk_hdmi_hw_aud_unmute(hdmi);

 return 0;
}

static int mtk_hdmi_audio_get_eld(struct device *dev, void *data, uint8_t *buf, size_t len)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 if (hdmi->enabled)
  memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len));
 else
  memset(buf, 0, len);
 return 0;
}

static void mtk_hdmi_audio_set_plugged_cb(struct mtk_hdmi *hdmi, hdmi_codec_plugged_cb fn,
       struct device *codec_dev)
{
 mutex_lock(&hdmi->update_plugged_status_lock);
 hdmi->plugged_cb = fn;
 hdmi->codec_dev = codec_dev;
 mutex_unlock(&hdmi->update_plugged_status_lock);
}

static int mtk_hdmi_audio_hook_plugged_cb(struct device *dev, void *data,
       hdmi_codec_plugged_cb fn,
       struct device *codec_dev)
{
 struct mtk_hdmi *hdmi = data;

 mtk_hdmi_audio_set_plugged_cb(hdmi, fn, codec_dev);
 mtk_hdmi_update_plugged_status(hdmi);

 return 0;
}

static const struct hdmi_codec_ops mtk_hdmi_audio_codec_ops = {
 .hw_params = mtk_hdmi_audio_hw_params,
 .audio_startup = mtk_hdmi_audio_startup,
 .audio_shutdown = mtk_hdmi_audio_shutdown,
 .mute_stream = mtk_hdmi_audio_mute,
 .get_eld = mtk_hdmi_audio_get_eld,
 .hook_plugged_cb = mtk_hdmi_audio_hook_plugged_cb,
};

static void mtk_hdmi_unregister_audio_driver(void *data)
{
 platform_device_unregister(data);
}

static int mtk_hdmi_register_audio_driver(struct device *dev)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
 struct hdmi_audio_param *aud_param = &hdmi->aud_param;
 struct hdmi_codec_pdata codec_data = {
  .ops = &mtk_hdmi_audio_codec_ops,
  .max_i2s_channels = 2,
  .i2s = 1,
  .data = hdmi,
  .no_capture_mute = 1,
 };
 int ret;

 aud_param->aud_codec = HDMI_AUDIO_CODING_TYPE_PCM;
 aud_param->aud_sample_size = HDMI_AUDIO_SAMPLE_SIZE_16;
 aud_param->aud_input_type = HDMI_AUD_INPUT_I2S;
 aud_param->aud_i2s_fmt = HDMI_I2S_MODE_I2S_24BIT;
 aud_param->aud_mclk = HDMI_AUD_MCLK_128FS;
 aud_param->aud_input_chan_type = HDMI_AUD_CHAN_TYPE_2_0;

 hdmi->audio_pdev = platform_device_register_data(dev,
        HDMI_CODEC_DRV_NAME,
        PLATFORM_DEVID_AUTO,
        &codec_data,
        sizeof(codec_data));
 if (IS_ERR(hdmi->audio_pdev))
  return PTR_ERR(hdmi->audio_pdev);

 ret = devm_add_action_or_reset(dev, mtk_hdmi_unregister_audio_driver,
           hdmi->audio_pdev);
 if (ret)
  return ret;

 return 0;
}

static int mtk_hdmi_probe(struct platform_device *pdev)
{
 struct mtk_hdmi *hdmi;
 struct device *dev = &pdev->dev;
 int ret;

 hdmi = devm_drm_bridge_alloc(dev, struct mtk_hdmi, bridge,
         &mtk_hdmi_bridge_funcs);
 if (IS_ERR(hdmi))
  return PTR_ERR(hdmi);

 hdmi->dev = dev;
 hdmi->conf = of_device_get_match_data(dev);

 ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev);
 if (ret)
  return ret;

 hdmi->phy = devm_phy_get(dev, "hdmi");
 if (IS_ERR(hdmi->phy))
  return dev_err_probe(dev, PTR_ERR(hdmi->phy),
         "Failed to get HDMI PHY\n");

 mutex_init(&hdmi->update_plugged_status_lock);
 platform_set_drvdata(pdev, hdmi);

 ret = mtk_hdmi_register_audio_driver(dev);
 if (ret)
  return dev_err_probe(dev, ret,
         "Failed to register audio driver\n");

 hdmi->bridge.of_node = pdev->dev.of_node;
 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
    | DRM_BRIDGE_OP_HPD;
 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
 hdmi->bridge.vendor = "MediaTek";
 hdmi->bridge.product = "On-Chip HDMI";

 ret = devm_drm_bridge_add(dev, &hdmi->bridge);
 if (ret)
  return dev_err_probe(dev, ret, "Failed to add bridge\n");

 ret = mtk_hdmi_clk_enable_audio(hdmi);
 if (ret)
  return dev_err_probe(dev, ret,
         "Failed to enable audio clocks\n");

 return 0;
}

static void mtk_hdmi_remove(struct platform_device *pdev)
{
 struct mtk_hdmi *hdmi = platform_get_drvdata(pdev);

 mtk_hdmi_clk_disable_audio(hdmi);
}

static __maybe_unused int mtk_hdmi_suspend(struct device *dev)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 mtk_hdmi_clk_disable_audio(hdmi);

 return 0;
}

static __maybe_unused int mtk_hdmi_resume(struct device *dev)
{
 struct mtk_hdmi *hdmi = dev_get_drvdata(dev);

 return mtk_hdmi_clk_enable_audio(hdmi);
}

static SIMPLE_DEV_PM_OPS(mtk_hdmi_pm_ops, mtk_hdmi_suspend, mtk_hdmi_resume);

static const struct mtk_hdmi_conf mtk_hdmi_conf_mt2701 = {
 .tz_disabled = true,
};

static const struct mtk_hdmi_conf mtk_hdmi_conf_mt8167 = {
 .max_mode_clock = 148500,
 .cea_modes_only = true,
};

static const struct of_device_id mtk_hdmi_of_ids[] = {
 { .compatible = "mediatek,mt2701-hdmi", .data = &mtk_hdmi_conf_mt2701 },
 { .compatible = "mediatek,mt8167-hdmi", .data = &mtk_hdmi_conf_mt8167 },
 { .compatible = "mediatek,mt8173-hdmi" },
 { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mtk_hdmi_of_ids);

static struct platform_driver mtk_hdmi_driver = {
 .probe = mtk_hdmi_probe,
 .remove = mtk_hdmi_remove,
 .driver = {
  .name = "mediatek-drm-hdmi",
  .of_match_table = mtk_hdmi_of_ids,
  .pm = &mtk_hdmi_pm_ops,
 },
};
module_platform_driver(mtk_hdmi_driver);

MODULE_AUTHOR("Jie Qiu <jie.qiu@mediatek.com>");
MODULE_DESCRIPTION("MediaTek HDMI Driver");
MODULE_LICENSE("GPL v2");
MODULE_IMPORT_NS("DRM_MTK_HDMI_V1");

Messung V0.5 in Prozent
C=99 H=96 G=97

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.54Angebot  ¤

*Bot Zugriff






Entwurf

Ziele

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Ergonomie der
Schnittstellen

Diese beiden folgenden Angebotsgruppen bietet das Unternehmen

Angebot

Hier finden Sie eine Liste der Produkte des Unternehmens