Lines Matching +full:depth +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/dma-mapping.h>
26 #define VPDMA_FIRMWARE "vpdma-1b8.bin"
32 .depth = 8,
37 .depth = 8,
42 .depth = 8,
47 .depth = 8,
52 .depth = 8,
57 .depth = 4,
62 .depth = 4,
67 .depth = 16,
72 .depth = 24,
77 .depth = 16,
82 .depth = 16,
87 .depth = 16,
96 .depth = 16,
101 .depth = 16,
106 .depth = 16,
111 .depth = 16,
116 .depth = 16,
121 .depth = 24,
126 .depth = 24,
131 .depth = 32,
136 .depth = 24,
141 .depth = 32,
146 .depth = 16,
151 .depth = 16,
156 .depth = 16,
161 .depth = 16,
166 .depth = 16,
171 .depth = 24,
176 .depth = 24,
181 .depth = 32,
186 .depth = 24,
191 .depth = 32,
197 * To handle RAW format we are re-using the CBY422
198 * vpdma data type so that we use the vpdma to re-order
209 .depth = 8,
214 .depth = 16,
223 .depth = 4,
282 return ioread32(vpdma->base + offset); in read_reg()
287 iowrite32(value, vpdma->base + offset); in write_reg()
309 struct device *dev = &vpdma->pdev->dev; in vpdma_dump_regs()
311 #define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(vpdma, VPDMA_##r)) in vpdma_dump_regs()
365 buf->size = size; in vpdma_alloc_desc_buf()
366 buf->mapped = false; in vpdma_alloc_desc_buf()
367 buf->addr = kzalloc(size, GFP_KERNEL); in vpdma_alloc_desc_buf()
368 if (!buf->addr) in vpdma_alloc_desc_buf()
369 return -ENOMEM; in vpdma_alloc_desc_buf()
371 WARN_ON(((unsigned long)buf->addr & VPDMA_DESC_ALIGN) != 0); in vpdma_alloc_desc_buf()
379 WARN_ON(buf->mapped); in vpdma_free_desc_buf()
380 kfree(buf->addr); in vpdma_free_desc_buf()
381 buf->addr = NULL; in vpdma_free_desc_buf()
382 buf->size = 0; in vpdma_free_desc_buf()
391 struct device *dev = &vpdma->pdev->dev; in vpdma_map_desc_buf()
393 WARN_ON(buf->mapped); in vpdma_map_desc_buf()
394 buf->dma_addr = dma_map_single(dev, buf->addr, buf->size, in vpdma_map_desc_buf()
396 if (dma_mapping_error(dev, buf->dma_addr)) { in vpdma_map_desc_buf()
398 return -EINVAL; in vpdma_map_desc_buf()
401 buf->mapped = true; in vpdma_map_desc_buf()
413 struct device *dev = &vpdma->pdev->dev; in vpdma_unmap_desc_buf()
415 if (buf->mapped) in vpdma_unmap_desc_buf()
416 dma_unmap_single(dev, buf->dma_addr, buf->size, in vpdma_unmap_desc_buf()
419 buf->mapped = false; in vpdma_unmap_desc_buf()
458 while (vpdma_list_busy(vpdma, list_num) && --timeout) in vpdma_list_cleanup()
462 dev_err(&vpdma->pdev->dev, "Timed out cleaning up VPDMA list\n"); in vpdma_list_cleanup()
463 ret = -EBUSY; in vpdma_list_cleanup()
485 r = vpdma_alloc_desc_buf(&list->buf, size); in vpdma_create_desc_list()
489 list->next = list->buf.addr; in vpdma_create_desc_list()
491 list->type = type; in vpdma_create_desc_list()
503 list->next = list->buf.addr; in vpdma_reset_desc_list()
513 vpdma_free_desc_buf(&list->buf); in vpdma_free_desc_list()
515 list->next = NULL; in vpdma_free_desc_list()
535 return -EBUSY; in vpdma_submit_descs()
537 /* 16-byte granularity */ in vpdma_submit_descs()
538 list_size = (list->next - list->buf.addr) >> 4; in vpdma_submit_descs()
540 spin_lock_irqsave(&vpdma->lock, flags); in vpdma_submit_descs()
541 write_reg(vpdma, VPDMA_LIST_ADDR, (u32) list->buf.dma_addr); in vpdma_submit_descs()
545 (list->type << VPDMA_LIST_TYPE_SHFT) | in vpdma_submit_descs()
547 spin_unlock_irqrestore(&vpdma->lock, flags); in vpdma_submit_descs()
559 struct vpdma_dtd *dtd = list->buf.addr; in vpdma_update_dma_addr()
564 vpdma_unmap_desc_buf(vpdma, &list->buf); in vpdma_update_dma_addr()
566 dtd->start_addr = dma_addr; in vpdma_update_dma_addr()
569 * of the list->buf in vpdma_update_dma_addr()
571 offset = (void *)write_dtd - list->buf.addr; in vpdma_update_dma_addr()
572 write_desc_addr = list->buf.dma_addr + offset; in vpdma_update_dma_addr()
575 dtd->desc_write_addr = dtd_desc_write_addr(write_desc_addr, in vpdma_update_dma_addr()
578 dtd->desc_write_addr = dtd_desc_write_addr(write_desc_addr, in vpdma_update_dma_addr()
581 vpdma_map_desc_buf(vpdma, &list->buf); in vpdma_update_dma_addr()
594 write_field_reg(vpdma, reg_addr, width - 1, in vpdma_set_max_size()
597 write_field_reg(vpdma, reg_addr, height - 1, in vpdma_set_max_size()
615 cfd->dest_addr_offset); in dump_cfd()
618 pr_debug("word1: num_data_wrds = %d\n", cfd->block_len); in dump_cfd()
620 pr_debug("word2: payload_addr = 0x%08x\n", cfd->payload_addr); in dump_cfd()
637 int len = blk->size; in vpdma_add_cfd_block()
639 WARN_ON(blk->dma_addr & VPDMA_DESC_ALIGN); in vpdma_add_cfd_block()
641 cfd = list->next; in vpdma_add_cfd_block()
642 WARN_ON((void *)(cfd + 1) > (list->buf.addr + list->buf.size)); in vpdma_add_cfd_block()
644 cfd->dest_addr_offset = dest_offset; in vpdma_add_cfd_block()
645 cfd->block_len = len; in vpdma_add_cfd_block()
646 cfd->payload_addr = (u32) blk->dma_addr; in vpdma_add_cfd_block()
647 cfd->ctl_payload_len = cfd_pkt_payload_len(CFD_INDIRECT, CFD_CLS_BLOCK, in vpdma_add_cfd_block()
650 list->next = cfd + 1; in vpdma_add_cfd_block()
665 unsigned int len = adb->size; in vpdma_add_cfd_adb()
668 WARN_ON(adb->dma_addr & VPDMA_DESC_ALIGN); in vpdma_add_cfd_adb()
670 cfd = list->next; in vpdma_add_cfd_adb()
671 BUG_ON((void *)(cfd + 1) > (list->buf.addr + list->buf.size)); in vpdma_add_cfd_adb()
673 cfd->w0 = 0; in vpdma_add_cfd_adb()
674 cfd->w1 = 0; in vpdma_add_cfd_adb()
675 cfd->payload_addr = (u32) adb->dma_addr; in vpdma_add_cfd_adb()
676 cfd->ctl_payload_len = cfd_pkt_payload_len(CFD_INDIRECT, CFD_CLS_ADB, in vpdma_add_cfd_adb()
679 list->next = cfd + 1; in vpdma_add_cfd_adb()
708 ctd = list->next; in vpdma_add_sync_on_channel_ctd()
709 WARN_ON((void *)(ctd + 1) > (list->buf.addr + list->buf.size)); in vpdma_add_sync_on_channel_ctd()
711 ctd->w0 = 0; in vpdma_add_sync_on_channel_ctd()
712 ctd->w1 = 0; in vpdma_add_sync_on_channel_ctd()
713 ctd->w2 = 0; in vpdma_add_sync_on_channel_ctd()
714 ctd->type_source_ctl = ctd_type_source_ctl(chan_info[chan].num, in vpdma_add_sync_on_channel_ctd()
717 list->next = ctd + 1; in vpdma_add_sync_on_channel_ctd()
733 ctd = list->next; in vpdma_add_abort_channel_ctd()
734 WARN_ON((void *)(ctd + 1) > (list->buf.addr + list->buf.size)); in vpdma_add_abort_channel_ctd()
736 ctd->w0 = 0; in vpdma_add_abort_channel_ctd()
737 ctd->w1 = 0; in vpdma_add_abort_channel_ctd()
738 ctd->w2 = 0; in vpdma_add_abort_channel_ctd()
739 ctd->type_source_ctl = ctd_type_source_ctl(chan_num, in vpdma_add_abort_channel_ctd()
742 list->next = ctd + 1; in vpdma_add_abort_channel_ctd()
767 pr_debug("word2: start_addr = %x\n", dtd->start_addr); in dump_dtd()
789 pr_debug("word6: client specific attr0 = 0x%08x\n", dtd->client_attr0); in dump_dtd()
790 pr_debug("word7: client specific attr1 = 0x%08x\n", dtd->client_attr1); in dump_dtd()
827 int depth = fmt->depth; in vpdma_rawchan_add_out_dtd() local
832 if (fmt->type == VPDMA_DATA_FMT_TYPE_YUV && in vpdma_rawchan_add_out_dtd()
833 (fmt->data_type == DATA_TYPE_C420 || in vpdma_rawchan_add_out_dtd()
834 fmt->data_type == DATA_TYPE_CB420)) { in vpdma_rawchan_add_out_dtd()
837 depth = 8; in vpdma_rawchan_add_out_dtd()
840 dma_addr += rect.top * stride + (rect.left * depth >> 3); in vpdma_rawchan_add_out_dtd()
842 dtd = list->next; in vpdma_rawchan_add_out_dtd()
843 WARN_ON((void *)(dtd + 1) > (list->buf.addr + list->buf.size)); in vpdma_rawchan_add_out_dtd()
845 dtd->type_ctl_stride = dtd_type_ctl_stride(fmt->data_type, in vpdma_rawchan_add_out_dtd()
852 dtd->w1 = 0; in vpdma_rawchan_add_out_dtd()
853 dtd->start_addr = (u32) dma_addr; in vpdma_rawchan_add_out_dtd()
854 dtd->pkt_ctl = dtd_pkt_ctl(!!(flags & VPDMA_DATA_MODE_TILED), in vpdma_rawchan_add_out_dtd()
856 dtd->desc_write_addr = dtd_desc_write_addr(0, 0, 0, 0); in vpdma_rawchan_add_out_dtd()
857 dtd->max_width_height = dtd_max_width_height(max_w, max_h); in vpdma_rawchan_add_out_dtd()
858 dtd->client_attr0 = 0; in vpdma_rawchan_add_out_dtd()
859 dtd->client_attr1 = 0; in vpdma_rawchan_add_out_dtd()
861 list->next = dtd + 1; in vpdma_rawchan_add_out_dtd()
894 int depth = fmt->depth; in vpdma_add_in_dtd() local
901 if (fmt->type == VPDMA_DATA_FMT_TYPE_YUV && in vpdma_add_in_dtd()
902 (fmt->data_type == DATA_TYPE_C420 || in vpdma_add_in_dtd()
903 fmt->data_type == DATA_TYPE_CB420)) { in vpdma_add_in_dtd()
906 depth = 8; in vpdma_add_in_dtd()
909 dma_addr += rect.top * stride + (rect.left * depth >> 3); in vpdma_add_in_dtd()
911 dtd = list->next; in vpdma_add_in_dtd()
912 WARN_ON((void *)(dtd + 1) > (list->buf.addr + list->buf.size)); in vpdma_add_in_dtd()
914 dtd->type_ctl_stride = dtd_type_ctl_stride(fmt->data_type, in vpdma_add_in_dtd()
922 dtd->xfer_length_height = dtd_xfer_length_height(rect.width, in vpdma_add_in_dtd()
924 dtd->start_addr = (u32) dma_addr; in vpdma_add_in_dtd()
925 dtd->pkt_ctl = dtd_pkt_ctl(!!(flags & VPDMA_DATA_MODE_TILED), in vpdma_add_in_dtd()
927 dtd->frame_width_height = dtd_frame_width_height(frame_width, in vpdma_add_in_dtd()
929 dtd->start_h_v = dtd_start_h_v(start_h, start_v); in vpdma_add_in_dtd()
930 dtd->client_attr0 = 0; in vpdma_add_in_dtd()
931 dtd->client_attr1 = 0; in vpdma_add_in_dtd()
933 list->next = dtd + 1; in vpdma_add_in_dtd()
941 int i, list_num = -1; in vpdma_hwlist_alloc()
944 spin_lock_irqsave(&vpdma->lock, flags); in vpdma_hwlist_alloc()
945 for (i = 0; i < VPDMA_MAX_NUM_LIST && vpdma->hwlist_used[i]; i++) in vpdma_hwlist_alloc()
950 vpdma->hwlist_used[i] = true; in vpdma_hwlist_alloc()
951 vpdma->hwlist_priv[i] = priv; in vpdma_hwlist_alloc()
953 spin_unlock_irqrestore(&vpdma->lock, flags); in vpdma_hwlist_alloc()
964 return vpdma->hwlist_priv[list_num]; in vpdma_hwlist_get_priv()
973 spin_lock_irqsave(&vpdma->lock, flags); in vpdma_hwlist_release()
974 vpdma->hwlist_used[list_num] = false; in vpdma_hwlist_release()
975 priv = vpdma->hwlist_priv; in vpdma_hwlist_release()
976 spin_unlock_irqrestore(&vpdma->lock, flags); in vpdma_hwlist_release()
1029 if (fmt->type == VPDMA_DATA_FMT_TYPE_RGB) in vpdma_set_bg_color()
1031 else if (fmt->type == VPDMA_DATA_FMT_TYPE_YUV) in vpdma_set_bg_color()
1072 dev_dbg(&vpdma->pdev->dev, "firmware callback\n"); in vpdma_firmware_cb()
1074 if (!f || !f->data) { in vpdma_firmware_cb()
1075 dev_err(&vpdma->pdev->dev, "couldn't get firmware\n"); in vpdma_firmware_cb()
1082 vpdma->cb(vpdma->pdev); in vpdma_firmware_cb()
1086 r = vpdma_alloc_desc_buf(&fw_dma_buf, f->size); in vpdma_firmware_cb()
1088 dev_err(&vpdma->pdev->dev, in vpdma_firmware_cb()
1093 memcpy(fw_dma_buf.addr, f->data, f->size); in vpdma_firmware_cb()
1108 dev_err(&vpdma->pdev->dev, "firmware upload failed\n"); in vpdma_firmware_cb()
1112 vpdma->cb(vpdma->pdev); in vpdma_firmware_cb()
1125 struct device *dev = &vpdma->pdev->dev; in vpdma_load_firmware()
1146 dev_dbg(&pdev->dev, "vpdma_create\n"); in vpdma_create()
1148 vpdma->pdev = pdev; in vpdma_create()
1149 vpdma->cb = cb; in vpdma_create()
1150 spin_lock_init(&vpdma->lock); in vpdma_create()
1154 dev_err(&pdev->dev, "missing platform resources data\n"); in vpdma_create()
1155 return -ENODEV; in vpdma_create()
1158 vpdma->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); in vpdma_create()
1159 if (!vpdma->base) { in vpdma_create()
1160 dev_err(&pdev->dev, "failed to ioremap\n"); in vpdma_create()
1161 return -ENOMEM; in vpdma_create()