diff options
Diffstat (limited to 'drivers/staging/media/ipu3')
-rw-r--r-- | drivers/staging/media/ipu3/include/intel-ipu3.h | 2 | ||||
-rw-r--r-- | drivers/staging/media/ipu3/ipu3-css-fw.c | 6 | ||||
-rw-r--r-- | drivers/staging/media/ipu3/ipu3-css.c | 14 | ||||
-rw-r--r-- | drivers/staging/media/ipu3/ipu3-dmamap.c | 15 | ||||
-rw-r--r-- | drivers/staging/media/ipu3/ipu3-mmu.c | 125 | ||||
-rw-r--r-- | drivers/staging/media/ipu3/ipu3-mmu.h | 5 | ||||
-rw-r--r-- | drivers/staging/media/ipu3/ipu3-v4l2.c | 4 |
7 files changed, 67 insertions, 104 deletions
diff --git a/drivers/staging/media/ipu3/include/intel-ipu3.h b/drivers/staging/media/ipu3/include/intel-ipu3.h index 1e7184e4311d..c7cd27efac8a 100644 --- a/drivers/staging/media/ipu3/include/intel-ipu3.h +++ b/drivers/staging/media/ipu3/include/intel-ipu3.h @@ -2472,7 +2472,7 @@ struct ipu3_uapi_acc_param { struct ipu3_uapi_yuvp1_yds_config yds2 __attribute__((aligned(32))); struct ipu3_uapi_yuvp2_tcc_static_config tcc __attribute__((aligned(32))); struct ipu3_uapi_anr_config anr; - struct ipu3_uapi_awb_fr_config_s awb_fr; + struct ipu3_uapi_awb_fr_config_s awb_fr __attribute__((aligned(32))); struct ipu3_uapi_ae_config ae; struct ipu3_uapi_af_config_s af; struct ipu3_uapi_awb_config awb; diff --git a/drivers/staging/media/ipu3/ipu3-css-fw.c b/drivers/staging/media/ipu3/ipu3-css-fw.c index 4122d4e42db6..45aff76198e2 100644 --- a/drivers/staging/media/ipu3/ipu3-css-fw.c +++ b/drivers/staging/media/ipu3/ipu3-css-fw.c @@ -200,13 +200,11 @@ int imgu_css_fw_init(struct imgu_css *css) goto bad_fw; for (j = 0; j < bi->info.isp.num_output_formats; j++) - if (bi->info.isp.output_formats[j] < 0 || - bi->info.isp.output_formats[j] >= + if (bi->info.isp.output_formats[j] >= IMGU_ABI_FRAME_FORMAT_NUM) goto bad_fw; for (j = 0; j < bi->info.isp.num_vf_formats; j++) - if (bi->info.isp.vf_formats[j] < 0 || - bi->info.isp.vf_formats[j] >= + if (bi->info.isp.vf_formats[j] >= IMGU_ABI_FRAME_FORMAT_NUM) goto bad_fw; diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c index 23cf5b2cfe8b..fd1ed84c400c 100644 --- a/drivers/staging/media/ipu3/ipu3-css.c +++ b/drivers/staging/media/ipu3/ipu3-css.c @@ -24,9 +24,8 @@ #define IPU3_CSS_MAX_H 3136 #define IPU3_CSS_MAX_W 4224 -/* filter size from graph settings is fixed as 4 */ -#define FILTER_SIZE 4 -#define MIN_ENVELOPE 8 +/* minimal envelope size(GDC in - out) should be 4 */ +#define MIN_ENVELOPE 4 /* * pre-allocated buffer size for CSS ABI, auxiliary frames @@ -1827,9 +1826,9 @@ int imgu_css_fmt_try(struct imgu_css *css, vf->width = imgu_css_adjust(vf->width, VF_ALIGN_W); vf->height = imgu_css_adjust(vf->height, 1); - s = (bds->width - gdc->width) / 2 - FILTER_SIZE; + s = (bds->width - gdc->width) / 2; env->width = s < MIN_ENVELOPE ? MIN_ENVELOPE : s; - s = (bds->height - gdc->height) / 2 - FILTER_SIZE; + s = (bds->height - gdc->height) / 2; env->height = s < MIN_ENVELOPE ? MIN_ENVELOPE : s; ret = imgu_css_find_binary(css, pipe, q, r); @@ -2251,9 +2250,8 @@ int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe, css_pipe->aux_frames[a].height, css_pipe->rect[g].width, css_pipe->rect[g].height, - css_pipe->rect[e].width + FILTER_SIZE, - css_pipe->rect[e].height + - FILTER_SIZE); + css_pipe->rect[e].width, + css_pipe->rect[e].height); } } diff --git a/drivers/staging/media/ipu3/ipu3-dmamap.c b/drivers/staging/media/ipu3/ipu3-dmamap.c index d978a00e1e0b..7431322379f6 100644 --- a/drivers/staging/media/ipu3/ipu3-dmamap.c +++ b/drivers/staging/media/ipu3/ipu3-dmamap.c @@ -31,12 +31,11 @@ static void imgu_dmamap_free_buffer(struct page **pages, * Based on the implementation of __iommu_dma_alloc_pages() * defined in drivers/iommu/dma-iommu.c */ -static struct page **imgu_dmamap_alloc_buffer(size_t size, - unsigned long order_mask, - gfp_t gfp) +static struct page **imgu_dmamap_alloc_buffer(size_t size, gfp_t gfp) { struct page **pages; unsigned int i = 0, count = size >> PAGE_SHIFT; + unsigned int order_mask = 1; const gfp_t high_order_gfp = __GFP_NOWARN | __GFP_NORETRY; /* Allocate mem for array of page ptrs */ @@ -45,10 +44,6 @@ static struct page **imgu_dmamap_alloc_buffer(size_t size, if (!pages) return NULL; - order_mask &= (2U << MAX_ORDER) - 1; - if (!order_mask) - return NULL; - gfp |= __GFP_HIGHMEM | __GFP_ZERO; while (count) { @@ -99,7 +94,6 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, size_t len) { unsigned long shift = iova_shift(&imgu->iova_domain); - unsigned int alloc_sizes = imgu->mmu->pgsize_bitmap; struct device *dev = &imgu->pci_dev->dev; size_t size = PAGE_ALIGN(len); struct page **pages; @@ -114,8 +108,7 @@ void *imgu_dmamap_alloc(struct imgu_device *imgu, struct imgu_css_map *map, if (!iova) return NULL; - pages = imgu_dmamap_alloc_buffer(size, alloc_sizes >> PAGE_SHIFT, - GFP_KERNEL); + pages = imgu_dmamap_alloc_buffer(size, GFP_KERNEL); if (!pages) goto out_free_iova; @@ -257,7 +250,7 @@ int imgu_dmamap_init(struct imgu_device *imgu) if (ret) return ret; - order = __ffs(imgu->mmu->pgsize_bitmap); + order = __ffs(IPU3_PAGE_SIZE); base_pfn = max_t(unsigned long, 1, imgu->mmu->aperture_start >> order); init_iova_domain(&imgu->iova_domain, 1UL << order, base_pfn); diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/ipu3/ipu3-mmu.c index cfc2bdfb14b3..3d969b0522ab 100644 --- a/drivers/staging/media/ipu3/ipu3-mmu.c +++ b/drivers/staging/media/ipu3/ipu3-mmu.c @@ -20,9 +20,6 @@ #include "ipu3-mmu.h" -#define IPU3_PAGE_SHIFT 12 -#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT) - #define IPU3_PT_BITS 10 #define IPU3_PT_PTES (1UL << IPU3_PT_BITS) #define IPU3_PT_SIZE (IPU3_PT_PTES << 2) @@ -238,62 +235,31 @@ static int __imgu_mmu_map(struct imgu_mmu *mmu, unsigned long iova, return 0; } -/* - * The following four functions are implemented based on iommu.c - * drivers/iommu/iommu.c/iommu_pgsize(). +/** + * imgu_mmu_map - map a buffer to a physical address + * + * @info: MMU mappable range + * @iova: the virtual address + * @paddr: the physical address + * @size: length of the mappable area + * + * The function has been adapted from iommu_map() in + * drivers/iommu/iommu.c . */ -static size_t imgu_mmu_pgsize(unsigned long pgsize_bitmap, - unsigned long addr_merge, size_t size) -{ - unsigned int pgsize_idx; - size_t pgsize; - - /* Max page size that still fits into 'size' */ - pgsize_idx = __fls(size); - - /* need to consider alignment requirements ? */ - if (likely(addr_merge)) { - /* Max page size allowed by address */ - unsigned int align_pgsize_idx = __ffs(addr_merge); - - pgsize_idx = min(pgsize_idx, align_pgsize_idx); - } - - /* build a mask of acceptable page sizes */ - pgsize = (1UL << (pgsize_idx + 1)) - 1; - - /* throw away page sizes not supported by the hardware */ - pgsize &= pgsize_bitmap; - - /* make sure we're still sane */ - WARN_ON(!pgsize); - - /* pick the biggest page */ - pgsize_idx = __fls(pgsize); - pgsize = 1UL << pgsize_idx; - - return pgsize; -} - -/* drivers/iommu/iommu.c/iommu_map() */ int imgu_mmu_map(struct imgu_mmu_info *info, unsigned long iova, phys_addr_t paddr, size_t size) { struct imgu_mmu *mmu = to_imgu_mmu(info); - unsigned int min_pagesz; int ret = 0; - /* find out the minimum page size supported */ - min_pagesz = 1 << __ffs(mmu->geometry.pgsize_bitmap); - /* * both the virtual address and the physical one, as well as * the size of the mapping, must be aligned (at least) to the * size of the smallest page supported by the hardware */ - if (!IS_ALIGNED(iova | paddr | size, min_pagesz)) { - dev_err(mmu->dev, "unaligned: iova 0x%lx pa %pa size 0x%zx min_pagesz 0x%x\n", - iova, &paddr, size, min_pagesz); + if (!IS_ALIGNED(iova | paddr | size, IPU3_PAGE_SIZE)) { + dev_err(mmu->dev, "unaligned: iova 0x%lx pa %pa size 0x%zx\n", + iova, &paddr, size); return -EINVAL; } @@ -301,19 +267,15 @@ int imgu_mmu_map(struct imgu_mmu_info *info, unsigned long iova, iova, &paddr, size); while (size) { - size_t pgsize = imgu_mmu_pgsize(mmu->geometry.pgsize_bitmap, - iova | paddr, size); - - dev_dbg(mmu->dev, "mapping: iova 0x%lx pa %pa pgsize 0x%zx\n", - iova, &paddr, pgsize); + dev_dbg(mmu->dev, "mapping: iova 0x%lx pa %pa\n", iova, &paddr); ret = __imgu_mmu_map(mmu, iova, paddr); if (ret) break; - iova += pgsize; - paddr += pgsize; - size -= pgsize; + iova += IPU3_PAGE_SIZE; + paddr += IPU3_PAGE_SIZE; + size -= IPU3_PAGE_SIZE; } call_if_imgu_is_powered(mmu, imgu_mmu_tlb_invalidate); @@ -321,28 +283,36 @@ int imgu_mmu_map(struct imgu_mmu_info *info, unsigned long iova, return ret; } -/* drivers/iommu/iommu.c/default_iommu_map_sg() */ +/** + * imgu_mmu_map_sg - Map a scatterlist + * + * @info: MMU mappable range + * @iova: the virtual address + * @sg: the scatterlist to map + * @nents: number of entries in the scatterlist + * + * The function has been adapted from default_iommu_map_sg() in + * drivers/iommu/iommu.c . + */ size_t imgu_mmu_map_sg(struct imgu_mmu_info *info, unsigned long iova, struct scatterlist *sg, unsigned int nents) { struct imgu_mmu *mmu = to_imgu_mmu(info); struct scatterlist *s; size_t s_length, mapped = 0; - unsigned int i, min_pagesz; + unsigned int i; int ret; - min_pagesz = 1 << __ffs(mmu->geometry.pgsize_bitmap); - for_each_sg(sg, s, nents, i) { phys_addr_t phys = page_to_phys(sg_page(s)) + s->offset; s_length = s->length; - if (!IS_ALIGNED(s->offset, min_pagesz)) + if (!IS_ALIGNED(s->offset, IPU3_PAGE_SIZE)) goto out_err; - /* must be min_pagesz aligned to be mapped singlely */ - if (i == nents - 1 && !IS_ALIGNED(s->length, min_pagesz)) + /* must be IPU3_PAGE_SIZE aligned to be mapped singlely */ + if (i == nents - 1 && !IS_ALIGNED(s->length, IPU3_PAGE_SIZE)) s_length = PAGE_ALIGN(s->length); ret = imgu_mmu_map(info, iova + mapped, phys, s_length); @@ -394,25 +364,30 @@ static size_t __imgu_mmu_unmap(struct imgu_mmu *mmu, return unmap; } -/* drivers/iommu/iommu.c/iommu_unmap() */ +/** + * imgu_mmu_unmap - Unmap a buffer + * + * @info: MMU mappable range + * @iova: the virtual address + * @size: the length of the buffer + * + * The function has been adapted from iommu_unmap() in + * drivers/iommu/iommu.c . + */ size_t imgu_mmu_unmap(struct imgu_mmu_info *info, unsigned long iova, size_t size) { struct imgu_mmu *mmu = to_imgu_mmu(info); size_t unmapped_page, unmapped = 0; - unsigned int min_pagesz; - - /* find out the minimum page size supported */ - min_pagesz = 1 << __ffs(mmu->geometry.pgsize_bitmap); /* * The virtual address, as well as the size of the mapping, must be * aligned (at least) to the size of the smallest page supported * by the hardware */ - if (!IS_ALIGNED(iova | size, min_pagesz)) { - dev_err(mmu->dev, "unaligned: iova 0x%lx size 0x%zx min_pagesz 0x%x\n", - iova, size, min_pagesz); + if (!IS_ALIGNED(iova | size, IPU3_PAGE_SIZE)) { + dev_err(mmu->dev, "unaligned: iova 0x%lx size 0x%zx\n", + iova, size); return -EINVAL; } @@ -423,10 +398,7 @@ size_t imgu_mmu_unmap(struct imgu_mmu_info *info, unsigned long iova, * or we hit an area that isn't mapped. */ while (unmapped < size) { - size_t pgsize = imgu_mmu_pgsize(mmu->geometry.pgsize_bitmap, - iova, size - unmapped); - - unmapped_page = __imgu_mmu_unmap(mmu, iova, pgsize); + unmapped_page = __imgu_mmu_unmap(mmu, iova, IPU3_PAGE_SIZE); if (!unmapped_page) break; @@ -444,6 +416,7 @@ size_t imgu_mmu_unmap(struct imgu_mmu_info *info, unsigned long iova, /** * imgu_mmu_init() - initialize IPU3 MMU block + * * @parent: struct device parent * @base: IOMEM base of hardware registers. * @@ -505,7 +478,6 @@ struct imgu_mmu_info *imgu_mmu_init(struct device *parent, void __iomem *base) mmu->geometry.aperture_start = 0; mmu->geometry.aperture_end = DMA_BIT_MASK(IPU3_MMU_ADDRESS_BITS); - mmu->geometry.pgsize_bitmap = IPU3_PAGE_SIZE; return &mmu->geometry; @@ -523,7 +495,8 @@ fail_group: /** * imgu_mmu_exit() - clean up IPU3 MMU block - * @info: IPU3 MMU private data + * + * @info: MMU mappable range */ void imgu_mmu_exit(struct imgu_mmu_info *info) { diff --git a/drivers/staging/media/ipu3/ipu3-mmu.h b/drivers/staging/media/ipu3/ipu3-mmu.h index fa58827eb19c..a5f0bca7e7e0 100644 --- a/drivers/staging/media/ipu3/ipu3-mmu.h +++ b/drivers/staging/media/ipu3/ipu3-mmu.h @@ -5,17 +5,18 @@ #ifndef __IPU3_MMU_H #define __IPU3_MMU_H +#define IPU3_PAGE_SHIFT 12 +#define IPU3_PAGE_SIZE (1UL << IPU3_PAGE_SHIFT) + /** * struct imgu_mmu_info - Describes mmu geometry * * @aperture_start: First address that can be mapped * @aperture_end: Last address that can be mapped - * @pgsize_bitmap: Bitmap of page sizes in use */ struct imgu_mmu_info { dma_addr_t aperture_start; dma_addr_t aperture_end; - unsigned long pgsize_bitmap; }; struct device; diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c index a7bc22040ed8..3c7ad1eed434 100644 --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -955,12 +955,12 @@ static const struct v4l2_file_operations imgu_v4l2_fops = { static const struct v4l2_ioctl_ops imgu_v4l2_ioctl_ops = { .vidioc_querycap = imgu_vidioc_querycap, - .vidioc_enum_fmt_vid_cap_mplane = vidioc_enum_fmt_vid_cap, + .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, .vidioc_g_fmt_vid_cap_mplane = imgu_vidioc_g_fmt, .vidioc_s_fmt_vid_cap_mplane = imgu_vidioc_s_fmt, .vidioc_try_fmt_vid_cap_mplane = imgu_vidioc_try_fmt, - .vidioc_enum_fmt_vid_out_mplane = vidioc_enum_fmt_vid_out, + .vidioc_enum_fmt_vid_out = vidioc_enum_fmt_vid_out, .vidioc_g_fmt_vid_out_mplane = imgu_vidioc_g_fmt, .vidioc_s_fmt_vid_out_mplane = imgu_vidioc_s_fmt, .vidioc_try_fmt_vid_out_mplane = imgu_vidioc_try_fmt, |