.. | .. |
---|
239 | 239 | #define DPTX_HDCP22GPIOCHNGSTS 0x362c |
---|
240 | 240 | #define DPTX_HDCPREG_DPK_CRC 0x3630 |
---|
241 | 241 | |
---|
| 242 | +#define HDCP_KEY_SIZE 308 |
---|
| 243 | +#define HDCP_KEY_SEED_SIZE 2 |
---|
| 244 | + |
---|
242 | 245 | #define HDCP_DATA_SIZE 330 |
---|
243 | 246 | #define DP_HDCP1X_ID 6 |
---|
| 247 | + |
---|
| 248 | +#define HDCP_SIG_MAGIC 0x4B534541 /* "AESK" */ |
---|
| 249 | +#define HDCP_FLG_AES 1 |
---|
244 | 250 | |
---|
245 | 251 | #define DPTX_MAX_REGISTER DPTX_HDCPREG_DPK_CRC |
---|
246 | 252 | |
---|
.. | .. |
---|
407 | 413 | int color_format; |
---|
408 | 414 | }; |
---|
409 | 415 | |
---|
| 416 | +struct hdcp_key_data_t { |
---|
| 417 | + unsigned int signature; |
---|
| 418 | + unsigned int length; |
---|
| 419 | + unsigned int crc; |
---|
| 420 | + unsigned int flags; |
---|
| 421 | + unsigned char data[]; |
---|
| 422 | +}; |
---|
| 423 | + |
---|
410 | 424 | enum { |
---|
411 | 425 | DPTX_VM_RGB_6BIT, |
---|
412 | 426 | DPTX_VM_RGB_8BIT, |
---|
.. | .. |
---|
499 | 513 | u8 hdcp_vendor_data[HDCP_DATA_SIZE + 1]; |
---|
500 | 514 | void __iomem *base; |
---|
501 | 515 | struct arm_smccc_res res; |
---|
| 516 | + struct hdcp_key_data_t *key_data; |
---|
| 517 | + bool aes_encrypt; |
---|
502 | 518 | |
---|
503 | 519 | regmap_read(dp->regmap, DPTX_HDCPREG_RMLSTS, &val); |
---|
504 | 520 | if (FIELD_GET(IDPK_DATA_INDEX, val) == 40) { |
---|
.. | .. |
---|
507 | 523 | } |
---|
508 | 524 | |
---|
509 | 525 | size = rk_vendor_read(DP_HDCP1X_ID, hdcp_vendor_data, HDCP_DATA_SIZE); |
---|
510 | | - if (size < HDCP_DATA_SIZE) { |
---|
511 | | - dev_info(dp->dev, "HDCP: read size %d\n", size); |
---|
| 526 | + if (size < (HDCP_KEY_SIZE + HDCP_KEY_SEED_SIZE)) { |
---|
| 527 | + dev_info(dp->dev, "HDCP key read error, size: %d\n", size); |
---|
512 | 528 | return -EINVAL; |
---|
513 | 529 | } |
---|
| 530 | + |
---|
| 531 | + key_data = (struct hdcp_key_data_t *)hdcp_vendor_data; |
---|
| 532 | + if ((key_data->signature != HDCP_SIG_MAGIC) || !(key_data->flags & HDCP_FLG_AES)) |
---|
| 533 | + aes_encrypt = false; |
---|
| 534 | + else |
---|
| 535 | + aes_encrypt = true; |
---|
514 | 536 | |
---|
515 | 537 | base = sip_hdcp_request_share_memory(dp->id ? DP_TX1 : DP_TX0); |
---|
516 | 538 | if (!base) |
---|
.. | .. |
---|
518 | 540 | |
---|
519 | 541 | memcpy_toio(base, hdcp_vendor_data, size); |
---|
520 | 542 | |
---|
521 | | - res = sip_hdcp_config(HDCP_FUNC_KEY_LOAD, dp->id ? DP_TX1 : DP_TX0, 0); |
---|
| 543 | + res = sip_hdcp_config(HDCP_FUNC_KEY_LOAD, dp->id ? DP_TX1 : DP_TX0, !aes_encrypt); |
---|
522 | 544 | if (IS_SIP_ERROR(res.a0)) { |
---|
523 | 545 | dev_err(dp->dev, "load hdcp key failed\n"); |
---|
524 | 546 | return -EBUSY; |
---|