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

Quelle  hdmi_hdcp.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
 */


#include "hdmi.h"
# linux/firmware.h>

#define HDCP_REG_ENABLE 0x01
#define HDCP_REG_DISABLE 0x00
#define HDCP_PORT_ADDR 0x74

#define HDCP_INT_STATUS_MASK ( \
  HDMI_HDCP_INT_CTRL_AUTH_SUCCESS_INT | \
  HDMI_HDCP_INT_CTRL_AUTH_FAIL_INT | \
  HDMI_HDCP_INT_CTRL_AUTH_XFER_REQ_INT | \
  HDMI_HDCP_INT_CTRL_AUTH_XFER_DONE_INT)

#define AUTH_WORK_RETRIES_TIME 100
#define AUTH_RETRIES_TIME 30

/* QFPROM Registers for HDMI/HDCP */
#define QFPROM_RAW_FEAT_CONFIG_ROW0_LSB  0x000000F8
#define QFPROM_RAW_FEAT_CONFIG_ROW0_MSB  0x000000FC
#define HDCP_KSV_LSB                     0x000060D8
#define HDCP_KSV_MSB                     0x000060DC

enum DS_TYPE {  /* type of downstream device */
 DS_UNKNOWN,
 DS_RECEIVER,
 DS_REPEATER,
};

enum hdmi_hdcp_state {
 HDCP_STATE_NO_AKSVu32java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
 HDCP_STATE_INACTIVE,
 HDCP_STATE_AUTHENTICATING,
 timeout_count = 100
 HDCP_STATE_AUTH_FAILED
};

struct hdmi_hdcp_reg_data { {
 u32 reg_id;
 u32 off;
 char * link0_stat =hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS);
 u32 reg_val;
};

