diff options
Diffstat (limited to 'drivers/media/platform/coda/coda-bit.c')
-rw-r--r-- | drivers/media/platform/coda/coda-bit.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c index 9fe113cb901f..68ed2a564ad1 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c | |||
@@ -68,8 +68,9 @@ static void coda_command_async(struct coda_ctx *ctx, int cmd) | |||
68 | { | 68 | { |
69 | struct coda_dev *dev = ctx->dev; | 69 | struct coda_dev *dev = ctx->dev; |
70 | 70 | ||
71 | if (dev->devtype->product == CODA_960 || | 71 | if (dev->devtype->product == CODA_HX4 || |
72 | dev->devtype->product == CODA_7541) { | 72 | dev->devtype->product == CODA_7541 || |
73 | dev->devtype->product == CODA_960) { | ||
73 | /* Restore context related registers to CODA */ | 74 | /* Restore context related registers to CODA */ |
74 | coda_write(dev, ctx->bit_stream_param, | 75 | coda_write(dev, ctx->bit_stream_param, |
75 | CODA_REG_BIT_BIT_STREAM_PARAM); | 76 | CODA_REG_BIT_BIT_STREAM_PARAM); |
@@ -506,7 +507,8 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx, | |||
506 | goto err; | 507 | goto err; |
507 | } | 508 | } |
508 | 509 | ||
509 | if (!ctx->psbuf.vaddr && dev->devtype->product == CODA_7541) { | 510 | if (!ctx->psbuf.vaddr && (dev->devtype->product == CODA_HX4 || |
511 | dev->devtype->product == CODA_7541)) { | ||
510 | ret = coda_alloc_context_buf(ctx, &ctx->psbuf, | 512 | ret = coda_alloc_context_buf(ctx, &ctx->psbuf, |
511 | CODA7_PS_BUF_SIZE, "psbuf"); | 513 | CODA7_PS_BUF_SIZE, "psbuf"); |
512 | if (ret < 0) | 514 | if (ret < 0) |
@@ -594,6 +596,7 @@ static void coda_setup_iram(struct coda_ctx *ctx) | |||
594 | int dbk_bits; | 596 | int dbk_bits; |
595 | int bit_bits; | 597 | int bit_bits; |
596 | int ip_bits; | 598 | int ip_bits; |
599 | int me_bits; | ||
597 | 600 | ||
598 | memset(iram_info, 0, sizeof(*iram_info)); | 601 | memset(iram_info, 0, sizeof(*iram_info)); |
599 | iram_info->next_paddr = dev->iram.paddr; | 602 | iram_info->next_paddr = dev->iram.paddr; |
@@ -603,15 +606,23 @@ static void coda_setup_iram(struct coda_ctx *ctx) | |||
603 | return; | 606 | return; |
604 | 607 | ||
605 | switch (dev->devtype->product) { | 608 | switch (dev->devtype->product) { |
609 | case CODA_HX4: | ||
610 | dbk_bits = CODA7_USE_HOST_DBK_ENABLE; | ||
611 | bit_bits = CODA7_USE_HOST_BIT_ENABLE; | ||
612 | ip_bits = CODA7_USE_HOST_IP_ENABLE; | ||
613 | me_bits = CODA7_USE_HOST_ME_ENABLE; | ||
614 | break; | ||
606 | case CODA_7541: | 615 | case CODA_7541: |
607 | dbk_bits = CODA7_USE_HOST_DBK_ENABLE | CODA7_USE_DBK_ENABLE; | 616 | dbk_bits = CODA7_USE_HOST_DBK_ENABLE | CODA7_USE_DBK_ENABLE; |
608 | bit_bits = CODA7_USE_HOST_BIT_ENABLE | CODA7_USE_BIT_ENABLE; | 617 | bit_bits = CODA7_USE_HOST_BIT_ENABLE | CODA7_USE_BIT_ENABLE; |
609 | ip_bits = CODA7_USE_HOST_IP_ENABLE | CODA7_USE_IP_ENABLE; | 618 | ip_bits = CODA7_USE_HOST_IP_ENABLE | CODA7_USE_IP_ENABLE; |
619 | me_bits = CODA7_USE_HOST_ME_ENABLE | CODA7_USE_ME_ENABLE; | ||
610 | break; | 620 | break; |
611 | case CODA_960: | 621 | case CODA_960: |
612 | dbk_bits = CODA9_USE_HOST_DBK_ENABLE | CODA9_USE_DBK_ENABLE; | 622 | dbk_bits = CODA9_USE_HOST_DBK_ENABLE | CODA9_USE_DBK_ENABLE; |
613 | bit_bits = CODA9_USE_HOST_BIT_ENABLE | CODA7_USE_BIT_ENABLE; | 623 | bit_bits = CODA9_USE_HOST_BIT_ENABLE | CODA7_USE_BIT_ENABLE; |
614 | ip_bits = CODA9_USE_HOST_IP_ENABLE | CODA7_USE_IP_ENABLE; | 624 | ip_bits = CODA9_USE_HOST_IP_ENABLE | CODA7_USE_IP_ENABLE; |
625 | me_bits = 0; | ||
615 | break; | 626 | break; |
616 | default: /* CODA_DX6 */ | 627 | default: /* CODA_DX6 */ |
617 | return; | 628 | return; |
@@ -626,7 +637,8 @@ static void coda_setup_iram(struct coda_ctx *ctx) | |||
626 | w64 = mb_width * 64; | 637 | w64 = mb_width * 64; |
627 | 638 | ||
628 | /* Prioritize in case IRAM is too small for everything */ | 639 | /* Prioritize in case IRAM is too small for everything */ |
629 | if (dev->devtype->product == CODA_7541) { | 640 | if (dev->devtype->product == CODA_HX4 || |
641 | dev->devtype->product == CODA_7541) { | ||
630 | iram_info->search_ram_size = round_up(mb_width * 16 * | 642 | iram_info->search_ram_size = round_up(mb_width * 16 * |
631 | 36 + 2048, 1024); | 643 | 36 + 2048, 1024); |
632 | iram_info->search_ram_paddr = coda_iram_alloc(iram_info, | 644 | iram_info->search_ram_paddr = coda_iram_alloc(iram_info, |
@@ -635,8 +647,7 @@ static void coda_setup_iram(struct coda_ctx *ctx) | |||
635 | pr_err("IRAM is smaller than the search ram size\n"); | 647 | pr_err("IRAM is smaller than the search ram size\n"); |
636 | goto out; | 648 | goto out; |
637 | } | 649 | } |
638 | iram_info->axi_sram_use |= CODA7_USE_HOST_ME_ENABLE | | 650 | iram_info->axi_sram_use |= me_bits; |
639 | CODA7_USE_ME_ENABLE; | ||
640 | } | 651 | } |
641 | 652 | ||
642 | /* Only H.264BP and H.263P3 are considered */ | 653 | /* Only H.264BP and H.263P3 are considered */ |
@@ -688,7 +699,8 @@ out: | |||
688 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, | 699 | v4l2_dbg(1, coda_debug, &ctx->dev->v4l2_dev, |
689 | "IRAM smaller than needed\n"); | 700 | "IRAM smaller than needed\n"); |
690 | 701 | ||
691 | if (dev->devtype->product == CODA_7541) { | 702 | if (dev->devtype->product == CODA_HX4 || |
703 | dev->devtype->product == CODA_7541) { | ||
692 | /* TODO - Enabling these causes picture errors on CODA7541 */ | 704 | /* TODO - Enabling these causes picture errors on CODA7541 */ |
693 | if (ctx->inst_type == CODA_INST_DECODER) { | 705 | if (ctx->inst_type == CODA_INST_DECODER) { |
694 | /* fw 1.4.50 */ | 706 | /* fw 1.4.50 */ |
@@ -706,6 +718,7 @@ out: | |||
706 | 718 | ||
707 | static u32 coda_supported_firmwares[] = { | 719 | static u32 coda_supported_firmwares[] = { |
708 | CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5), | 720 | CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5), |
721 | CODA_FIRMWARE_VERNUM(CODA_HX4, 1, 4, 50), | ||
709 | CODA_FIRMWARE_VERNUM(CODA_7541, 1, 4, 50), | 722 | CODA_FIRMWARE_VERNUM(CODA_7541, 1, 4, 50), |
710 | CODA_FIRMWARE_VERNUM(CODA_960, 2, 1, 5), | 723 | CODA_FIRMWARE_VERNUM(CODA_960, 2, 1, 5), |
711 | CODA_FIRMWARE_VERNUM(CODA_960, 2, 3, 10), | 724 | CODA_FIRMWARE_VERNUM(CODA_960, 2, 3, 10), |
@@ -890,6 +903,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
890 | case CODA_960: | 903 | case CODA_960: |
891 | coda_write(dev, 0, CODA9_GDI_WPROT_RGN_EN); | 904 | coda_write(dev, 0, CODA9_GDI_WPROT_RGN_EN); |
892 | /* fallthrough */ | 905 | /* fallthrough */ |
906 | case CODA_HX4: | ||
893 | case CODA_7541: | 907 | case CODA_7541: |
894 | coda_write(dev, CODA7_STREAM_BUF_DYNALLOC_EN | | 908 | coda_write(dev, CODA7_STREAM_BUF_DYNALLOC_EN | |
895 | CODA7_STREAM_BUF_PIC_RESET, CODA_REG_BIT_STREAM_CTRL); | 909 | CODA7_STREAM_BUF_PIC_RESET, CODA_REG_BIT_STREAM_CTRL); |
@@ -919,6 +933,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
919 | value |= (q_data_src->height & CODADX6_PICHEIGHT_MASK) | 933 | value |= (q_data_src->height & CODADX6_PICHEIGHT_MASK) |
920 | << CODA_PICHEIGHT_OFFSET; | 934 | << CODA_PICHEIGHT_OFFSET; |
921 | break; | 935 | break; |
936 | case CODA_HX4: | ||
922 | case CODA_7541: | 937 | case CODA_7541: |
923 | if (dst_fourcc == V4L2_PIX_FMT_H264) { | 938 | if (dst_fourcc == V4L2_PIX_FMT_H264) { |
924 | value = (round_up(q_data_src->width, 16) & | 939 | value = (round_up(q_data_src->width, 16) & |
@@ -1086,6 +1101,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
1086 | value = FMO_SLICE_SAVE_BUF_SIZE << 7; | 1101 | value = FMO_SLICE_SAVE_BUF_SIZE << 7; |
1087 | coda_write(dev, value, CODADX6_CMD_ENC_SEQ_FMO); | 1102 | coda_write(dev, value, CODADX6_CMD_ENC_SEQ_FMO); |
1088 | break; | 1103 | break; |
1104 | case CODA_HX4: | ||
1089 | case CODA_7541: | 1105 | case CODA_7541: |
1090 | coda_write(dev, ctx->iram_info.search_ram_paddr, | 1106 | coda_write(dev, ctx->iram_info.search_ram_paddr, |
1091 | CODA7_CMD_ENC_SEQ_SEARCH_BASE); | 1107 | CODA7_CMD_ENC_SEQ_SEARCH_BASE); |
@@ -1131,7 +1147,8 @@ static int coda_start_encoding(struct coda_ctx *ctx) | |||
1131 | coda_write(dev, num_fb, CODA_CMD_SET_FRAME_BUF_NUM); | 1147 | coda_write(dev, num_fb, CODA_CMD_SET_FRAME_BUF_NUM); |
1132 | coda_write(dev, stride, CODA_CMD_SET_FRAME_BUF_STRIDE); | 1148 | coda_write(dev, stride, CODA_CMD_SET_FRAME_BUF_STRIDE); |
1133 | 1149 | ||
1134 | if (dev->devtype->product == CODA_7541) { | 1150 | if (dev->devtype->product == CODA_HX4 || |
1151 | dev->devtype->product == CODA_7541) { | ||
1135 | coda_write(dev, q_data_src->bytesperline, | 1152 | coda_write(dev, q_data_src->bytesperline, |
1136 | CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE); | 1153 | CODA7_CMD_SET_FRAME_SOURCE_BUF_STRIDE); |
1137 | } | 1154 | } |
@@ -1570,7 +1587,8 @@ static bool coda_reorder_enable(struct coda_ctx *ctx) | |||
1570 | struct coda_dev *dev = ctx->dev; | 1587 | struct coda_dev *dev = ctx->dev; |
1571 | int profile, level; | 1588 | int profile, level; |
1572 | 1589 | ||
1573 | if (dev->devtype->product != CODA_7541 && | 1590 | if (dev->devtype->product != CODA_HX4 && |
1591 | dev->devtype->product != CODA_7541 && | ||
1574 | dev->devtype->product != CODA_960) | 1592 | dev->devtype->product != CODA_960) |
1575 | return false; | 1593 | return false; |
1576 | 1594 | ||
@@ -1664,7 +1682,8 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1664 | CODA_CMD_DEC_SEQ_MP4_ASP_CLASS); | 1682 | CODA_CMD_DEC_SEQ_MP4_ASP_CLASS); |
1665 | } | 1683 | } |
1666 | if (src_fourcc == V4L2_PIX_FMT_H264) { | 1684 | if (src_fourcc == V4L2_PIX_FMT_H264) { |
1667 | if (dev->devtype->product == CODA_7541) { | 1685 | if (dev->devtype->product == CODA_HX4 || |
1686 | dev->devtype->product == CODA_7541) { | ||
1668 | coda_write(dev, ctx->psbuf.paddr, | 1687 | coda_write(dev, ctx->psbuf.paddr, |
1669 | CODA_CMD_DEC_SEQ_PS_BB_START); | 1688 | CODA_CMD_DEC_SEQ_PS_BB_START); |
1670 | coda_write(dev, (CODA7_PS_BUF_SIZE / 1024), | 1689 | coda_write(dev, (CODA7_PS_BUF_SIZE / 1024), |
@@ -1791,7 +1810,8 @@ static int __coda_start_decoding(struct coda_ctx *ctx) | |||
1791 | CODA_CMD_SET_FRAME_SLICE_BB_SIZE); | 1810 | CODA_CMD_SET_FRAME_SLICE_BB_SIZE); |
1792 | } | 1811 | } |
1793 | 1812 | ||
1794 | if (dev->devtype->product == CODA_7541) { | 1813 | if (dev->devtype->product == CODA_HX4 || |
1814 | dev->devtype->product == CODA_7541) { | ||
1795 | int max_mb_x = 1920 / 16; | 1815 | int max_mb_x = 1920 / 16; |
1796 | int max_mb_y = 1088 / 16; | 1816 | int max_mb_y = 1088 / 16; |
1797 | int max_mb_num = max_mb_x * max_mb_y; | 1817 | int max_mb_num = max_mb_x * max_mb_y; |
@@ -1909,6 +1929,7 @@ static int coda_prepare_decode(struct coda_ctx *ctx) | |||
1909 | switch (dev->devtype->product) { | 1929 | switch (dev->devtype->product) { |
1910 | case CODA_DX6: | 1930 | case CODA_DX6: |
1911 | /* TBD */ | 1931 | /* TBD */ |
1932 | case CODA_HX4: | ||
1912 | case CODA_7541: | 1933 | case CODA_7541: |
1913 | coda_write(dev, CODA_PRE_SCAN_EN, CODA_CMD_DEC_PIC_OPTION); | 1934 | coda_write(dev, CODA_PRE_SCAN_EN, CODA_CMD_DEC_PIC_OPTION); |
1914 | break; | 1935 | break; |
@@ -2049,7 +2070,8 @@ static void coda_finish_decode(struct coda_ctx *ctx) | |||
2049 | v4l2_err(&dev->v4l2_dev, | 2070 | v4l2_err(&dev->v4l2_dev, |
2050 | "errors in %d macroblocks\n", err_mb); | 2071 | "errors in %d macroblocks\n", err_mb); |
2051 | 2072 | ||
2052 | if (dev->devtype->product == CODA_7541) { | 2073 | if (dev->devtype->product == CODA_HX4 || |
2074 | dev->devtype->product == CODA_7541) { | ||
2053 | val = coda_read(dev, CODA_RET_DEC_PIC_OPTION); | 2075 | val = coda_read(dev, CODA_RET_DEC_PIC_OPTION); |
2054 | if (val == 0) { | 2076 | if (val == 0) { |
2055 | /* not enough bitstream data */ | 2077 | /* not enough bitstream data */ |