Lines Matching +full:hdmi +full:- +full:in
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2010-2015, The Linux Foundation. All rights reserved.
5 #include "hdmi.h"
21 /* QFPROM Registers for HDMI/HDCP */
49 struct hdmi *hdmi; member
78 static int msm_hdmi_ddc_read(struct hdmi *hdmi, u16 addr, u8 offset, in msm_hdmi_ddc_read() argument
99 rc = i2c_transfer(hdmi->i2c, msgs, 2); in msm_hdmi_ddc_read()
101 retry--; in msm_hdmi_ddc_read()
107 rc = -EIO; in msm_hdmi_ddc_read()
116 static int msm_hdmi_ddc_write(struct hdmi *hdmi, u16 addr, u8 offset, in msm_hdmi_ddc_write() argument
131 if (data_len > (HDCP_DDC_WRITE_MAX_BYTE_NUM - 1)) { in msm_hdmi_ddc_write()
133 return -ERANGE; in msm_hdmi_ddc_write()
141 rc = i2c_transfer(hdmi->i2c, msgs, 1); in msm_hdmi_ddc_write()
143 retry--; in msm_hdmi_ddc_write()
149 rc = -EIO; in msm_hdmi_ddc_write()
159 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_scm_wr() local
166 if (hdcp_ctrl->tz_hdcp) { in msm_hdmi_hdcp_scm_wr()
167 phy_addr = (u32)hdmi->mmio_phy_addr; in msm_hdmi_hdcp_scm_wr()
182 ret = -EINVAL; in msm_hdmi_hdcp_scm_wr()
186 count -= i; in msm_hdmi_hdcp_scm_wr()
190 hdmi_write(hdmi, preg[i], pdata[i]); in msm_hdmi_hdcp_scm_wr()
198 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_irq() local
202 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_irq()
203 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_INT_CTRL); in msm_hdmi_hdcp_irq()
206 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_irq()
214 hdmi_write(hdmi, REG_HDMI_HDCP_INT_CTRL, reg_val); in msm_hdmi_hdcp_irq()
215 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_irq()
221 if (HDCP_STATE_AUTHENTICATING == hdcp_ctrl->hdcp_state) { in msm_hdmi_hdcp_irq()
222 set_bit(AUTH_RESULT_RDY_EV, &hdcp_ctrl->auth_event); in msm_hdmi_hdcp_irq()
223 wake_up_all(&hdcp_ctrl->auth_event_queue); in msm_hdmi_hdcp_irq()
228 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS); in msm_hdmi_hdcp_irq()
231 if (HDCP_STATE_AUTHENTICATED == hdcp_ctrl->hdcp_state) in msm_hdmi_hdcp_irq()
232 queue_work(hdmi->workq, &hdcp_ctrl->hdcp_reauth_work); in msm_hdmi_hdcp_irq()
234 hdcp_ctrl->hdcp_state) { in msm_hdmi_hdcp_irq()
235 set_bit(AUTH_RESULT_RDY_EV, &hdcp_ctrl->auth_event); in msm_hdmi_hdcp_irq()
236 wake_up_all(&hdcp_ctrl->auth_event_queue); in msm_hdmi_hdcp_irq()
245 rc = wait_event_timeout(hdcp_ctrl->auth_event_queue, in msm_hdmi_hdcp_msleep()
246 !!test_bit(ev, &hdcp_ctrl->auth_event), in msm_hdmi_hdcp_msleep()
251 clear_bit(ev, &hdcp_ctrl->auth_event); in msm_hdmi_hdcp_msleep()
252 return -ECANCELED; in msm_hdmi_hdcp_msleep()
260 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_read_validate_aksv() local
263 hdcp_ctrl->aksv_lsb = hdmi_qfprom_read(hdmi, HDCP_KSV_LSB); in msm_hdmi_hdcp_read_validate_aksv()
264 hdcp_ctrl->aksv_msb = hdmi_qfprom_read(hdmi, HDCP_KSV_MSB); in msm_hdmi_hdcp_read_validate_aksv()
266 /* check there are 20 ones in AKSV */ in msm_hdmi_hdcp_read_validate_aksv()
267 if ((hweight32(hdcp_ctrl->aksv_lsb) + hweight32(hdcp_ctrl->aksv_msb)) in msm_hdmi_hdcp_read_validate_aksv()
272 __func__, hdcp_ctrl->aksv_msb, in msm_hdmi_hdcp_read_validate_aksv()
273 hdcp_ctrl->aksv_lsb); in msm_hdmi_hdcp_read_validate_aksv()
274 return -EINVAL; in msm_hdmi_hdcp_read_validate_aksv()
276 DBG("AKSV=%02x%08x", hdcp_ctrl->aksv_msb, hdcp_ctrl->aksv_lsb); in msm_hdmi_hdcp_read_validate_aksv()
283 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_reset_hdcp_ddc_failures() local
288 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_DDC_STATUS); in msm_reset_hdcp_ddc_failures()
305 hdmi_write(hdmi, REG_HDMI_HDCP_DDC_CTRL_0, in msm_reset_hdcp_ddc_failures()
309 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_DDC_CTRL_1); in msm_reset_hdcp_ddc_failures()
311 hdmi_write(hdmi, REG_HDMI_HDCP_DDC_CTRL_1, reg_val); in msm_reset_hdcp_ddc_failures()
314 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_DDC_STATUS); in msm_reset_hdcp_ddc_failures()
319 /* Re-Enable HDCP DDC */ in msm_reset_hdcp_ddc_failures()
320 hdmi_write(hdmi, REG_HDMI_HDCP_DDC_CTRL_0, 0); in msm_reset_hdcp_ddc_failures()
325 hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS)); in msm_reset_hdcp_ddc_failures()
326 /* Reset HDMI DDC software status */ in msm_reset_hdcp_ddc_failures()
327 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL); in msm_reset_hdcp_ddc_failures()
329 hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val); in msm_reset_hdcp_ddc_failures()
333 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL); in msm_reset_hdcp_ddc_failures()
335 hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val); in msm_reset_hdcp_ddc_failures()
337 /* Reset HDMI DDC Controller */ in msm_reset_hdcp_ddc_failures()
338 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL); in msm_reset_hdcp_ddc_failures()
340 hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val); in msm_reset_hdcp_ddc_failures()
346 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL); in msm_reset_hdcp_ddc_failures()
348 hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val); in msm_reset_hdcp_ddc_failures()
350 hdmi_read(hdmi, REG_HDMI_DDC_SW_STATUS)); in msm_reset_hdcp_ddc_failures()
363 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_hw_ddc_clean() local
365 if (hdmi_read(hdmi, REG_HDMI_DDC_HW_STATUS) == 0) in msm_hdmi_hdcp_hw_ddc_clean()
371 hdcp_ddc_status = hdmi_read(hdmi, REG_HDMI_HDCP_DDC_STATUS); in msm_hdmi_hdcp_hw_ddc_clean()
372 ddc_hw_status = hdmi_read(hdmi, REG_HDMI_DDC_HW_STATUS); in msm_hdmi_hdcp_hw_ddc_clean()
382 timeout_count--; in msm_hdmi_hdcp_hw_ddc_clean()
385 return -ETIMEDOUT; in msm_hdmi_hdcp_hw_ddc_clean()
400 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_reauth_work() local
408 * attempt a re-authentication, HW would clear the AN0_READY and in msm_hdmi_hdcp_reauth_work()
409 * AN1_READY bits in HDMI_HDCP_LINK0_STATUS register in msm_hdmi_hdcp_reauth_work()
411 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_reauth_work()
412 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL); in msm_hdmi_hdcp_reauth_work()
414 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, reg_val); in msm_hdmi_hdcp_reauth_work()
417 hdmi_write(hdmi, REG_HDMI_HDCP_INT_CTRL, 0); in msm_hdmi_hdcp_reauth_work()
418 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_reauth_work()
420 hdmi_write(hdmi, REG_HDMI_HDCP_RESET, in msm_hdmi_hdcp_reauth_work()
430 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL, 0); in msm_hdmi_hdcp_reauth_work()
433 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_reauth_work()
434 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL); in msm_hdmi_hdcp_reauth_work()
436 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, reg_val); in msm_hdmi_hdcp_reauth_work()
437 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_reauth_work()
442 if (++hdcp_ctrl->auth_retries == AUTH_RETRIES_TIME) { in msm_hdmi_hdcp_reauth_work()
443 hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE; in msm_hdmi_hdcp_reauth_work()
444 hdcp_ctrl->auth_retries = 0; in msm_hdmi_hdcp_reauth_work()
451 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTHENTICATING; in msm_hdmi_hdcp_reauth_work()
452 queue_work(hdmi->workq, &hdcp_ctrl->hdcp_auth_work); in msm_hdmi_hdcp_reauth_work()
457 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_prepare() local
463 if (!hdcp_ctrl->aksv_valid) { in msm_hdmi_hdcp_auth_prepare()
467 hdcp_ctrl->hdcp_state = HDCP_STATE_NO_AKSV; in msm_hdmi_hdcp_auth_prepare()
468 return -ENOTSUPP; in msm_hdmi_hdcp_auth_prepare()
470 hdcp_ctrl->aksv_valid = true; in msm_hdmi_hdcp_auth_prepare()
473 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_prepare()
474 /* disable HDMI Encrypt */ in msm_hdmi_hdcp_auth_prepare()
475 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_hdcp_auth_prepare()
477 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val); in msm_hdmi_hdcp_auth_prepare()
480 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_ARBITRATION); in msm_hdmi_hdcp_auth_prepare()
482 hdmi_write(hdmi, REG_HDMI_DDC_ARBITRATION, reg_val); in msm_hdmi_hdcp_auth_prepare()
483 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_prepare()
490 hdmi_write(hdmi, REG_HDMI_HDCP_SW_LOWER_AKSV, hdcp_ctrl->aksv_lsb); in msm_hdmi_hdcp_auth_prepare()
491 hdmi_write(hdmi, REG_HDMI_HDCP_SW_UPPER_AKSV, hdcp_ctrl->aksv_msb); in msm_hdmi_hdcp_auth_prepare()
497 hdmi_write(hdmi, REG_HDMI_HDCP_ENTROPY_CTRL0, 0xB1FFB0FF); in msm_hdmi_hdcp_auth_prepare()
498 hdmi_write(hdmi, REG_HDMI_HDCP_ENTROPY_CTRL1, 0xF00DFACE); in msm_hdmi_hdcp_auth_prepare()
501 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_DEBUG_CTRL); in msm_hdmi_hdcp_auth_prepare()
503 hdmi_write(hdmi, REG_HDMI_HDCP_DEBUG_CTRL, reg_val); in msm_hdmi_hdcp_auth_prepare()
505 hdmi_read(hdmi, REG_HDMI_HDCP_DEBUG_CTRL)); in msm_hdmi_hdcp_auth_prepare()
515 * This needs to be done as early as possible in order for the in msm_hdmi_hdcp_auth_prepare()
518 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL, HDMI_HDCP_CTRL_ENABLE); in msm_hdmi_hdcp_auth_prepare()
524 link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS); in msm_hdmi_hdcp_auth_prepare()
539 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_fail() local
544 /* clear HDMI Encrypt */ in msm_hdmi_hdcp_auth_fail()
545 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_fail()
546 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_hdcp_auth_fail()
548 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val); in msm_hdmi_hdcp_auth_fail()
549 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_fail()
551 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTH_FAILED; in msm_hdmi_hdcp_auth_fail()
552 queue_work(hdmi->workq, &hdcp_ctrl->hdcp_reauth_work); in msm_hdmi_hdcp_auth_fail()
557 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_done() local
565 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_done()
566 reg_val = hdmi_read(hdmi, REG_HDMI_DDC_ARBITRATION); in msm_hdmi_hdcp_auth_done()
568 hdmi_write(hdmi, REG_HDMI_DDC_ARBITRATION, reg_val); in msm_hdmi_hdcp_auth_done()
569 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_done()
571 /* enable HDMI Encrypt */ in msm_hdmi_hdcp_auth_done()
572 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_done()
573 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_hdcp_auth_done()
575 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val); in msm_hdmi_hdcp_auth_done()
576 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_done()
578 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTHENTICATED; in msm_hdmi_hdcp_auth_done()
579 hdcp_ctrl->auth_retries = 0; in msm_hdmi_hdcp_auth_done()
593 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_wait_key_an_ready() local
601 link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS); in msm_hdmi_hdcp_wait_key_an_ready()
609 timeout_count--; in msm_hdmi_hdcp_wait_key_an_ready()
612 return -ETIMEDOUT; in msm_hdmi_hdcp_wait_key_an_ready()
622 link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS); in msm_hdmi_hdcp_wait_key_an_ready()
631 timeout_count--; in msm_hdmi_hdcp_wait_key_an_ready()
634 return -ETIMEDOUT; in msm_hdmi_hdcp_wait_key_an_ready()
648 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_send_aksv_an() local
654 link0_an[0] = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA5); in msm_hdmi_hdcp_send_aksv_an()
655 link0_an[1] = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA6); in msm_hdmi_hdcp_send_aksv_an()
658 link0_aksv_0 = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA3); in msm_hdmi_hdcp_send_aksv_an()
659 link0_aksv_1 = hdmi_read(hdmi, REG_HDMI_HDCP_RCVPORT_DATA4); in msm_hdmi_hdcp_send_aksv_an()
670 rc = msm_hdmi_ddc_write(hdmi, HDCP_PORT_ADDR, 0x18, (u8 *)link0_an, in msm_hdmi_hdcp_send_aksv_an()
676 DBG("Link0-An=%08x%08x", link0_an[0], link0_an[1]); in msm_hdmi_hdcp_send_aksv_an()
679 rc = msm_hdmi_ddc_write(hdmi, HDCP_PORT_ADDR, 0x10, aksv, 5); in msm_hdmi_hdcp_send_aksv_an()
684 DBG("Link0-AKSV=%02x%08x", link0_aksv_1 & 0xFF, link0_aksv_0); in msm_hdmi_hdcp_send_aksv_an()
692 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_recv_bksv() local
697 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x00, bksv, 5); in msm_hdmi_hdcp_recv_bksv()
703 hdcp_ctrl->bksv_lsb = bksv[0] | (bksv[1] << 8) | in msm_hdmi_hdcp_recv_bksv()
705 hdcp_ctrl->bksv_msb = bksv[4]; in msm_hdmi_hdcp_recv_bksv()
706 DBG(":BKSV=%02x%08x", hdcp_ctrl->bksv_msb, hdcp_ctrl->bksv_lsb); in msm_hdmi_hdcp_recv_bksv()
708 /* check there are 20 ones in BKSV */ in msm_hdmi_hdcp_recv_bksv()
709 if ((hweight32(hdcp_ctrl->bksv_lsb) + hweight32(hdcp_ctrl->bksv_msb)) in msm_hdmi_hdcp_recv_bksv()
714 return -EINVAL; in msm_hdmi_hdcp_recv_bksv()
719 data[0] = hdcp_ctrl->bksv_lsb; in msm_hdmi_hdcp_recv_bksv()
721 data[1] = hdcp_ctrl->bksv_msb; in msm_hdmi_hdcp_recv_bksv()
730 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_recv_bcaps() local
734 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1); in msm_hdmi_hdcp_recv_bcaps()
742 hdcp_ctrl->ds_type = (bcaps & BIT(6)) ? DS_REPEATER : DS_RECEIVER; in msm_hdmi_hdcp_recv_bcaps()
754 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_part1_key_exchange() local
776 hdmi_write(hdmi, REG_HDMI_HDCP_RCVPORT_DATA4, 0); in msm_hdmi_hdcp_auth_part1_key_exchange()
793 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_part1_key_exchange()
794 hdmi_write(hdmi, REG_HDMI_HDCP_INT_CTRL, in msm_hdmi_hdcp_auth_part1_key_exchange()
800 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_auth_part1_key_exchange()
808 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_part1_recv_r0() local
813 * HDCP Compliance Test case 1A-01: in msm_hdmi_hdcp_auth_part1_recv_r0()
821 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x08, buf, 2); in msm_hdmi_hdcp_auth_part1_recv_r0()
829 hdmi_write(hdmi, REG_HDMI_HDCP_RCVPORT_DATA2_0, in msm_hdmi_hdcp_auth_part1_recv_r0()
838 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_part1_verify_r0() local
846 return -ETIMEDOUT; in msm_hdmi_hdcp_auth_part1_verify_r0()
849 link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS); in msm_hdmi_hdcp_auth_part1_verify_r0()
852 return -EINVAL; in msm_hdmi_hdcp_auth_part1_verify_r0()
856 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL, in msm_hdmi_hdcp_auth_part1_verify_r0()
867 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_recv_check_bstatus() local
874 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x41, buf, 2); in msm_hdmi_hdcp_recv_check_bstatus()
894 rc = -EINVAL; in msm_hdmi_hdcp_recv_check_bstatus()
899 * HDCP Compliance 1B-05: in msm_hdmi_hdcp_recv_check_bstatus()
906 rc = -EINVAL; in msm_hdmi_hdcp_recv_check_bstatus()
911 * HDCP Compliance 1B-06: in msm_hdmi_hdcp_recv_check_bstatus()
918 rc = -EINVAL; in msm_hdmi_hdcp_recv_check_bstatus()
923 hdcp_ctrl->dev_count = down_stream_devices; in msm_hdmi_hdcp_recv_check_bstatus()
924 hdcp_ctrl->max_cascade_exceeded = max_cascade_exceeded; in msm_hdmi_hdcp_recv_check_bstatus()
925 hdcp_ctrl->max_dev_exceeded = max_devs_exceeded; in msm_hdmi_hdcp_recv_check_bstatus()
926 hdcp_ctrl->depth = repeater_cascade_depth; in msm_hdmi_hdcp_recv_check_bstatus()
934 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready() local
941 * Wait until READY bit is set in BCAPS, as per HDCP specifications in msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready()
947 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1); in msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready()
956 timeout_count--; in msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready()
959 return -ETIMEDOUT; in msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready()
993 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_transfer_v_h() local
1010 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, in msm_hdmi_hdcp_transfer_v_h()
1011 rd->off, (u8 *)&data[i], (u16)sizeof(data[i])); in msm_hdmi_hdcp_transfer_v_h()
1013 pr_err("%s: Read %s failed\n", __func__, rd->name); in msm_hdmi_hdcp_transfer_v_h()
1017 DBG("%s =%x", rd->name, data[i]); in msm_hdmi_hdcp_transfer_v_h()
1030 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_recv_ksv_fifo() local
1033 ksv_bytes = 5 * hdcp_ctrl->dev_count; in msm_hdmi_hdcp_recv_ksv_fifo()
1035 rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x43, in msm_hdmi_hdcp_recv_ksv_fifo()
1036 hdcp_ctrl->ksv_list, ksv_bytes); in msm_hdmi_hdcp_recv_ksv_fifo()
1068 * All bytes (DEVICE_COUNT * 5) must be read in a single, in msm_hdmi_hdcp_auth_part2_recv_ksv_fifo()
1079 timeout_count--; in msm_hdmi_hdcp_auth_part2_recv_ksv_fifo()
1082 return -ETIMEDOUT; in msm_hdmi_hdcp_auth_part2_recv_ksv_fifo()
1117 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_write_ksv_fifo() local
1123 ksv_bytes = 5 * hdcp_ctrl->dev_count; in msm_hdmi_hdcp_write_ksv_fifo()
1126 if (hdcp_ctrl->ksv_fifo_w_index) { in msm_hdmi_hdcp_write_ksv_fifo()
1127 reg_val = hdmi_read(hdmi, REG_HDMI_HDCP_SHA_STATUS); in msm_hdmi_hdcp_write_ksv_fifo()
1129 if (hdcp_ctrl->ksv_fifo_w_index == ksv_bytes) { in msm_hdmi_hdcp_write_ksv_fifo()
1135 return -EAGAIN; in msm_hdmi_hdcp_write_ksv_fifo()
1140 return -EAGAIN; in msm_hdmi_hdcp_write_ksv_fifo()
1146 ksv_bytes -= hdcp_ctrl->ksv_fifo_w_index; in msm_hdmi_hdcp_write_ksv_fifo()
1152 ksv_fifo = hdcp_ctrl->ksv_list; in msm_hdmi_hdcp_write_ksv_fifo()
1153 ksv_fifo += hdcp_ctrl->ksv_fifo_w_index; in msm_hdmi_hdcp_write_ksv_fifo()
1158 if ((i == (ksv_bytes - 1)) && last_byte) in msm_hdmi_hdcp_write_ksv_fifo()
1169 hdcp_ctrl->ksv_fifo_w_index += ksv_bytes; in msm_hdmi_hdcp_write_ksv_fifo()
1172 *return -EAGAIN to notify caller to wait for COMP_DONE or BLOCK_DONE in msm_hdmi_hdcp_write_ksv_fifo()
1174 return -EAGAIN; in msm_hdmi_hdcp_write_ksv_fifo()
1184 hdcp_ctrl->ksv_fifo_w_index = 0; in msm_hdmi_hdcp_auth_part2_write_ksv_fifo()
1191 if (rc != -EAGAIN) in msm_hdmi_hdcp_auth_part2_write_ksv_fifo()
1194 timeout_count--; in msm_hdmi_hdcp_auth_part2_write_ksv_fifo()
1197 return -ETIMEDOUT; in msm_hdmi_hdcp_auth_part2_write_ksv_fifo()
1211 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_auth_part2_check_v_match() local
1216 link0_status = hdmi_read(hdmi, REG_HDMI_HDCP_LINK0_STATUS); in msm_hdmi_hdcp_auth_part2_check_v_match()
1220 timeout_count--; in msm_hdmi_hdcp_auth_part2_check_v_match()
1223 return -ETIMEDOUT; in msm_hdmi_hdcp_auth_part2_check_v_match()
1265 if (hdcp_ctrl->ds_type == DS_RECEIVER) in msm_hdmi_hdcp_auth_work()
1292 if (rc == -ECANCELED) { in msm_hdmi_hdcp_auth_work()
1294 } else if (rc == -ENOTSUPP) { in msm_hdmi_hdcp_auth_work()
1306 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_on() local
1310 if ((HDCP_STATE_INACTIVE != hdcp_ctrl->hdcp_state) || in msm_hdmi_hdcp_on()
1311 (HDCP_STATE_NO_AKSV == hdcp_ctrl->hdcp_state)) { in msm_hdmi_hdcp_on()
1316 /* clear HDMI Encrypt */ in msm_hdmi_hdcp_on()
1317 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_on()
1318 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_hdcp_on()
1320 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val); in msm_hdmi_hdcp_on()
1321 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_on()
1323 hdcp_ctrl->auth_event = 0; in msm_hdmi_hdcp_on()
1324 hdcp_ctrl->hdcp_state = HDCP_STATE_AUTHENTICATING; in msm_hdmi_hdcp_on()
1325 hdcp_ctrl->auth_retries = 0; in msm_hdmi_hdcp_on()
1326 queue_work(hdmi->workq, &hdcp_ctrl->hdcp_auth_work); in msm_hdmi_hdcp_on()
1331 struct hdmi *hdmi = hdcp_ctrl->hdmi; in msm_hdmi_hdcp_off() local
1335 if ((HDCP_STATE_INACTIVE == hdcp_ctrl->hdcp_state) || in msm_hdmi_hdcp_off()
1336 (HDCP_STATE_NO_AKSV == hdcp_ctrl->hdcp_state)) { in msm_hdmi_hdcp_off()
1344 * attempt a re-authentication, HW would clear the AN0_READY and in msm_hdmi_hdcp_off()
1345 * AN1_READY bits in HDMI_HDCP_LINK0_STATUS register in msm_hdmi_hdcp_off()
1347 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_off()
1348 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL); in msm_hdmi_hdcp_off()
1350 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, reg_val); in msm_hdmi_hdcp_off()
1357 hdmi_write(hdmi, REG_HDMI_HDCP_INT_CTRL, 0); in msm_hdmi_hdcp_off()
1358 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_off()
1366 set_bit(AUTH_ABORT_EV, &hdcp_ctrl->auth_event); in msm_hdmi_hdcp_off()
1367 wake_up_all(&hdcp_ctrl->auth_event_queue); in msm_hdmi_hdcp_off()
1368 cancel_work_sync(&hdcp_ctrl->hdcp_auth_work); in msm_hdmi_hdcp_off()
1369 cancel_work_sync(&hdcp_ctrl->hdcp_reauth_work); in msm_hdmi_hdcp_off()
1371 hdmi_write(hdmi, REG_HDMI_HDCP_RESET, in msm_hdmi_hdcp_off()
1375 hdmi_write(hdmi, REG_HDMI_HDCP_CTRL, 0); in msm_hdmi_hdcp_off()
1377 spin_lock_irqsave(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_off()
1378 reg_val = hdmi_read(hdmi, REG_HDMI_CTRL); in msm_hdmi_hdcp_off()
1380 hdmi_write(hdmi, REG_HDMI_CTRL, reg_val); in msm_hdmi_hdcp_off()
1383 reg_val = hdmi_read(hdmi, REG_HDMI_HPD_CTRL); in msm_hdmi_hdcp_off()
1385 hdmi_write(hdmi, REG_HDMI_HPD_CTRL, reg_val); in msm_hdmi_hdcp_off()
1386 spin_unlock_irqrestore(&hdmi->reg_lock, flags); in msm_hdmi_hdcp_off()
1388 hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE; in msm_hdmi_hdcp_off()
1393 struct hdmi_hdcp_ctrl *msm_hdmi_hdcp_init(struct hdmi *hdmi) in msm_hdmi_hdcp_init() argument
1397 if (!hdmi->qfprom_mmio) { in msm_hdmi_hdcp_init()
1400 return ERR_PTR(-EINVAL); in msm_hdmi_hdcp_init()
1405 return ERR_PTR(-ENOMEM); in msm_hdmi_hdcp_init()
1407 INIT_WORK(&hdcp_ctrl->hdcp_auth_work, msm_hdmi_hdcp_auth_work); in msm_hdmi_hdcp_init()
1408 INIT_WORK(&hdcp_ctrl->hdcp_reauth_work, msm_hdmi_hdcp_reauth_work); in msm_hdmi_hdcp_init()
1409 init_waitqueue_head(&hdcp_ctrl->auth_event_queue); in msm_hdmi_hdcp_init()
1410 hdcp_ctrl->hdmi = hdmi; in msm_hdmi_hdcp_init()
1411 hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE; in msm_hdmi_hdcp_init()
1412 hdcp_ctrl->aksv_valid = false; in msm_hdmi_hdcp_init()
1415 hdcp_ctrl->tz_hdcp = true; in msm_hdmi_hdcp_init()
1417 hdcp_ctrl->tz_hdcp = false; in msm_hdmi_hdcp_init()
1422 void msm_hdmi_hdcp_destroy(struct hdmi *hdmi) in msm_hdmi_hdcp_destroy() argument
1424 if (hdmi) { in msm_hdmi_hdcp_destroy()
1425 kfree(hdmi->hdcp_ctrl); in msm_hdmi_hdcp_destroy()
1426 hdmi->hdcp_ctrl = NULL; in msm_hdmi_hdcp_destroy()