Lines Matching full:mhdp

18 static int cdns_mhdp_secure_mailbox_read(struct cdns_mhdp_device *mhdp)  in cdns_mhdp_secure_mailbox_read()  argument
22 WARN_ON(!mutex_is_locked(&mhdp->mbox_mutex)); in cdns_mhdp_secure_mailbox_read()
24 ret = readx_poll_timeout(readl, mhdp->sapb_regs + CDNS_MAILBOX_EMPTY, in cdns_mhdp_secure_mailbox_read()
30 return readl(mhdp->sapb_regs + CDNS_MAILBOX_RX_DATA) & 0xff; in cdns_mhdp_secure_mailbox_read()
33 static int cdns_mhdp_secure_mailbox_write(struct cdns_mhdp_device *mhdp, in cdns_mhdp_secure_mailbox_write() argument
38 WARN_ON(!mutex_is_locked(&mhdp->mbox_mutex)); in cdns_mhdp_secure_mailbox_write()
40 ret = readx_poll_timeout(readl, mhdp->sapb_regs + CDNS_MAILBOX_FULL, in cdns_mhdp_secure_mailbox_write()
46 writel(val, mhdp->sapb_regs + CDNS_MAILBOX_TX_DATA); in cdns_mhdp_secure_mailbox_write()
51 static int cdns_mhdp_secure_mailbox_recv_header(struct cdns_mhdp_device *mhdp, in cdns_mhdp_secure_mailbox_recv_header() argument
62 ret = cdns_mhdp_secure_mailbox_read(mhdp); in cdns_mhdp_secure_mailbox_recv_header()
74 if (cdns_mhdp_secure_mailbox_read(mhdp) < 0) in cdns_mhdp_secure_mailbox_recv_header()
82 static int cdns_mhdp_secure_mailbox_recv_data(struct cdns_mhdp_device *mhdp, in cdns_mhdp_secure_mailbox_recv_data() argument
89 ret = cdns_mhdp_secure_mailbox_read(mhdp); in cdns_mhdp_secure_mailbox_recv_data()
99 static int cdns_mhdp_secure_mailbox_send(struct cdns_mhdp_device *mhdp, in cdns_mhdp_secure_mailbox_send() argument
114 ret = cdns_mhdp_secure_mailbox_write(mhdp, header[i]); in cdns_mhdp_secure_mailbox_send()
120 ret = cdns_mhdp_secure_mailbox_write(mhdp, message[i]); in cdns_mhdp_secure_mailbox_send()
128 static int cdns_mhdp_hdcp_get_status(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_get_status() argument
134 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_get_status()
135 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_get_status()
140 ret = cdns_mhdp_secure_mailbox_recv_header(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_get_status()
146 ret = cdns_mhdp_secure_mailbox_recv_data(mhdp, hdcp_status, in cdns_mhdp_hdcp_get_status()
154 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_get_status()
159 static u8 cdns_mhdp_hdcp_handle_status(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_handle_status() argument
165 dev_dbg(mhdp->dev, "HDCP Error = %d", err); in cdns_mhdp_hdcp_handle_status()
170 static int cdns_mhdp_hdcp_rx_id_valid_response(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_rx_id_valid_response() argument
175 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_rx_id_valid_response()
176 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_rx_id_valid_response()
179 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_rx_id_valid_response()
184 static int cdns_mhdp_hdcp_rx_id_valid(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_rx_id_valid() argument
191 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_rx_id_valid()
192 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_rx_id_valid()
197 ret = cdns_mhdp_secure_mailbox_recv_header(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_rx_id_valid()
203 ret = cdns_mhdp_secure_mailbox_recv_data(mhdp, rec_id_hdr, 2); in cdns_mhdp_hdcp_rx_id_valid()
209 ret = cdns_mhdp_secure_mailbox_recv_data(mhdp, hdcp_rx_id, 5 * *recv_num); in cdns_mhdp_hdcp_rx_id_valid()
212 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_rx_id_valid()
217 static int cdns_mhdp_hdcp_km_stored_resp(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_km_stored_resp() argument
222 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_km_stored_resp()
223 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_km_stored_resp()
225 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_km_stored_resp()
230 static int cdns_mhdp_hdcp_tx_is_km_stored(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_tx_is_km_stored() argument
235 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_tx_is_km_stored()
236 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_tx_is_km_stored()
241 ret = cdns_mhdp_secure_mailbox_recv_header(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_tx_is_km_stored()
247 ret = cdns_mhdp_secure_mailbox_recv_data(mhdp, resp, size); in cdns_mhdp_hdcp_tx_is_km_stored()
249 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_tx_is_km_stored()
254 static int cdns_mhdp_hdcp_tx_config(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_tx_config() argument
259 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_tx_config()
260 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_tx_config()
262 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_tx_config()
267 static int cdns_mhdp_hdcp_set_config(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_set_config() argument
277 cdns_mhdp_hdcp_tx_config(mhdp, hdcp_cfg); in cdns_mhdp_hdcp_set_config()
278 ret_event = cdns_mhdp_wait_for_sw_event(mhdp, CDNS_HDCP_TX_STATUS); in cdns_mhdp_hdcp_set_config()
282 ret = cdns_mhdp_hdcp_get_status(mhdp, &hdcp_port_status); in cdns_mhdp_hdcp_set_config()
283 if (ret || cdns_mhdp_hdcp_handle_status(mhdp, hdcp_port_status)) in cdns_mhdp_hdcp_set_config()
289 static int cdns_mhdp_hdcp_auth_check(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_auth_check() argument
295 ret_event = cdns_mhdp_wait_for_sw_event(mhdp, CDNS_HDCP_TX_STATUS); in cdns_mhdp_hdcp_auth_check()
299 ret = cdns_mhdp_hdcp_get_status(mhdp, &hdcp_port_status); in cdns_mhdp_hdcp_auth_check()
300 if (ret || cdns_mhdp_hdcp_handle_status(mhdp, hdcp_port_status)) in cdns_mhdp_hdcp_auth_check()
304 dev_dbg(mhdp->dev, "Authentication completed successfully!\n"); in cdns_mhdp_hdcp_auth_check()
308 dev_dbg(mhdp->dev, "Authentication failed\n"); in cdns_mhdp_hdcp_auth_check()
313 static int cdns_mhdp_hdcp_check_receviers(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_check_receviers() argument
319 ret_event = cdns_mhdp_wait_for_sw_event(mhdp, in cdns_mhdp_hdcp_check_receviers()
326 cdns_mhdp_hdcp_rx_id_valid(mhdp, &hdcp_num_rec, (u8 *)hdcp_rec_id); in cdns_mhdp_hdcp_check_receviers()
327 cdns_mhdp_hdcp_rx_id_valid_response(mhdp, 1); in cdns_mhdp_hdcp_check_receviers()
332 static int cdns_mhdp_hdcp_auth_22(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_auth_22() argument
339 dev_dbg(mhdp->dev, "HDCP: Start 2.2 Authentication\n"); in cdns_mhdp_hdcp_auth_22()
340 ret_event = cdns_mhdp_wait_for_sw_event(mhdp, in cdns_mhdp_hdcp_auth_22()
346 mhdp->sw_events &= ~CDNS_HDCP_TX_STATUS; in cdns_mhdp_hdcp_auth_22()
347 ret = cdns_mhdp_hdcp_get_status(mhdp, &hdcp_port_status); in cdns_mhdp_hdcp_auth_22()
348 if (ret || cdns_mhdp_hdcp_handle_status(mhdp, hdcp_port_status)) in cdns_mhdp_hdcp_auth_22()
352 cdns_mhdp_hdcp_tx_is_km_stored(mhdp, resp, sizeof(resp)); in cdns_mhdp_hdcp_auth_22()
353 cdns_mhdp_hdcp_km_stored_resp(mhdp, 0, NULL); in cdns_mhdp_hdcp_auth_22()
355 if (cdns_mhdp_hdcp_check_receviers(mhdp)) in cdns_mhdp_hdcp_auth_22()
361 static inline int cdns_mhdp_hdcp_auth_14(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_auth_14() argument
363 dev_dbg(mhdp->dev, "HDCP: Starting 1.4 Authentication\n"); in cdns_mhdp_hdcp_auth_14()
364 return cdns_mhdp_hdcp_check_receviers(mhdp); in cdns_mhdp_hdcp_auth_14()
367 static int cdns_mhdp_hdcp_auth(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_auth() argument
372 ret = cdns_mhdp_hdcp_set_config(mhdp, hdcp_config, true); in cdns_mhdp_hdcp_auth()
377 ret = cdns_mhdp_hdcp_auth_14(mhdp); in cdns_mhdp_hdcp_auth()
379 ret = cdns_mhdp_hdcp_auth_22(mhdp); in cdns_mhdp_hdcp_auth()
384 ret = cdns_mhdp_hdcp_auth_check(mhdp); in cdns_mhdp_hdcp_auth()
386 ret = cdns_mhdp_hdcp_auth_check(mhdp); in cdns_mhdp_hdcp_auth()
392 static int _cdns_mhdp_hdcp_disable(struct cdns_mhdp_device *mhdp) in _cdns_mhdp_hdcp_disable() argument
396 dev_dbg(mhdp->dev, "[%s:%d] HDCP is being disabled...\n", in _cdns_mhdp_hdcp_disable()
397 mhdp->connector.name, mhdp->connector.base.id); in _cdns_mhdp_hdcp_disable()
399 ret = cdns_mhdp_hdcp_set_config(mhdp, 0, false); in _cdns_mhdp_hdcp_disable()
404 static int _cdns_mhdp_hdcp_enable(struct cdns_mhdp_device *mhdp, u8 content_type) in _cdns_mhdp_hdcp_enable() argument
413 ret = cdns_mhdp_hdcp_auth(mhdp, HDCP_TX_2); in _cdns_mhdp_hdcp_enable()
416 _cdns_mhdp_hdcp_disable(mhdp); in _cdns_mhdp_hdcp_enable()
420 ret = cdns_mhdp_hdcp_auth(mhdp, HDCP_TX_1); in _cdns_mhdp_hdcp_enable()
423 _cdns_mhdp_hdcp_disable(mhdp); in _cdns_mhdp_hdcp_enable()
427 dev_err(mhdp->dev, "HDCP authentication failed (%d tries/%d)\n", in _cdns_mhdp_hdcp_enable()
433 static int cdns_mhdp_hdcp_check_link(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_check_link() argument
438 mutex_lock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_check_link()
439 if (mhdp->hdcp.value == DRM_MODE_CONTENT_PROTECTION_UNDESIRED) in cdns_mhdp_hdcp_check_link()
442 ret = cdns_mhdp_hdcp_get_status(mhdp, &hdcp_port_status); in cdns_mhdp_hdcp_check_link()
446 dev_err(mhdp->dev, in cdns_mhdp_hdcp_check_link()
448 mhdp->connector.name, mhdp->connector.base.id); in cdns_mhdp_hdcp_check_link()
450 ret = _cdns_mhdp_hdcp_disable(mhdp); in cdns_mhdp_hdcp_check_link()
452 mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_DESIRED; in cdns_mhdp_hdcp_check_link()
453 schedule_work(&mhdp->hdcp.prop_work); in cdns_mhdp_hdcp_check_link()
457 ret = _cdns_mhdp_hdcp_enable(mhdp, mhdp->hdcp.hdcp_content_type); in cdns_mhdp_hdcp_check_link()
459 mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_DESIRED; in cdns_mhdp_hdcp_check_link()
460 schedule_work(&mhdp->hdcp.prop_work); in cdns_mhdp_hdcp_check_link()
463 mutex_unlock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_check_link()
473 struct cdns_mhdp_device *mhdp = container_of(hdcp, in cdns_mhdp_hdcp_check_work() local
477 if (!cdns_mhdp_hdcp_check_link(mhdp)) in cdns_mhdp_hdcp_check_work()
487 struct cdns_mhdp_device *mhdp = container_of(hdcp, in cdns_mhdp_hdcp_prop_work() local
490 struct drm_device *dev = mhdp->connector.dev; in cdns_mhdp_hdcp_prop_work()
494 mutex_lock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_prop_work()
495 if (mhdp->hdcp.value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) { in cdns_mhdp_hdcp_prop_work()
496 state = mhdp->connector.state; in cdns_mhdp_hdcp_prop_work()
497 state->content_protection = mhdp->hdcp.value; in cdns_mhdp_hdcp_prop_work()
499 mutex_unlock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_prop_work()
503 int cdns_mhdp_hdcp_set_lc(struct cdns_mhdp_device *mhdp, u8 *val) in cdns_mhdp_hdcp_set_lc() argument
507 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_set_lc()
508 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_GENERAL, in cdns_mhdp_hdcp_set_lc()
511 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_set_lc()
517 cdns_mhdp_hdcp_set_public_key_param(struct cdns_mhdp_device *mhdp, in cdns_mhdp_hdcp_set_public_key_param() argument
522 mutex_lock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_set_public_key_param()
523 ret = cdns_mhdp_secure_mailbox_send(mhdp, MB_MODULE_ID_HDCP_TX, in cdns_mhdp_hdcp_set_public_key_param()
526 mutex_unlock(&mhdp->mbox_mutex); in cdns_mhdp_hdcp_set_public_key_param()
531 int cdns_mhdp_hdcp_enable(struct cdns_mhdp_device *mhdp, u8 content_type) in cdns_mhdp_hdcp_enable() argument
535 mutex_lock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_enable()
536 ret = _cdns_mhdp_hdcp_enable(mhdp, content_type); in cdns_mhdp_hdcp_enable()
540 mhdp->hdcp.hdcp_content_type = content_type; in cdns_mhdp_hdcp_enable()
541 mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_ENABLED; in cdns_mhdp_hdcp_enable()
542 schedule_work(&mhdp->hdcp.prop_work); in cdns_mhdp_hdcp_enable()
543 schedule_delayed_work(&mhdp->hdcp.check_work, in cdns_mhdp_hdcp_enable()
546 mutex_unlock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_enable()
550 int cdns_mhdp_hdcp_disable(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_disable() argument
554 mutex_lock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_disable()
555 if (mhdp->hdcp.value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) { in cdns_mhdp_hdcp_disable()
556 mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED; in cdns_mhdp_hdcp_disable()
557 schedule_work(&mhdp->hdcp.prop_work); in cdns_mhdp_hdcp_disable()
558 ret = _cdns_mhdp_hdcp_disable(mhdp); in cdns_mhdp_hdcp_disable()
560 mutex_unlock(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_disable()
561 cancel_delayed_work_sync(&mhdp->hdcp.check_work); in cdns_mhdp_hdcp_disable()
566 void cdns_mhdp_hdcp_init(struct cdns_mhdp_device *mhdp) in cdns_mhdp_hdcp_init() argument
568 INIT_DELAYED_WORK(&mhdp->hdcp.check_work, cdns_mhdp_hdcp_check_work); in cdns_mhdp_hdcp_init()
569 INIT_WORK(&mhdp->hdcp.prop_work, cdns_mhdp_hdcp_prop_work); in cdns_mhdp_hdcp_init()
570 mutex_init(&mhdp->hdcp.mutex); in cdns_mhdp_hdcp_init()