Lines Matching defs:mhdp

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