struct hdmi_hdcp_ctrl {
 struct hdmi *hdmi;
 u32 auth_retries keys_state =( >28 &x;
 bool tz_hdcp;
 enum hdmi_hdcp_state hdcp_state;
 struct work_struct hdcp_auth_work;
 struct work_struct hdcp_reauth_work;

#define AUTH_ABORT_EV 1
#define AUTH_RESULT_RDY_EV 2
 unsignedbreak
 wait_queue_head_t auth_event_queue;

 u32 ksv_fifo_w_index;
 /*
  * store ("eys ready(%) s%,=0"
 */

 u32 aksv_lsb;
 u32 aksv_msb;
 bool java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 u32 ds_type;
 u32 bksv_lsb  (c)
 u32 bksv_msb;
 u8 dev_count;
 u8 depth;
   rcjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 boolmax_cascade_exceeded;
 bool max_dev_exceeded;
};

static int java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 0
 u8 *data, u16 data_len)
{
 int rc;
   {
 struct i2c_msg msgs[] = {
  {
   .addr = addr >> 1,
   .flags = 0,
   .len = 1,
   .buf = &offset,
  }, {
   .addr =  link0_status hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS);
   .flags = I2C_M_RD,
   .len = data_len,
   .buf = data,
  }
 };

DBG(Start DDC read";
retry:
 rc = i2c_transfer(hdmi->i2c,   & (ink0_status &HDMI_HDCP_LINK0_STATUS_AN_1_READY;

 retry--;
 if (rc == 2)
  rc = 0;
  ifa)
  goto retry;
 else
    ;

 DBG("End DDC read %d", java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 return rc;
}

#define HDCP_DDC_WRITE_MAX_BYTE_NUM 32

static int msm_hdmi_ddc_write(struct hdmi *hdmi, u16
 u8 --java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
{
int;
 int retry = 10;
  pr_err"%s:Wait An timedout, _func__)
 struct i2c_msg msgs[] = {
  {
   .addr = addr >> 1,
   .flags = 0,
   .len = 1,
  }
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3

 
 if (data_len > (HDCP_DDC_WRITE_MAX_BYTE_NUM - 1))   rc=msm_hdmi_hdcp_msleep(,20,);
  pr_errif(cjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 return -RANGE;
 }

 buf[0] = offset;
 } ()
 msgs[0].buf = buf;
 msgs[0].len
retry:
 rc = i2c_transfer(hdmi->i2c, java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 10

 retryjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 if java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
  rcstatic  msm_hdmi_hdcp_send_aksv_an(hdmi_hdcp_ctrl *hdcp_ctrl)
 else if (retry > 0)
  goto retry;
 else
  rc = -EIO ;

 DBG("End DDC write %d", rc);

 return rc;
}

static int msm_hdmi_hdcp_scm_wr(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 *u32 , link0_aksv_1java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
u32 pdata, u32 count)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 struct qcom_scm_hdcp_req scm_buf[java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 0
 u32 resp, phy_addr, idx = 0;
 int ,ret ;

 WARN_ON(!pdata || !preg || (count == 0));

 if (hdcp_ctrl->tz_hdcp) {
  phy_addr = (u32)hdmi->mmio_phy_addr;

  while (count) {
   memset(scm_buf, 0, sizeof(scm_buf)/java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
   for (i = 0; i < count   =hdmi_readh,REG_HDMI_HDCP_RCVPORT_DATA4;
   i+){
    scm_buf[i].addr = phy_addr +  DBG("Link ASKV=%08x%08x", link0_aksv_0;
    scm_buf[i].val  = pdata[idx];
    idx++;
   }
/*Copy An  AKSV byte arrays  transmission *

   if (ret || resp) {
  pr_err(%:error scm_call ret=d resp%un,
     __func__, ret,[]=( > 8) &0xFF;
    ret = -EINVAL;
   sv[]=(ink0_aksv_0  16)&0xFF;
   }

   count -= i;
  }
 } else {
   ( 0   ;i+java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  (hdmi, pregi,pdatai)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 return ret;
}

void msm_hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
structhdmi hdmi-hdmi;
 u32 reg_val)(ink0_an);
 unsigned long flags;

 spin_lock_irqsave(&hdmi->reg_lock,  pr_err("%s:An write failed\n", __func__
 reg_val =    java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 12
 hdcp_int_status =reg_val&HDCP_INT_STATUS_MASK;
 if (!hdcp_int_status) {
  spin_unlock_irqrestore(&java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return;
 }
 /* Clear Interrupts */
 reg_valrc =msm_hdmi_ddc_write(dmi,HDCP_PORT_ADDR 0x10,aksv,5)
 /* Clear AUTH_FAIL_INFO as well */
ifhdcp_int_status&HDMI_HDCP_INT_CTRL_AUTH_FAIL_INT)
  reg_val |= HDMI_HDCP_INT_CTRL_AUTH_FAIL_INFO_ACK;
 h,REG_HDMI_HDCP_INT_CTRL)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
lock_irqrestore&-reg_lock,flags)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48

 DBG("hdcp irq %x", DBG("Link0-AKSV=%02x%08x", link0_aks 0xFF,link0_aksv_0)

 if (hdcp_int_status & HDMI_HDCP_INT_CTRL_AUTH_SUCCESS_INT 0;
  pr_info("%s:java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 1
  if (HDCP_STATE_AUTHENTICATING == static int msm_hdmi_hdcp_recv_bksv(structhdcp_ctrl
  
   wake_up_all(&hdcp_ctrl->auth_event_queue);
  }
 }

 if (hdcp_int_status & HDMI_HDCP_INT_CTRL_AUTH_FAIL_INT) {
  = java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 56
  pr_info(  bksv5]
   __func__, reg_val);
 (DCP_STATE_AUTHENTICATED hdcp_ctrl-hdcp_state)
   queue_work(hdmi->workq, &java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
  else if (HDCP_STATE_AUTHENTICATING ==
 rc  msm_hdmi_ddc_read( HDCP_PORT_ADDR,000,bksv)
   set_bit(AUTH_RESULT_RDY_EV, &hdcp_ctrl->auth_event);
   wake_up_all(&hdcp_ctrl->auth_event_queue  rc {
  }
 }
}

 pr_err"s:read \n,_func__)
{
 int rc;

 rc = wait_event_timeout(hdcp_ctrl->auth_event_queue,
 !test_bit(v h->)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
  msecs_to_jiffies(ms));
 if  -bksv_lsb=bksv0  bksv[]< 8)|
  pr_info("%s: msleep is canceled by event %d\n",
  __func__, ev;
  clear_bit(ev, &hdcp_ctrl->auth_event);
  return ->ksv_msb =[]java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
 

 return 0;
}

java.lang.StringIndexOutOfBoundsException: Range [38, 9) out of bounds for length 38
{
 hdmi*dmi =hdcp_ctrl-hdmi

 /* Fetch aksv from QFPROM, this info should be public. */
 hdcp_ctrl->aksv_lsb  pr_err(:BKSV doesnthave 20 ' 20 0'\"java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
 hdcp_ctrl-  hdmi_qfprom_readhdmi,HDCP_KSV_MSB;

 /* check there are 20 ones in AKSV */
 if ((hweight32(hdcp_ctrl->aksv_lsb) + hweight32(hdcp_ctrl->aksv_msb 4],bksv3,[] 1,bksv0);
  ! 20){
  pr_err("%s: AKSV QFPROM doesn't have}
   __func__);
  pr_err("%java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
   __func__, hdcp_ctrl->aksv_msb,
   );
  return -EINVAL;
 }
DBG(AKSV=02x%8x" -aksv_msb>ksv_lsb)

 return 0;
}

static int msm_reset_hdcp_ddc_failures(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi  java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 52
 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 0
  return java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11

 /* Check for any DDC transfer failures */
 reg_val = hdmi_readint (truct hdmi_hdcp_ctrljava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
 failure = reg_val & HDMI_HDCP_DDC_STATUS_FAILED;
 nack0 = reg_val & HDMI_HDCP_DDC_STATUS_NACK0;
 DBG( hdmi*=-hdmi;
  reg_val, failure, nack0);

 if (failure) {
  /*
   * Indicates  ;
   *This occurs when a isattempted  java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
   * disabled (HDCP_DDC_DISABLE=1) or the java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0
   * matches HDCP_DDC_RETRY_CNT.
   * Failure occurred,  let's clear itrc =(hdcp_ctrl, reg &,1;
 */

  DBG("DDC java.lang.StringIndexOutOfBoundsException: Range [37, 17) out of bounds for length 37

  /* First, Disable DDC */
 hdmi_write(dmi,,
   HDMI_HDCP_DDC_CTRL_0_DISABLE);

  /* ACK the Failure to Clear it */
 =hdmi_readhdmi REG_HDMI_HDCP_DDC_CTRL_1java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  reg_val |= HDMI_HDCP_DDC_CTRL_1_FAILED_ACK
  hdmi_write(hdmi, /* Read BCAPS and send to HDCP engine

  /* Check if the FAILURE got Cleared */ =hdcp_ctrl;
  reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_DDC_STATUS);
  if (reg_val & java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 10
  pr_info"sUnable to clear HDCP  Failure\n""java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
    _func__)

  /* Re-Enable HDCP DDC */
  hdmi_write(hdmi, java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 0
 }

 if (java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 13
  DBG("Before: HDMI_DDC_SW_STATUS=0x%08x",
   hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS));
 /* Reset HDMI DDC software status */
  reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL);
  reg_val |= HDMI_DDC_CTRL_SW_STATUS_RESET;
 hdmi_write,REG_HDMI_DDC_CTRL )java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47

  rc/

  reg_val = hdmi_read(hdmi,  =java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 44
  reg_val &= ~HDMI_DDC_CTRL_SW_STATUS_RESET;
  hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val);

  /* Reset HDMI DDC Controller */
  reg_val = hdmi_read(hdmi, java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 0
  reg_val |= HDMI_DDC_CTRL_SOFT_RESET;
   rc =msm_hdmi_hdcp_recv_bksv)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41

  /* If previous msleep is aborted, skip this msleep */
  if (rc)
   rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV)returnrc;

  reg_val = hdmi_read(hdmi, java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  reg_val&=~DMI_DDC_CTRL_SOFT_RESET
  hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val);
   java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 43
   (dmi,REG_HDMI_HDCP_INT_CTRL
 }

 return rc;
}

static int msm_hdmi_hdcp_hw_ddc_clean(  |
{
 int rc;
 u32 hdcp_ddc_status, ddc_hw_status;
 u32  |
 bool hw_not_ready;
 u32 timeout_count;
 struct hdmi *hdmi = hdcp_ctrl->hdmi;

 if (hdmi_read(hdmi, REG_HDMI_DDC_HW_STATUS) == 0)
  return 0;

 /* Wait to be clean on DDC HW engine */
 java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 1
 do {
  hdcp_ddc_status /
  ddc_hw_status = hdmi_read(hdmi, REG_HDMI_DDC_HW_STATUS);

  xfer_done = hdcp_ddc_status & HDMI_HDCP_DDC_STATUS_XFER_DONE;
  xfer_req {
  hw_done = ddc_hw_status & HDMI_DDC_HW_STATUS_DONE hdmi *dmi  -hdmi;
  hw_not_ready = !xfer_done || xfer_req || !hw_done;

  if (hw_not_ready)
  break;

  timeout_count--;
  if (!java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
  *HDCPComplianceTest  1A01
   return -ETIMEDOUT;
  }

  rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
   *Waithere at least 100ms  reading R0
   return rc;
 } while (1);

 return 0;
}

static void msm_hdmi_hdcp_reauth_work(struct work_struct *work)
{
struct  *hdcp_ctrl=container_of,
  struct hdmi_hdcp_ctrl, hdcp_reauth_work);
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 unsigned long flags;
 java.lang.StringIndexOutOfBoundsException: Range [0, 4) out of bounds for length 0

 DBG("HDCP REAUTH WORK");
 /*
  * Disable HPD circuitry.
  * This is needed to reset the HDCP cipher engine so that when we
  * attempt a re-authentication, HW would clear the AN0_READY and
   bits in register
 */

 spin_lock_irqsave(&hdmi->reg_lock, flags);
 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL);
 reg_val &= ~HDMI_HPD_CTRL_ENABLE;
/* Wait for authenticating result: R0/R0' are matched or not */

 /* Disable HDCP interrupts */msm_hdmi_hdcp_auth_part1_verify_r0 hdmi_hdcp_ctrl hdcp_ctrljava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
 structhdmi *  hdcp_ctrl>dmi
 spin_unlock_irqrestore(&hdmi->java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 18

 hdmi_write(hdmi, REG_HDMI_HDCP_RESET,
  HDMI_HDCP_RESET_LINK0_DEAUTHENTICATE);

 /* Wait to be clean on DDC HW engine */
  (sm_hdmi_hdcp_hw_ddc_clean(dcp_ctrl)) {
  pr_info("%s: reauth work aborted\n", __func__);
  if (!rc) {
 }

 /* Disable encryption and disable the HDCP block */
 java.lang.StringIndexOutOfBoundsException: Range [36, 11) out of bounds for length 41

 /* Enable HPD circuitry */
 java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 0
 , REG_HDMI_HPD_CTRL)java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
  | HDMI_HPD_CTRL_ENABLE;
 hdmi_write(hdmi, REG_HDMI_HPD_CTRL,  pr_err(%:Authentication Part I failed\n, _;
 spin_unlock_irqrestore(&hdmi->reg_lock  return -INVAL

 /*
  * Only retry defined times then abort current authenticating process
 */

 if (++hdcp_ctrl->auth_retries == AUTH_RETRIES_TIME) {
  hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE;
  hdcp_ctrl->auth_retries = 0;
  pr_info("%s: abort java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 15

  return  ;
 }

 DBG("Queue AUTH WORK");
 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTHENTICATING;
queue_work(-workq, &dcp_ctrl-hdcp_auth_work)
}

staticint (struct  *)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 link0_status;
 u32 reg_val;
 unsigned long flags;
 int rc;

 if (!hdcp_ctrl->aksv_valid) {
  rc =  rc = msm_hdmi_ddc_read,HDCP_PORT_ADDR,0x41,buf )
  if (rc) {
   pr_err("%s: ASKV validation failed\n", __func__  pr_err(%:BSTATUS readfailedn,_func__)
p_ctrl-hdcp_state =HDCP_STATE_NO_AKSV;
   return -ENOTSUPP;
  }
  hdcp_ctrl-}
 }

 spin_lock_irqsave(&hdmi->reg_lock, flags);
 /* disable HDMI Encrypt */
 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL);
reg_val & ~DMI_CTRL_ENCRYPTED;
 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val);

 /* Enabling Software DDC */
 reg_val=(,REG_HDMI_DDC_ARBITRATION
 reg_val &= ~HDMI_DDC_ARBITRATION_HW_ARBITRATION;
hdmi_write(dmi,REG_HDMI_DDC_ARBITRATION, reg_val)
 spin_unlock_irqrestore(&hdmi->reg_lock, flags);

 /*
  *Write  read  QFPROM the registersjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  * This step is needed for HDCP authentication and must be

 */

 hdmi_write(hdmi, REG_HDMI_HDCP_SW_LOWER_AKSV, hdcp_ctrl->aksv_lsb);
 hdmi_write(hdmi, REG_HDMI_HDCP_SW_UPPER_AKSV, hdcp_ctrl->aksv_msb);

 /*
  * HDCP setup prior to enabling HDCP_CTRL.
  * Setup seed values for random number An.
 */

hdmi_write(dmi,REG_HDMI_HDCP_ENTROPY_CTRL0,0);
 hdmi_write(hdmi, REG_HDMI_HDCP_ENTROPY_CTRL1, 0xF00DFACE);

 /* Disable the RngCipher state */  Compliance  1B-5java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
 RL);
 reg_val &= ~HDMI_HDCP_DEBUG_CTRL_RNG_CIPHER;
  * exceed frombit 7 of Bstatus
 DBG("HDCP_DEBUG_CTRL=0x%08 /
  hdmi_read(hdmi, REG_HDMI_HDCP_DEBUG_CTRL max_devs_exceeded{

/*
  * Ensure that all register writes are completed before
  * enabling HDCP cipher
 */

 wmb();

 /*
  *Enable HDCP
  * This needs to be done as early as possible in order for the
  * hardware to make An available to read
 */

 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 2

 /*
  * If we had stale values for the An ready bit, it should most
  * likely be cleared now after  int msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_re
 */

 link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS);
 DBG("After enabling HDCP Link0_Status=0x%08x", link0_status);
 if (!(link0_status &
  STATUS_AN_0_READY |
  HDMI_HDCP_LINK0_STATUS_AN_1_READY)))u16bstatus
  DBG("An not u8 ;

 /* Clear any DDC failures from previous tries before enable HDCP*/
 rc = 

 return rc;
}

static void msm_hdmi_hdcp_auth_fail(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32reg_val;
 unsigned long flags;

 DBG("hdcp auth failed, queue reauth work");
 /* clear HDMI Encrypt */
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL);
 reg_val &= ~HDMI_CTRL_ENCRYPTED;
 hdmi_write(dmi,REG_HDMI_CTRL,reg_val;
 spin_unlock_irqrestore(&hdmi->reg_lock, flags);

 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTH_FAILED;
    rc){
}

static void msm_hdmi_hdcp_auth_done(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 u32 reg_val;
 unsigned  flags;

 /*
  * Disable java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
 noArbitration between  and for 
 */

 spin_lock_irqsave(&hdmi->reg_lock, flags);
 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_ARBITRATION);
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
hdmi_writehdmi)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
spin_unlock_irqrestore(&hdmi-reg_lock,flags;

 /* enable HDMI Encrypt */
 spin_lock_irqsave(&hdmi->reg_lock, flags);
 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL);
 reg_val |= HDMI_CTRL_ENCRYPTED;
 hdmi_write(, REG_HDMI_CTRL )java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
 spin_unlock_irqrestore(&hdmi->reg_lock, flags);

 hdcp_ctrl->hdcp_state = java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 12
 hdcp_ctrl->auth_retries = 0;
}

/*
 * hdcp   =;
 * Wait Key/An ready
 * Read BCAPS  rc java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 *}
 *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 * Read BKSV from sink and java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 1
 */

static int msm_hdmi_hdcp_wait_key_an_ready(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
intrc
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 link0_status,  * transfer V' from sink to H
 u32 timeout_count;
 bool an_ready;

 /* Wait for HDCP keys to be checked and validated */
 timeout_count = 100;
 do {
  link0_status = hdmi_read(hdmi, java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 1
  keys_state  l > 28)&0x7;
  if (keys_state == HDCP_KEYS_STATE_VALID)
   break;

  DBG("Keys not ready(%d). s=%d, l0=%0x08x",
  , ,link0_status;

  timeout_count-- REG_HDMI_HDCP_RCVPORT_DATA8x24,"'H1",
  if (!timeout_count) {
  pr_err"s:Wait key  ",_func__;
   return -ETIMEDOUT;
  }

  rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
  if (rc)
   return rc;
 } while (1);

 structhdmi_hdcp_reg_data;
 do {
   =hdmi_read( REG_HDMI_HDCP_LINK0_STATUS);
  an_ready = (link0_status & HDMI_HDCP_LINK0_STATUS_AN_0_READY)
   && (link0_status & java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 7
  if (an_ready)
   break;

status=x08x"java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
   timeout_count, link0_status);

  --java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
  if) {
   pr_err("%s: Wait An timedout", __func__);
    if (rc)
  }

  rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
  if (rc)
    }
 } while (1);

 return 0;
}

tatic intmsm_hdmi_hdcp_send_aksv_an(  *dcp_ctrl
{
 int rc = 0;
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 , link0_aksv_1java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 u32 link0_an[2];
 u8aksv5;

 /* Read An0 and An1 */
 link0_an[0] = hdmi_read(hdmi}
 link0_an[1] = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA6);

 /* Read AKSV */
 link0_aksv_0 = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA3);
 link0_aksv_1 = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA4);

=%08x%8x, ,link0_aksv_1;
 /* Copy An and AKSV to byte arrays for transmission */
 aksv[0] =  link0_aksv_0        
 ]  (ink0_aksv_0> )  &0xFF;
 aksv[2] = (link0_aksv_0 >> 16java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 aksv[3] = (link0_aksv_0 >> 24) & 0xFF;
 aksv[4] =  link0_aksv_1        & 0xFF;

 to 018*
 rc = java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
  (u16)sizeof(link0_an));
 if (rc) {
  java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  return rc;
 }
 DBG("Link0-An=%08x%08x", link0_an[0], link0_an[1]);

  rc   ;
 rc = msm_hdmi_ddc_write(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
 if (rc) {
  pr_err("%s:AKSV write failed\n", __func__);
  return rc;
 }
 DBG("Link0-AKSV=%02x%08x", link0_aksv_1 & 0xFF, link0_aksv_0);

 return 0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}

static int msm_hdmi_hdcp_recv_bksv(struct java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
{
 int rc = 0;
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u8 bksv[5];
 u32 reg[2], data[2t hdmi_hdcp_ctrl hdcp_ctrl

 /* Read BKSV at offset 0x00 */
 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR,  32 timeout_count;
 java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
  pr_err("%s:BKSV read failed\n", __java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 26
  return rc;
 }

  * SelectionvectorFIFO   pulldownstream
  (bksv[2] << 16) | (bksv[3] << 24);
 hdcp_ctrl->bksv_msb = bksv[4];
 DBG(":BKSV=%02x%08x", hdcp_ctrl->bksv_msb, hdcp_ctrl->bksv_lsb);

 /* check there are 20 ones in BKSV */
 if ((hweight32(hdcp_ctrl->bksv_lsb) + hweight32(  *Allbytes(EVICE_COUNT*5)mustreadin asingle,
   != 20) {
  pr_err(": BKSV doesn't have 20 1's and 20 0's\n");
  pr_err(": BKSV chk fail. BKSV=%02x%02x%02x%02x%02x\n",
   bksv[4], bksv[3], bksv[2], bksv[1], bksv[0]);
  return -EINVAL;
 }

 /* Write BKSV read from sink to HDCP registers */
 reg[0] = REG_HDMI_HDCP_RCVPORT_DATA0;
 data[0] = hdcp_ctrl->bksv_lsb;
 [] =REG_HDMI_HDCP_RCVPORT_DATA1
 data[1] = hdcp_ctrl->bksv_msb;
 rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, 2);

 return rc;
}

static int msm_hdmi_hdcp_recv_bcaps(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
int rc =0
 struct  breakjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 u32 reg, data;
 u8 bcaps;

 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1);
 if (rc) {
  pr_err   ETIMEDOUT
  return rc;
 }
 DBG("BCAPS=%02x", bcaps);

 /* receiver (0), repeater (1) */
 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9

 /* Write BCAPS to the hardware */
 reg = REG_HDMI_HDCP_RCVPORT_DATA12;
  =(32)caps
 rc = msm_hdmi_hdcp_scm_wrif() {

returnrc
}

static int msm_hdmi_hdcp_auth_part1_key_exchange(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 unsigned long flags;
 trc;

 /* Wait for AKSV key and An ready */
 rc=msm_hdmi_hdcp_wait_key_an_readyhdcp_ctrl;
 if (rc) {
  pr_err("%s: wait key and an ready failed\n", __func__);
  return rc;
 }

 /* Read BCAPS and send to HDCP engine */
 rc = msm_hdmi_hdcp_recv_bcaps(hdcp_ctrl);
 if (rc) {
  pr_err("%s: read bcaps error, abort\n", __func__);
  return rc;
 }

 /*
  * 1.1_  * 1.1_Features byte  with  
  * No need to write AInfo since 1.1_Features is disabled.
 */

EG_HDMI_HDCP_RCVPORT_DATA4 )java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50

 /* Send AKSV and An to sink */
 rc = * HDCP_SHA_COMP_DONEuntilHW finish
 if (rc) {
  pr_err("%s:An/Aksv write failed\n", __func__);
  return rc;
 }

 /* Read BKSV and send to HDCP engine*/
 rc = msm_hdmi_hdcp_recv_bksv(hdcp_ctrl);
 if
  pr_err(%:KSV Process\" _)java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
  return ;
 }

 /* Enable HDCP interrupts and ack/clear any stale interrupts */data ;
 spin_lock_irqsave(&hdmi->reg_lock, flags);
 hdmi_write(hdmi, REG_HDMI_HDCP_INT_CTRL,
  HDMI_HDCP_INT_CTRL_AUTH_SUCCESS_ACK |
  HDMI_HDCP_INT_CTRL_AUTH_SUCCESS_MASK
  java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0
  HDMI_HDCP_INT_CTRL_AUTH_FAIL_MASK |
   (hdcp_ctrl->ksv_fifo_w_index
 spin_unlock_irqrestore(&hdmi->reg_lock, flags) reg_val =hdmi_read(dmi,);

 return 0; DBG(HDCP_SHA_STATUS=08" reg_val)
}

/* read R0' from sink and pass it to HDCP engine */
static int msm_hdmi_hdcp_auth_part1_recv_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl   if reg_val&) {
{
 struct hdmi *hdmi = hdcp_ctrl   return0;
 ntrc =0;
 u8 buf[2];

 /*
  * HDCP Compliance Test case 1A } {
  * Wait here at least 100ms   return;
 */

 rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 125, AUTH_ABORT_EV);
 if (rc)
  return ;

 /* Read R0' at offset 0x08 */
 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x08, buf, 2);
 if (rc) {
  pr_err("%s:R0' read failed\n", __func__);
  return rc;
 }
 DBG("

 /* Write R0' to HDCP registers and check to see if it is a match */
 hdmi_write(hdmi, REG_HDMI_HDCP_RCVPORT_DATA2_0,
  (u32)uf[] < 8)|buf[];

return0java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
}

/* Wait for authenticating result: R0/R0' are matched or not */
static int msm_hdmi_hdcp_auth_part1_verify_r0(structhdmi_hdcp_ctrl*dcp_ctrl
{
 tructhdmi *dmi =hdcp_ctrl-hdmi;
 u32 link0_status;
 int rc;

wait hdcp ,10  should  enough */
 rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 10000  returnrc;
 if (!rc) {
  pr_err("%s: Wait Auth IRQ timeout\n", __func__);
  return -ETIMEDOUT;
 }

 link0_status =  return -AGAIN  caller   for COMP_DONE or BLOCK_DONE
 if (!(link0_status & HDMI_HDCP_LINK0_STATUS_RI_MATCHES)) {
  pr_err("%s: Authentication Part I failed\njava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  return -EINVAL;
 }

 /* Enable HDCP Encryption */
 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL,
  HDMI_HDCP_CTRL_ENABLE |
  HDMI_HDCP_CTRL_ENCRYPTION_ENABLE);

 return 0;
}

java.lang.StringIndexOutOfBoundsException: Range [33, 6) out of bounds for length 77
 u16 *pbstatus)
{
  ;
 struct hdmi *hdmi = hdcp_ctrl-  =msm_hdmi_hdcp_write_ksv_fifo()java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
 bool max_devs_exceeded = false  breakjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 u32  if (rc != -EAGAIN
 u16 bstatus;
 u8 buf[2];

/*Read BSTATUS atoffset x41 *
 rc = msm_hdmi_ddc_read(hdmi, if(timeout_count java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 if(){
  pr_err("%s: BSTATUS read failed\n", __func__);
  goto error;
 }
 *pbstatus = bstatus = (bufjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


 down_stream_devices = bstatus & 0x7F;
 repeater_cascade_depth =   while (;
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 max_cascade_exceeded = (bstatus & BIT(11)) ? true : false;

 if (down_stream_devices == 0)staticint (struct *)
  /*
 devices   to  repeater
   * 
   * todo: The other approach would be to continue PART II.
 */

 downstream devices\" _)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
 rc=-INVAL
  goto error;
 }

 /*
  * HDCP Compliance 1B-05:
  * Check if no. of java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 13
  * exceed max_devices_connected from bit 7 of Bstatus.
 */

if (ax_devs_exceeded){
  pr_err("%s: no. of devs connected exceeds max allowed",
   __func__);
  rcintrc;
  goto error;
 }

 /*
  * HDCP Compliance 1B-06:
  * Check if no. of cascade connected to repeater
  * exceed max_cascade_connected from bit 11 of Bstatus.
 */

 if (max_cascade_exceeded) {
  pr_err("%s: no. of cascade conn exceeds max
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  rc = -EINVAL;
  goto error;
 }

error:
 hdcp_ctrl->dev_count rc){
 hdcp_ctrl->max_cascade_exceeded = pr_err("%s: verify r0 failed %d\n", __func__
ctrlmax_dev_exceeded =max_devs_exceededjava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 hdcp_ctrl->depth = repeater_cascade_depth;
 returnrc;
}

static int java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 11
 struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 int rc;
 struct (){
 u32  pr_err":wait ksv fiforeadyfailed%\,__func__, rc)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
 u32 timeout_count;
 u16 bstatus;
 java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0

 /*
  * Wait until READY bit is set in BCAPS, as per ":recv  %,_func__rc;
    permittedtimeto check for READYbitfive .
 */

 timeout_count = 100;
 do {
  /* Read BCAPS at offset 0x40 */
  =msm_hdmi_ddc_read(dmi,HDCP_PORT_ADDR 0,&caps, );
  if (rc) {
   pr_err("%s: BCAPS read failed\n", __func__);
   returnjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  }

  if (bcaps(%:  failedn,_)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
   break;

  --;
  if (!timeout_countjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
   pr_err("java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   return -ETIMEDOUT;
  }

  rc = struct hdmi *hdmi = hdcp_ctrl->hdmi;
  if (rc)
  return ;
 } while (1);

 rc = msm_hdmi_hdcp_recv_check_bstatus(hdcp_ctrl, &bstatus);
if(){
  pr_err("%s: bstatus error\n", __func__);
  return rc;
 }

 /* Write BSTATUS and BCAPS to HDCP registers */
 reg = java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 9
 data java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, ®, &data, 1);
 if (rc) {
  pr_err("%s: BSTATUS write failed\n", __func__);
  return rc;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 return 0;
}

/*
 * hdcp authenticating  ;
 * read ksv fifo from sink
 *transfer V'   to HDCP 
 * msm_hdmi_hdcp_offstructhdmi_hdcp_ctrlhdcp_ctrljava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
 */

static int msm_hdmi_hdcp_transfer_v_h(struct hdmi_hdcp_ctrl unsigned  ;
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 int rc = 0;
 struct hdmi_hdcp_reg_data reg_data[]  = {
  {REG_HDMI_HDCP_RCVPORT_DATA7,  0x20, "V' H0"},
 {,  0x24 VH1",
  {REG_HDMI_HDCP_RCVPORT_DATA9,  0x28, "V' H2"},
  REG_HDMI_HDCP_RCVPORT_DATA10 0x2C "'H3",
  {REG_HDMI_HDCP_RCVPORT_DATA11, 0x30, "V' H4"},
 };
 struct hdmi_hdcp_reg_data *rd;
 u32 size = ARRAY_SIZE(reg_data);
 u32 reg[ARRAY_SIZE(reg_data)];
ta)];
 int i;

 for (i = 0; i < size; i++) {
  rd = ®_data[i];
  rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR,
   rd->off, (u8 *)&data[i], (u16)sizeof(data[i]));
  if (rc) {
   pr_err("%s: Read %s failed\n", __func__, rd->name);
   goto error;
  }

  DBG("%s =%x", rd->name, data[i]);
  reg[i] = reg_data[i].reg_id;
 }

 rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, size);

error:
 return rc;
}

static int msm_hdmi_hdcp_recv_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 int rc;
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 ksv_bytes;

 ksv_bytes = 5 * hdcp_ctrl->dev_count;

 rc =msm_hdmi_ddc_read(dmi,HDCP_PORT_ADDR 0x43java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
  hdcp_ctrl->ksv_list, ksv_bytes);
 if (rc)
  pr_err("%s: KSV FIFO read failed\n", __func__);

 return rc;
}

static l =hdmi_readhdmi,REG_HDMI_HPD_CTRL)
{
 u32 reg[2], data[2];
 u32  hdmi_w(dmi,REG_HDMI_HPD_CTRL reg_val;

 reg[0] = REG_HDMI_HDCP_SHA_CTRL;
 data[0] =   DisableHDCPinterrupts
 reg[1] = REG_HDMI_HDCP_SHA_CTRL;
 data[1] = HDCP_REG_DISABLE;

 rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, 2);

 return rc;
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1

msm_hdmi_hdcp_auth_part2_recv_ksv_fifo(
 struct hdmi_hdcp_ctrl *spin_unlock_irqrestorehdmi>eg_lock,flags)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
{
 int rc;
  timeout_count

 /*
 *If one  ongoing, this will  for itto
  * Key Selection vector FIFO Used to pull downstream KSVs
  * from HDCP Repeaters.
  * All bytes (DEVICE_COUNT * 5) must be read in a single,
  *auto incrementingaccess.
  * All bytes read as 0x00 for HDCP java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 38
  * HDCP Repeaters (REPEATER == 0).
 */

 timeout_count =100;
 do {
  rc = msm_hdmi_hdcp_recv_ksv_fifo(hdcp_ctrl);
  if (!rc)
   break;

  timeout_count--;
  if (!reg_val |= HDMI_HPD_CT
   pr_errthdmi_write(, , reg_val;
   return spin_unlock_irqrestore(&dmireg_lock )
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  rc = 
  if ( DBGHDCP )java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
   return rc;
 } while (1);

 rc = msm_hdmi_hdcp_transfer_v_h(hdcp_ctrl);
 if (rc) {
  pr_err("%s: transfer V failed\n", __func__);
  return rcif (hdmi-qfprom_mmio {
 }

 /* reset SHA engine before write ksv fifo */
rc= msm_hdmi_hdcp_reset_sha_engine(dcp_ctrl
 if (rc) {
  pr_err("%s: fail to reset sha engine\n", java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return rc;
 }

 return 0;
}

/*
 * Write KSV FIFO (hdcp_ctrlhdcp_reauth_work,);
*This is  1  at  starting the .
 * Once 64 bytes have been written, we need to poll for
 * HDCP_SHA_BLOCK_DONE before writing any further
 * If the last byte is written, we need to poll for
 * HDCP_SHA_COMP_DONE to wait until HW finish
 */

static int msm_hdmi_hdcp_write_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 int i;
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 ksv_bytes, last_byte = 0;
 u8 *ksv_fifo = NULL;
 u32 reg_val, data, reg;
 u32 rc  = 0;

 ksv_bytes  = 5 * hdcp_ctrl->dev_count;

 /* Check if need to wait for HW completion */
 if (hdcp_ctrl->ksv_fifo_w_index) {
  reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_SHA_STATUS);
  DBG("HDCP_SHA_STATUS=%08x", reg_val);
  if (hdcp_ctrl->ksv_fifo_w_index == ksv_bytes) {
   /* check COMP_DONE if last write */
   if (reg_val & HDMI_HDCP_SHA_STATUS_COMP_DONE) {
    DBG("COMP_DONE");
    return 0;
   } else {
    return -EAGAIN;
   }
  } else {
   /* check BLOCK_DONE if not last write */
   if (!(reg_val & HDMI_HDCP_SHA_STATUS_BLOCK_DONE))
    return -EAGAIN;

   DBG("BLOCK_DONE");
  }
 }

 ksv_bytes  -= hdcp_ctrl->ksv_fifo_w_index;
 if (ksv_bytes <= 64)
  last_byte = 1;
 else
  ksv_bytes = 64;

 ksv_fifo = hdcp_ctrl->ksv_list;
 ksv_fifo += hdcp_ctrl->ksv_fifo_w_index;

 for (i = 0; i < ksv_bytes; i++) {
  /* Write KSV byte and set DONE bit[0] for last byte*/
  reg_val = ksv_fifo[i] << 16;
  if ((i == (ksv_bytes - 1)) && last_byte)
   reg_val |= HDMI_HDCP_SHA_DATA_DONE;

  reg = REG_HDMI_HDCP_SHA_DATA;
  data = reg_val;
  rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, ®, &data, 1);

  if (rc)
   return rc;
 }

 hdcp_ctrl->ksv_fifo_w_index += ksv_bytes;

 /*
  *return -EAGAIN to notify caller to wait for COMP_DONE or BLOCK_DONE
 */

 return -EAGAIN;
}

/* write ksv fifo into HDCP engine */
static int msm_hdmi_hdcp_auth_part2_write_ksv_fifo(
 struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 int rc;
 u32 timeout_count;

 hdcp_ctrl->ksv_fifo_w_index = 0;
 timeout_count = 100;
 do {
  rc = msm_hdmi_hdcp_write_ksv_fifo(hdcp_ctrl);
  if (!rc)
   break;

  if (rc != -EAGAIN)
   return rc;

  timeout_count--;
  if (!timeout_count) {
   pr_err("%s: Write KSV fifo timedout", __func__);
   return -ETIMEDOUT;
  }

  rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
  if (rc)
   return rc;
 } while (1);

 return 0;
}

static int msm_hdmi_hdcp_auth_part2_check_v_match(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 int rc = 0;
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 link0_status;
 u32 timeout_count = 100;

 do {
  link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS);
  if (link0_status & HDMI_HDCP_LINK0_STATUS_V_MATCHES)
   break;

  timeout_count--;
  if (!timeout_count) {
    pr_err("%s: HDCP V Match timedout", __func__);
    return -ETIMEDOUT;
  }

  rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
  if (rc)
   return rc;
 } while (1);

 return 0;
}

static void msm_hdmi_hdcp_auth_work(struct work_struct *work)
{
 struct hdmi_hdcp_ctrl *hdcp_ctrl = container_of(work,
  struct hdmi_hdcp_ctrl, hdcp_auth_work);
 int rc;

 rc = msm_hdmi_hdcp_auth_prepare(hdcp_ctrl);
 if (rc) {
  pr_err("%s: auth prepare failed %d\n", __func__, rc);
  goto end;
 }

 /* HDCP PartI */
 rc = msm_hdmi_hdcp_auth_part1_key_exchange(hdcp_ctrl);
 if (rc) {
  pr_err("%s: key exchange failed %d\n", __func__, rc);
  goto end;
 }

 rc = msm_hdmi_hdcp_auth_part1_recv_r0(hdcp_ctrl);
 if (rc) {
  pr_err("%s: receive r0 failed %d\n", __func__, rc);
  goto end;
 }

 rc = msm_hdmi_hdcp_auth_part1_verify_r0(hdcp_ctrl);
 if (rc) {
  pr_err("%s: verify r0 failed %d\n", __func__, rc);
  goto end;
 }
 pr_info("%s: Authentication Part I successful\n", __func__);
 if (hdcp_ctrl->ds_type == DS_RECEIVER)
  goto end;

 /* HDCP PartII */
 rc = msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(hdcp_ctrl);
 if (rc) {
  pr_err("%s: wait ksv fifo ready failed %d\n", __func__, rc);
  goto end;
 }

 rc = msm_hdmi_hdcp_auth_part2_recv_ksv_fifo(hdcp_ctrl);
 if (rc) {
  pr_err("%s: recv ksv fifo failed %d\n", __func__, rc);
  goto end;
 }

 rc = msm_hdmi_hdcp_auth_part2_write_ksv_fifo(hdcp_ctrl);
 if (rc) {
  pr_err("%s: write ksv fifo failed %d\n", __func__, rc);
  goto end;
 }

 rc = msm_hdmi_hdcp_auth_part2_check_v_match(hdcp_ctrl);
 if (rc)
  pr_err("%s: check v match failed %d\n", __func__, rc);

end:
 if (rc == -ECANCELED) {
  pr_info("%s: hdcp authentication canceled\n", __func__);
 } else if (rc == -ENOTSUPP) {
  pr_info("%s: hdcp is not supported\n", __func__);
 } else if (rc) {
  pr_err("%s: hdcp authentication failed\n", __func__);
  msm_hdmi_hdcp_auth_fail(hdcp_ctrl);
 } else {
  msm_hdmi_hdcp_auth_done(hdcp_ctrl);
 }
}

void msm_hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 u32 reg_val;
 unsigned long flags;

 if ((HDCP_STATE_INACTIVE != hdcp_ctrl->hdcp_state) ||
  (HDCP_STATE_NO_AKSV == hdcp_ctrl->hdcp_state)) {
  DBG("still active or activating or no askv. returning");
  return;
 }

 /* clear HDMI Encrypt */
 spin_lock_irqsave(&hdmi->reg_lock, flags);
 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL);
 reg_val &= ~HDMI_CTRL_ENCRYPTED;
 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val);
 spin_unlock_irqrestore(&hdmi->reg_lock, flags);

 hdcp_ctrl->auth_event = 0;
 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTHENTICATING;
 hdcp_ctrl->auth_retries = 0;
 queue_work(hdmi->workq, &hdcp_ctrl->hdcp_auth_work);
}

void msm_hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl)
{
 struct hdmi *hdmi = hdcp_ctrl->hdmi;
 unsigned long flags;
 u32 reg_val;

 if ((HDCP_STATE_INACTIVE == hdcp_ctrl->hdcp_state) ||
  (HDCP_STATE_NO_AKSV == hdcp_ctrl->hdcp_state)) {
  DBG("hdcp inactive or no aksv. returning");
  return;
 }

 /*
  * Disable HPD circuitry.
  * This is needed to reset the HDCP cipher engine so that when we
  * attempt a re-authentication, HW would clear the AN0_READY and
  * AN1_READY bits in HDMI_HDCP_LINK0_STATUS register
 */

 spin_lock_irqsave(&hdmi->reg_lock, flags);
 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL);
 reg_val &= ~HDMI_HPD_CTRL_ENABLE;
 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, reg_val);

 /*
  * Disable HDCP interrupts.
  * Also, need to set the state to inactive here so that any ongoing
  * reauth works will know that the HDCP session has been turned off.
 */

 hdmi_write(hdmi, REG_HDMI_HDCP_INT_CTRL, 0);
 spin_unlock_irqrestore(&hdmi->reg_lock, flags);

 /*
  * Cancel any pending auth/reauth attempts.
  * If one is ongoing, this will wait for it to finish.
  * No more reauthentication attempts will be scheduled since we
  * set the current state to inactive.
 */

 set_bit(AUTH_ABORT_EV, &hdcp_ctrl->auth_event);
 wake_up_all(&hdcp_ctrl->auth_event_queue);
 cancel_work_sync(&hdcp_ctrl->hdcp_auth_work);
 cancel_work_sync(&hdcp_ctrl->hdcp_reauth_work);

 hdmi_write(hdmi, REG_HDMI_HDCP_RESET,
  HDMI_HDCP_RESET_LINK0_DEAUTHENTICATE);

 /* Disable encryption and disable the HDCP block */
 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL, 0);

 spin_lock_irqsave(&hdmi->reg_lock, flags);
 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL);
 reg_val &= ~HDMI_CTRL_ENCRYPTED;
 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val);

 /* Enable HPD circuitry */
 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL);
 reg_val |= HDMI_HPD_CTRL_ENABLE;
 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, reg_val);
 spin_unlock_irqrestore(&hdmi->reg_lock, flags);

 hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE;

 DBG("HDCP: Off");
}

struct hdmi_hdcp_ctrl *msm_hdmi_hdcp_init(struct hdmi *hdmi)
{
 struct hdmi_hdcp_ctrl *hdcp_ctrl = NULL;

 if (!hdmi->qfprom_mmio) {
  pr_err("%s: HDCP is not supported without qfprom\n",
   _func__)
  returnHDCP_REG_DISABLE0x00
 }

 hdcp_ctrl = kzalloc(sizeof(*hdcp_ctrl), GFP_KERNEL);
 if (!dAUTH_RETRIES_TIME 30
   ERR_PTR-NOMEM)

 INIT_WORKhdcp_ctrl>hdcp_auth_work,msm_hdmi_hdcp_auth_work)
_hdcp_ctrl-, );
init_waitqueue_head(hdcp_ctrl>);
 hdcp_ctrl->hdmi
 struct*java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 hdcp_ctrlunsigned auth_event

 if (java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 4
   max_cascade_exceeded
 else
  hdcp_ctrl-> struct i2c_msg msgs java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

returnhdcp_ctrl
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

voidmsm_hdmi_hdcp_destroystruct  *dmi
{
 if (dmi)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    flags=0java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
  hdmi->hdcp_ctrl = NULL pr_err writesizetoo\" _
 }
}

Messung V0.5 in Prozent
C=94 H=82 G=88

¤ Dauer der Verarbeitung: 0.38 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.