diff options
author | Andy Gross <andy.gross@ti.com> | 2011-06-07 16:54:39 -0500 |
---|---|---|
committer | Suman Anna <s-anna@ti.com> | 2011-06-17 22:39:58 -0500 |
commit | 36cbfc3594048f2cd10b3cd231b2b6f000fbaf53 (patch) | |
tree | d99b233adfa4ae080b667a30d9c8b67135ada07b | |
parent | d442c9a6c0ed679e30d57dcc34b7ee6746e066a3 (diff) | |
download | kernel_samsung_tuna-36cbfc3594048f2cd10b3cd231b2b6f000fbaf53.zip kernel_samsung_tuna-36cbfc3594048f2cd10b3cd231b2b6f000fbaf53.tar.gz kernel_samsung_tuna-36cbfc3594048f2cd10b3cd231b2b6f000fbaf53.tar.bz2 |
TILER: Simplify alignment and offset usage in driver
Slim down APIs by removing alignment and offset. Simplified
calculations based off of align/offset.
Change-Id: I7d7bdb89668a7f553bbbd836f5dc45f6beceab25
Signed-off-by: Andy Gross <andy.gross@ti.com>
-rw-r--r-- | arch/arm/mach-omap2/include/mach/tiler.h | 31 | ||||
-rw-r--r-- | drivers/media/video/tiler/Kconfig | 15 | ||||
-rw-r--r-- | drivers/media/video/tiler/_tiler.h | 11 | ||||
-rw-r--r-- | drivers/media/video/tiler/tiler-iface.c | 27 | ||||
-rw-r--r-- | drivers/media/video/tiler/tiler-ioctl.c | 6 | ||||
-rw-r--r-- | drivers/media/video/tiler/tiler-main.c | 105 | ||||
-rw-r--r-- | drivers/media/video/tiler/tiler-nv12.c | 18 | ||||
-rw-r--r-- | drivers/media/video/tiler/tiler-reserve.c | 11 |
8 files changed, 70 insertions, 154 deletions
diff --git a/arch/arm/mach-omap2/include/mach/tiler.h b/arch/arm/mach-omap2/include/mach/tiler.h index bbb4108..6e25dcc 100644 --- a/arch/arm/mach-omap2/include/mach/tiler.h +++ b/arch/arm/mach-omap2/include/mach/tiler.h @@ -139,13 +139,10 @@ u32 tiler_virt2phys(u32 usr); * must be 0) with the tiler block information. 'height' must be 1 * for 1D block. * @param fmt TILER block format - * @param align block alignment (default: normally PAGE_SIZE) - * @param offs block offset * * @return error status */ -s32 tiler_alloc(struct tiler_block_t *blk, enum tiler_fmt fmt, u32 align, - u32 offs); +s32 tiler_alloc(struct tiler_block_t *blk, enum tiler_fmt fmt); /** * Reserves a 1D or 2D TILER block area and memory for a set process and group @@ -155,15 +152,13 @@ s32 tiler_alloc(struct tiler_block_t *blk, enum tiler_fmt fmt, u32 align, * must be 0) with the tiler block information. 'height' must be 1 * for 1D block. * @param fmt TILER block format - * @param align block alignment (default: normally PAGE_SIZE) - * @param offs block offset * @param gid group ID * @param pid process ID * * @return error status */ -s32 tiler_allocx(struct tiler_block_t *blk, enum tiler_fmt fmt, u32 align, - u32 offs, u32 gid, pid_t pid); +s32 tiler_allocx(struct tiler_block_t *blk, enum tiler_fmt fmt, + u32 gid, pid_t pid); /** * Mmaps a portion of a tiler block to a virtual address. Use this method in @@ -259,11 +254,8 @@ void tiler_free(struct tiler_block_t *blk); * @param fmt TILER format * @param width block width * @param height block height (must be 1 for 1D) - * @param align block alignment (default: PAGE_SIZE) - * @param offs block offset */ -void tiler_reserve(u32 n, enum tiler_fmt fmt, u32 width, u32 height, u32 align, - u32 offs); +void tiler_reserve(u32 n, enum tiler_fmt fmt, u32 width, u32 height); /** * Reserves tiler area for n identical blocks. Use this method to get optimal @@ -274,13 +266,11 @@ void tiler_reserve(u32 n, enum tiler_fmt fmt, u32 width, u32 height, u32 align, * @param fmt TILER bit mode * @param width block width * @param height block height (must be 1 for 1D) - * @param align block alignment (default: PAGE_SIZE) - * @param offs block offset * @param gid group ID * @param pid process ID */ void tiler_reservex(u32 n, enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs, u32 gid, pid_t pid); + u32 gid, pid_t pid); /** * Reserves tiler area for n identical NV12 blocks for the current process. Use @@ -290,10 +280,8 @@ void tiler_reservex(u32 n, enum tiler_fmt fmt, u32 width, u32 height, * @param n number of identical set of blocks * @param width block width (Y) * @param height block height (Y) - * @param align block alignment (default: PAGE_SIZE) - * @param offs block offset */ -void tiler_reserve_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs); +void tiler_reserve_nv12(u32 n, u32 width, u32 height); /** * Reserves tiler area for n identical NV12 blocks. Use this method to get @@ -303,13 +291,10 @@ void tiler_reserve_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs); * @param n number of identical set of blocks * @param width block width (Y) * @param height block height (Y) - * @param align block alignment (default: PAGE_SIZE) - * @param offs block offset * @param gid group ID * @param pid process ID */ -void tiler_reservex_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs, - u32 gid, pid_t pid); +void tiler_reservex_nv12(u32 n, u32 width, u32 height, u32 gid, pid_t pid); /** * Create a view based on a tiler address and width and height @@ -431,8 +416,6 @@ struct tiler_block_info { u32 id; u32 key; u32 group_id; - u32 align; /* alignment requirements for ssptr */ - u32 offs; /* offset (ssptr & (align - 1) will equal offs) */ u32 ssptr; /* physical address, may not exposed by default */ }; diff --git a/drivers/media/video/tiler/Kconfig b/drivers/media/video/tiler/Kconfig index 65f8d7e..202f7f8 100644 --- a/drivers/media/video/tiler/Kconfig +++ b/drivers/media/video/tiler/Kconfig @@ -31,21 +31,6 @@ config TILER_GRANULARITY Supported values are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096. -config TILER_ALIGNMENT - int "Allocation alignment (2^n)" - range 1 4096 - default 4096 - depends on TI_TILER - help - This option sets the default TILER allocation alignment. It can - be overriden by the tiler.align boot argument. - - Must be a 2^n in the range of 1 to 4096; however, it is naturally - aligned to the TILER granularity. - - Supported values are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, - 2048, 4096. - config TILER_CACHE_LIMIT int "Memory limit to cache free pages in MBytes" range 0 128 diff --git a/drivers/media/video/tiler/_tiler.h b/drivers/media/video/tiler/_tiler.h index 2c8f769..9da70d0 100644 --- a/drivers/media/video/tiler/_tiler.h +++ b/drivers/media/video/tiler/_tiler.h @@ -110,16 +110,16 @@ struct tiler_geom { struct tiler_ops { /* block operations */ s32 (*alloc) (enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs, u32 key, + u32 key, u32 gid, struct process_info *pi, struct mem_info **info); s32 (*pin) (enum tiler_fmt fmt, u32 width, u32 height, u32 key, u32 gid, struct process_info *pi, struct mem_info **info, u32 usr_addr); - void (*reserve_nv12) (u32 n, u32 width, u32 height, u32 align, u32 offs, + void (*reserve_nv12) (u32 n, u32 width, u32 height, u32 gid, struct process_info *pi); void (*reserve) (u32 n, enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs, u32 gid, struct process_info *pi); + u32 gid, struct process_info *pi); void (*unreserve) (u32 gid, struct process_info *pi); /* block access operations */ @@ -129,7 +129,7 @@ struct tiler_ops { void (*unlock_free) (struct mem_info *mi, bool free); s32 (*lay_2d) (enum tiler_fmt fmt, u16 n, u16 w, u16 h, u16 band, - u16 align, u16 offs, struct gid_info *gi, + u16 align, struct gid_info *gi, struct list_head *pos); #ifdef CONFIG_TILER_ENABLE_NV12 s32 (*lay_nv12) (int n, u16 w, u16 w1, u16 h, struct gid_info *gi, @@ -146,8 +146,7 @@ struct tiler_ops { /* area operations */ s32 (*analize) (enum tiler_fmt fmt, u32 width, u32 height, - u16 *x_area, u16 *y_area, u16 *band, - u16 *align, u16 *offs, u16 *in_offs); + u16 *x_area, u16 *y_area, u16 *band, u16 *align); /* process operations */ void (*cleanup) (void); diff --git a/drivers/media/video/tiler/tiler-iface.c b/drivers/media/video/tiler/tiler-iface.c index 69bfe81..b7d84d5 100644 --- a/drivers/media/video/tiler/tiler-iface.c +++ b/drivers/media/video/tiler/tiler-iface.c @@ -166,42 +166,41 @@ u32 tiler_virt2phys(u32 usr) EXPORT_SYMBOL(tiler_virt2phys); void tiler_reservex(u32 n, enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs, u32 gid, pid_t pid) + u32 gid, pid_t pid) { struct process_info *pi = __get_pi(pid, true); if (pi) - ops->reserve(n, fmt, width, height, align, offs, gid, pi); + ops->reserve(n, fmt, width, height, gid, pi); } EXPORT_SYMBOL(tiler_reservex); -void tiler_reserve(u32 n, enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs) +void tiler_reserve(u32 n, enum tiler_fmt fmt, u32 width, u32 height) { - tiler_reservex(n, fmt, width, height, align, offs, 0, current->tgid); + tiler_reservex(n, fmt, width, height, 0, current->tgid); } EXPORT_SYMBOL(tiler_reserve); #ifdef CONFIG_TILER_ENABLE_NV12 -void tiler_reservex_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs, +void tiler_reservex_nv12(u32 n, u32 width, u32 height, u32 gid, pid_t pid) { struct process_info *pi = __get_pi(pid, true); if (pi) - ops->reserve_nv12(n, width, height, align, offs, gid, pi); + ops->reserve_nv12(n, width, height, gid, pi); } EXPORT_SYMBOL(tiler_reservex_nv12); -void tiler_reserve_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs) +void tiler_reserve_nv12(u32 n, u32 width, u32 height) { - tiler_reservex_nv12(n, width, height, align, offs, 0, current->tgid); + tiler_reservex_nv12(n, width, height, 0, current->tgid); } EXPORT_SYMBOL(tiler_reserve_nv12); #endif s32 tiler_allocx(struct tiler_block_t *blk, enum tiler_fmt fmt, - u32 align, u32 offs, u32 gid, pid_t pid) + u32 gid, pid_t pid) { struct mem_info *mi; struct process_info *pi; @@ -213,8 +212,7 @@ s32 tiler_allocx(struct tiler_block_t *blk, enum tiler_fmt fmt, if (!pi) return -ENOMEM; - res = ops->alloc(fmt, blk->width, blk->height, align, offs, blk->key, - gid, pi, &mi); + res = ops->alloc(fmt, blk->width, blk->height, blk->key, gid, pi, &mi); if (mi) { blk->phys = mi->blk.phys; blk->id = mi->blk.id; @@ -223,10 +221,9 @@ s32 tiler_allocx(struct tiler_block_t *blk, enum tiler_fmt fmt, } EXPORT_SYMBOL(tiler_allocx); -s32 tiler_alloc(struct tiler_block_t *blk, enum tiler_fmt fmt, - u32 align, u32 offs) +s32 tiler_alloc(struct tiler_block_t *blk, enum tiler_fmt fmt) { - return tiler_allocx(blk, fmt, align, offs, 0, current->tgid); + return tiler_allocx(blk, fmt, 0, current->tgid); } EXPORT_SYMBOL(tiler_alloc); diff --git a/drivers/media/video/tiler/tiler-ioctl.c b/drivers/media/video/tiler/tiler-ioctl.c index 9c4e131..3cb0abf 100644 --- a/drivers/media/video/tiler/tiler-ioctl.c +++ b/drivers/media/video/tiler/tiler-ioctl.c @@ -245,7 +245,6 @@ static long tiler_ioctl(struct file *filp, u32 cmd, unsigned long arg) switch (block_info.fmt) { case TILFMT_PAGE: r = ops->alloc(block_info.fmt, block_info.dim.len, 1, - block_info.align, block_info.offs, block_info.key, block_info.group_id, pi, &mi); break; @@ -255,7 +254,6 @@ static long tiler_ioctl(struct file *filp, u32 cmd, unsigned long arg) r = ops->alloc(block_info.fmt, block_info.dim.area.width, block_info.dim.area.height, - block_info.align, block_info.offs, block_info.key, block_info.group_id, pi, &mi); break; @@ -410,8 +408,6 @@ static long tiler_ioctl(struct file *filp, u32 cmd, unsigned long arg) ops->reserve_nv12(block_info.key, block_info.dim.area.width, block_info.dim.area.height, - block_info.align, - block_info.offs, block_info.group_id, pi); #else return -EINVAL; @@ -421,8 +417,6 @@ static long tiler_ioctl(struct file *filp, u32 cmd, unsigned long arg) block_info.fmt, block_info.dim.area.width, block_info.dim.area.height, - block_info.align, - block_info.offs, block_info.group_id, pi); break; /* unreserve blocks */ diff --git a/drivers/media/video/tiler/tiler-main.c b/drivers/media/video/tiler/tiler-main.c index 92aac12..e972196 100644 --- a/drivers/media/video/tiler/tiler-main.c +++ b/drivers/media/video/tiler/tiler-main.c @@ -38,7 +38,6 @@ #include "tcm/tcm-sita.h" /* TCM algorithm */ static bool ssptr_id = CONFIG_TILER_SSPTR_ID; -static uint default_align = CONFIG_TILER_ALIGNMENT; static uint granularity = CONFIG_TILER_GRANULARITY; /* @@ -48,8 +47,6 @@ static uint granularity = CONFIG_TILER_GRANULARITY; */ module_param(ssptr_id, bool, 0444); MODULE_PARM_DESC(ssptr_id, "Use ssptr as block ID"); -module_param_named(align, default_align, uint, 0644); -MODULE_PARM_DESC(align, "Default block ssptr alignment"); module_param_named(grain, granularity, uint, 0644); MODULE_PARM_DESC(grain, "Granularity (bytes)"); @@ -283,29 +280,23 @@ static inline void _m_area_free(struct area_info *ai) static s32 __analize_area(enum tiler_fmt fmt, u32 width, u32 height, u16 *x_area, u16 *y_area, u16 *band, - u16 *align, u16 *offs, u16 *in_offs) + u16 *align) { - /* input: width, height is in pixels, align, offs in bytes */ - /* output: x_area, y_area, band, align, offs in slots */ + /* input: width, height is in pixels */ + /* output: x_area, y_area, band, align */ /* slot width, height, and row size */ u32 slot_row, min_align; const struct tiler_geom *g; + /* set alignment to page size */ + *align = PAGE_SIZE; + /* width and height must be positive */ if (!width || !height) return -EINVAL; - /* align must be 2 power */ - if (*align & (*align - 1)) - return -EINVAL; - if (fmt == TILFMT_PAGE) { - /* adjust size to accomodate offset, only do page alignment */ - *align = PAGE_SIZE; - *in_offs = *offs & ~PAGE_MASK; - width += *in_offs; - /* for 1D area keep the height (1), width is in tiler slots */ *x_area = DIV_ROUND_UP(width, tiler.page); *y_area = *band = 1; @@ -326,33 +317,14 @@ static s32 __analize_area(enum tiler_fmt fmt, u32 width, u32 height, /* how many slots are can be accessed via one physical page */ *band = PAGE_SIZE / slot_row; - /* minimum alignment is at least 1 slot. Use default if needed */ + /* minimum alignment is at least 1 slot */ min_align = max(slot_row, granularity); - *align = ALIGN(*align ? : default_align, min_align); - - /* align must still be 2 power (in case default_align is wrong) */ - if (*align & (*align - 1)) - return -EAGAIN; - - /* offset must be multiple of bpp */ - if (*offs & (g->bpp - 1) || *offs >= *align) - return -EINVAL; - - /* round down the offset to the nearest slot size, and increase width - to allow space for having the correct offset */ - width += (*offs & (min_align - 1)) / g->bpp; - if (in_offs) - *in_offs = *offs & (min_align - 1); - *offs &= ~(min_align - 1); - - /* expand width to block size */ - width = ALIGN(width, min_align / g->bpp); + *align = ALIGN(*align, min_align); /* adjust to slots */ *x_area = DIV_ROUND_UP(width, g->slot_w); *y_area = DIV_ROUND_UP(height, g->slot_h); *align /= slot_row; - *offs /= slot_row; if (*x_area > tiler.width || *y_area > tiler.height) return -ENOMEM; @@ -367,7 +339,6 @@ static s32 __analize_area(enum tiler_fmt fmt, u32 width, u32 height, * * @param w Width of the block. * @param align Alignment of the block. - * @param offs Offset of the block (within alignment) * @param ai Pointer to area info * @param next Pointer to the variable where the next block * will be stored. The block should be inserted @@ -378,10 +349,10 @@ static s32 __analize_area(enum tiler_fmt fmt, u32 width, u32 height, * * (must have mutex) */ -static u16 _m_blk_find_fit(u16 w, u16 align, u16 offs, +static u16 _m_blk_find_fit(u16 w, u16 align, struct area_info *ai, struct list_head **before) { - int x = ai->area.p0.x + w + offs; + int x = ai->area.p0.x + w; struct mem_info *mi; /* area blocks are sorted by x */ @@ -391,7 +362,7 @@ static u16 _m_blk_find_fit(u16 w, u16 align, u16 offs, *before = &mi->by_area; return x; } - x = ALIGN(mi->area.p1.x + 1 - offs, align) + w + offs; + x = ALIGN(mi->area.p1.x + 1, align) + w; } *before = &ai->blocks; @@ -413,7 +384,7 @@ struct mem_info *_m_add2area(struct mem_info *mi, struct area_info *ai, return mi; } -static struct mem_info *get_2d_area(u16 w, u16 h, u16 align, u16 offs, u16 band, +static struct mem_info *get_2d_area(u16 w, u16 h, u16 align, u16 band, struct gid_info *gi, struct tcm *tcm) { struct area_info *ai = NULL; @@ -429,7 +400,7 @@ static struct mem_info *get_2d_area(u16 w, u16 h, u16 align, u16 offs, u16 band, if (mi->area.tcm == tcm && tcm_aheight(mi->area) == h && tcm_awidth(mi->area) == w && - (mi->area.p0.x & (align - 1)) == offs) { + (mi->area.p0.x & (align - 1)) == 0) { /* this area is already set up */ /* remove from reserved list */ @@ -451,7 +422,7 @@ static struct mem_info *get_2d_area(u16 w, u16 h, u16 align, u16 offs, u16 band, list_for_each_entry(ai, &gi->areas, by_gid) { if (ai->area.tcm == tcm && tcm_aheight(ai->area) == h) { - x = _m_blk_find_fit(w, align, offs, ai, &before); + x = _m_blk_find_fit(w, align, ai, &before); if (x) { _m_add2area(mi, ai, x - w, w, before); goto done; @@ -461,10 +432,10 @@ static struct mem_info *get_2d_area(u16 w, u16 h, u16 align, u16 offs, u16 band, mutex_unlock(&mtx); /* if no area fit, reserve a new one */ - ai = area_new_m(ALIGN(w + offs, max(band, align)), h, + ai = area_new_m(ALIGN(w, max(band, align)), h, max(band, align), tcm, gi); if (ai) { - _m_add2area(mi, ai, ai->area.p0.x + offs, w, &ai->blocks); + _m_add2area(mi, ai, ai->area.p0.x, w, &ai->blocks); } else { /* clean up */ kfree(mi); @@ -477,9 +448,9 @@ done: } /* layout reserved 2d blocks in a larger area */ -/* NOTE: band, w, h, a(lign), o(ffs) is in slots */ +/* NOTE: band, w, h, a(lign) is in slots */ static s32 lay_2d(enum tiler_fmt fmt, u16 n, u16 w, u16 h, u16 band, - u16 align, u16 offs, struct gid_info *gi, + u16 align, struct gid_info *gi, struct list_head *pos) { u16 x, x0, e = ALIGN(w, align), w_res = (n - 1) * e + w; @@ -489,15 +460,15 @@ static s32 lay_2d(enum tiler_fmt fmt, u16 n, u16 w, u16 h, u16 band, printk(KERN_INFO "packing %u %u buffers into %u width\n", n, w, w_res); - /* calculate dimensions, band, offs and alignment in slots */ + /* calculate dimensions, band, and alignment in slots */ /* reserve an area */ - ai = area_new_m(ALIGN(w_res + offs, max(band, align)), h, + ai = area_new_m(ALIGN(w_res, max(band, align)), h, max(band, align), tcm[fmt], gi); if (!ai) return -ENOMEM; /* lay out blocks in the reserved area */ - for (n = 0, x = offs; x < w_res; x += e, n++) { + for (n = 0, x = 0; x < w_res; x += e, n++) { /* reserve a block struct */ mi = kmalloc(sizeof(*mi), GFP_KERNEL); if (!mi) @@ -860,8 +831,6 @@ static void fill_block_info(struct mem_info *i, struct tiler_block_info *blk) } blk->id = i->blk.id; blk->key = i->blk.key; - blk->offs = i->blk.phys & ~PAGE_MASK; - blk->align = PAGE_SIZE; } /* @@ -869,15 +838,14 @@ static void fill_block_info(struct mem_info *i, struct tiler_block_info *blk) * ========================================================================== */ static struct mem_info *alloc_area(enum tiler_fmt fmt, u32 width, u32 height, - u16 align, u16 offs, struct gid_info *gi) + struct gid_info *gi) { - u16 x, y, band, in_offs = 0; + u16 x, y, band, align; struct mem_info *mi = NULL; const struct tiler_geom *g = tiler.geom(fmt); - /* calculate dimensions, band, offs and alignment in slots */ - if (__analize_area(fmt, width, height, &x, &y, &band, &align, &offs, - &in_offs)) + /* calculate dimensions, band, and alignment in slots */ + if (__analize_area(fmt, width, height, &x, &y, &band, &align)) return NULL; if (fmt == TILFMT_PAGE) { @@ -896,7 +864,7 @@ static struct mem_info *alloc_area(enum tiler_fmt fmt, u32 width, u32 height, mi->parent = gi; list_add(&mi->by_area, &gi->onedim); } else { - mi = get_2d_area(x, y, align, offs, band, gi, tcm[fmt]); + mi = get_2d_area(x, y, align, band, gi, tcm[fmt]); if (!mi) return NULL; @@ -910,20 +878,19 @@ static struct mem_info *alloc_area(enum tiler_fmt fmt, u32 width, u32 height, mutex_unlock(&mtx); mi->blk.phys = tiler.addr(fmt, - mi->area.p0.x * g->slot_w, mi->area.p0.y * g->slot_h) - + in_offs; + mi->area.p0.x * g->slot_w, mi->area.p0.y * g->slot_h); return mi; } static struct mem_info *alloc_block_area(enum tiler_fmt fmt, u32 width, - u32 height, u32 align, u32 offs, u32 key, u32 gid, + u32 height, u32 key, u32 gid, struct process_info *pi) { struct mem_info *mi = NULL; struct gid_info *gi = NULL; /* only support up to page alignment */ - if (align > PAGE_SIZE || offs >= (align ? : default_align) || !pi) + if (!pi) return ERR_PTR(-EINVAL); /* get group context */ @@ -935,7 +902,7 @@ static struct mem_info *alloc_block_area(enum tiler_fmt fmt, u32 width, return ERR_PTR(-ENOMEM); /* reserve area in tiler container */ - mi = alloc_area(fmt, width, height, align, offs, gi); + mi = alloc_area(fmt, width, height, gi); if (!mi) { mutex_lock(&mtx); gi->refs--; @@ -1015,7 +982,7 @@ static struct tiler_pa_info *get_new_pa(struct tmm *tmm, u32 num_pg) } static s32 alloc_block(enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs, u32 key, u32 gid, struct process_info *pi, + u32 key, u32 gid, struct process_info *pi, struct mem_info **info) { struct mem_info *mi; @@ -1025,7 +992,7 @@ static s32 alloc_block(enum tiler_fmt fmt, u32 width, u32 height, *info = NULL; /* allocate tiler container area */ - mi = alloc_block_area(fmt, width, height, align, offs, key, gid, pi); + mi = alloc_block_area(fmt, width, height, key, gid, pi); if (IS_ERR_OR_NULL(mi)) return mi ? -ENOMEM : PTR_ERR(mi); @@ -1167,7 +1134,7 @@ static s32 pin_any_block(enum tiler_fmt fmt, u32 width, u32 height, goto done; /* get allocation area */ - mi = alloc_block_area(fmt, width, height, 0, 0, key, gid, pi); + mi = alloc_block_area(fmt, width, height, key, gid, pi); if (IS_ERR_OR_NULL(mi)) { res = mi ? PTR_ERR(mi) : -ENOMEM; goto done; @@ -1247,9 +1214,7 @@ static s32 __init tiler_init(void) #endif /* check module parameters for correctness */ - if (default_align > PAGE_SIZE || - default_align & (default_align - 1) || - granularity < 1 || granularity > PAGE_SIZE || + if (granularity < 1 || granularity > PAGE_SIZE || granularity & (granularity - 1)) return -EINVAL; @@ -1402,7 +1367,7 @@ EXPORT_SYMBOL(tiler_free_block); tiler_blk_handle tiler_alloc_block_area(u32 size) { - return alloc_block_area(TILFMT_PAGE, size >> PAGE_SHIFT, 1, 0, 0, 0, 0, + return alloc_block_area(TILFMT_PAGE, size >> PAGE_SHIFT, 1, 0, 0, __get_pi(0, true)); } EXPORT_SYMBOL(tiler_alloc_block_area); diff --git a/drivers/media/video/tiler/tiler-nv12.c b/drivers/media/video/tiler/tiler-nv12.c index c16a140..e166122 100644 --- a/drivers/media/video/tiler/tiler-nv12.c +++ b/drivers/media/video/tiler/tiler-nv12.c @@ -333,29 +333,23 @@ static u16 nv12_together(u16 o, u16 a, u16 w, u16 n, u16 *area, u8 *packing) } /* reserve nv12 blocks */ -static void reserve_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs, +static void reserve_nv12(u32 n, u32 width, u32 height, u32 gid, struct process_info *pi) { - u16 w, h, band, a = align, o = offs; + u16 w, h, band, a, o = 0; struct gid_info *gi; int res = 0, res2, i; u16 n_t, n_s, area_t, area_s; u8 packing[2 * MAX_ANY]; struct list_head reserved = LIST_HEAD_INIT(reserved); - /* adjust alignment to the largest slot width (128 bytes) */ - a = max_t(u16, PAGE_SIZE / min(band_8, band_16), a); - /* Check input parameters for correctness, and support */ if (!width || !height || !n || - offs >= align || offs & 1 || - align >= PAGE_SIZE || n > ops->width * ops->height / 2) return; - /* calculate dimensions, band, offs and alignment in slots */ - if (ops->analize(TILFMT_8BIT, width, height, &w, &h, &band, &a, &o, - NULL)) + /* calculate dimensions, band, and alignment in slots */ + if (ops->analize(TILFMT_8BIT, width, height, &w, &h, &band, &a)) return; /* get group context */ @@ -384,10 +378,10 @@ static void reserve_nv12(u32 n, u32 width, u32 height, u32 align, u32 offs, * able to reserve both 8- and 16-bit blocks as the * offsets of them must match. */ - res = ops->lay_2d(TILFMT_8BIT, n_s, w, h, band_8, a, o, + res = ops->lay_2d(TILFMT_8BIT, n_s, w, h, band_8, a, gi, &reserved); res2 = ops->lay_2d(TILFMT_16BIT, n_s, (w + 1) >> 1, h, - band_16, a >> 1, o >> 1, gi, &reserved); + band_16, a >> 1, gi, &reserved); if (res2 < 0 || res < 0 || res != res2) { /* clean up */ diff --git a/drivers/media/video/tiler/tiler-reserve.c b/drivers/media/video/tiler/tiler-reserve.c index 770fb07..fbabc6d 100644 --- a/drivers/media/video/tiler/tiler-reserve.c +++ b/drivers/media/video/tiler/tiler-reserve.c @@ -77,17 +77,16 @@ u32 tiler_best2pack(u16 o, u16 a, u16 b, u16 w, u16 *n, u16 *_area) /* reserve 2d blocks */ static void reserve_blocks(u32 n, enum tiler_fmt fmt, u32 width, u32 height, - u32 align, u32 offs, u32 gid, + u32 gid, struct process_info *pi) { u32 bpt, res = 0, i; - u16 o = offs, a = align, band, w, h, n_try; + u16 a, band, w, h, n_try; struct gid_info *gi; const struct tiler_geom *g; /* Check input parameters for correctness, and support */ if (!width || !height || !n || - align > PAGE_SIZE || offs >= align || fmt < TILFMT_8BIT || fmt > TILFMT_32BIT) return; @@ -100,7 +99,7 @@ static void reserve_blocks(u32 n, enum tiler_fmt fmt, u32 width, u32 height, * sufficient. Also check for basic area info. */ if (width * g->bpp * 2 <= PAGE_SIZE || - ops->analize(fmt, width, height, &w, &h, &band, &a, &o, NULL)) + ops->analize(fmt, width, height, &w, &h, &band, &a)) return; /* get group id */ @@ -112,12 +111,12 @@ static void reserve_blocks(u32 n, enum tiler_fmt fmt, u32 width, u32 height, for (i = 0; i < n && res >= 0; i += res + 1) { /* blocks to allocate in one area */ n_try = min(n - i, ops->width); - tiler_best2pack(offs, a, band, w, &n_try, NULL); + tiler_best2pack(0, a, band, w, &n_try, NULL); res = -1; while (n_try > 1) { /* adjust res so we fail on 0 return value */ - res = ops->lay_2d(fmt, n_try, w, h, band, a, o, + res = ops->lay_2d(fmt, n_try, w, h, band, a, gi, &gi->reserved) - 1; if (res >= 0) break; |