summaryrefslogtreecommitdiff
path: root/drivers/media/video/tiler
diff options
context:
space:
mode:
authorLajos Molnar <molnar@ti.com>2011-04-07 08:41:51 +0100
committerAndy Green <andy.green@linaro.org>2011-04-07 08:41:51 +0100
commite09b54a18acb1da4ce596099b24d122886bb745c (patch)
tree3f316c88eac0ea3273bb74bd2d0fdd6eb8f697ae /drivers/media/video/tiler
parentb9161226bfbf0b95c0b69de453d4669fe0eab819 (diff)
TILER: Cleaned up tcm API definitions.
Fixed comments. Removed unused methods. Removed AREA_FMT macro that caused a checkpatch failure. Added further error checking to tcm methods. Signed-off-by: Lajos Molnar <molnar@ti.com> Signed-off-by: David Sin <davidsin@ti.com>
Diffstat (limited to 'drivers/media/video/tiler')
-rw-r--r--drivers/media/video/tiler/tcm.h64
-rw-r--r--drivers/media/video/tiler/tcm/tcm-utils.h19
2 files changed, 34 insertions, 49 deletions
diff --git a/drivers/media/video/tiler/tcm.h b/drivers/media/video/tiler/tcm.h
index ccd3ce4eaaa..abeb99b6697 100644
--- a/drivers/media/video/tiler/tcm.h
+++ b/drivers/media/video/tiler/tcm.h
@@ -4,6 +4,8 @@
* TILER container manager specification and support functions for TI
* processors.
*
+ * Author: Lajos Molnar <molnar@ti.com>
+ *
* Copyright (C) 2009-2010 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
@@ -15,19 +17,18 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef _TCM_H_
-#define _TCM_H_
-
-#include <linux/init.h>
-#include <linux/module.h>
+#ifndef TCM_H
+#define TCM_H
struct tcm;
+/* point */
struct tcm_pt {
u16 x;
u16 y;
};
+/* 1d or 2d area */
struct tcm_area {
bool is2d; /* whether are is 1d or 2d */
struct tcm *tcm; /* parent */
@@ -90,8 +91,6 @@ struct tcm *name(u16 width, u16 height, typeof(attr_t) *attr);
/**
* Deinitialize tiler container manager.
*
- * @author Ravi Ramachandra (3/1/2010)
- *
* @param tcm Pointer to container manager.
*
* @return 0 on success, non-0 error value on error. The call
@@ -108,8 +107,6 @@ static inline void tcm_deinit(struct tcm *tcm)
/**
* Reserves a 2D area in the container.
*
- * @author Ravi Ramachandra (3/1/2010)
- *
* @param tcm Pointer to container manager.
* @param height Height(in pages) of area to be reserved.
* @param width Width(in pages) of area to be reserved.
@@ -129,13 +126,17 @@ static inline s32 tcm_reserve_2d(struct tcm *tcm, u16 width, u16 height,
u16 align, struct tcm_area *area)
{
/* perform rudimentary error checking */
- s32 res = (tcm == NULL ? -ENODEV :
- area == NULL ? -EINVAL :
- (height > tcm->height || width > tcm->width) ? -ENOMEM :
- tcm->reserve_2d(tcm, height, width, align, area));
-
- if (area)
+ s32 res = tcm == NULL ? -ENODEV :
+ (area == NULL || width == 0 || height == 0 ||
+ /* align must be a 2 power */
+ align & (align - 1)) ? -EINVAL :
+ (height > tcm->height || width > tcm->width) ? -ENOMEM : 0;
+
+ if (!res) {
+ area->is2d = true;
+ res = tcm->reserve_2d(tcm, height, width, align, area);
area->tcm = res ? NULL : tcm;
+ }
return res;
}
@@ -143,8 +144,6 @@ static inline s32 tcm_reserve_2d(struct tcm *tcm, u16 width, u16 height,
/**
* Reserves a 1D area in the container.
*
- * @author Ravi Ramachandra (3/1/2010)
- *
* @param tcm Pointer to container manager.
* @param slots Number of (contiguous) slots to reserve.
* @param area Pointer to where the reserved area should be stored.
@@ -159,13 +158,15 @@ static inline s32 tcm_reserve_1d(struct tcm *tcm, u32 slots,
struct tcm_area *area)
{
/* perform rudimentary error checking */
- s32 res = (tcm == NULL ? -ENODEV :
- area == NULL ? -EINVAL :
- slots > (tcm->width * (u32) tcm->height) ? -ENOMEM :
- tcm->reserve_1d(tcm, slots, area));
+ s32 res = tcm == NULL ? -ENODEV :
+ (area == NULL || slots == 0) ? -EINVAL :
+ slots > (tcm->width * (u32) tcm->height) ? -ENOMEM : 0;
- if (area)
+ if (!res) {
+ area->is2d = false;
+ res = tcm->reserve_1d(tcm, slots, area);
area->tcm = res ? NULL : tcm;
+ }
return res;
}
@@ -173,8 +174,6 @@ static inline s32 tcm_reserve_1d(struct tcm *tcm, u32 slots,
/**
* Free a previously reserved area from the container.
*
- * @author Ravi Ramachandra (3/1/2010)
- *
* @param area Pointer to area reserved by a prior call to
* tcm_reserve_1d or tcm_reserve_2d call, whether
* it was successful or not. (Note: all fields of
@@ -209,8 +208,6 @@ static inline s32 tcm_free(struct tcm_area *area)
* fit in a 2D slice, its tcm pointer is set to NULL to mark that it is no
* longer a valid area.
*
- * @author Lajos Molnar (3/17/2010)
- *
* @param parent Pointer to a VALID parent area that will get modified
* @param slice Pointer to the slice area that will get modified
*/
@@ -234,16 +231,10 @@ static inline void tcm_slice(struct tcm_area *parent, struct tcm_area *slice)
}
}
-/**
- * Verifies if a tcm area is logically valid.
- *
- * @param area Pointer to tcm area
- *
- * @return TRUE if area is logically valid, FALSE otherwise.
- */
+/* Verify if a tcm area is logically valid */
static inline bool tcm_area_is_valid(struct tcm_area *area)
{
- return (area && area->tcm &&
+ return area && area->tcm &&
/* coordinate bounds */
area->p1.x < area->tcm->width &&
area->p1.y < area->tcm->height &&
@@ -255,8 +246,7 @@ static inline bool tcm_area_is_valid(struct tcm_area *area)
area->p1.x + area->p1.y * area->tcm->width) ||
/* 2D coordinate relationship */
(area->is2d &&
- area->p0.x <= area->p1.x))
- );
+ area->p0.x <= area->p1.x));
}
/* see if a coordinate is within an area */
@@ -316,4 +306,4 @@ static inline u16 __tcm_sizeof(struct tcm_area *area)
tcm_slice(&safe, &var); \
var.tcm; tcm_slice(&safe, &var))
-#endif /* _TCM_H_ */
+#endif
diff --git a/drivers/media/video/tiler/tcm/tcm-utils.h b/drivers/media/video/tiler/tcm/tcm-utils.h
index 1013929a455..0d1260af197 100644
--- a/drivers/media/video/tiler/tcm/tcm-utils.h
+++ b/drivers/media/video/tiler/tcm/tcm-utils.h
@@ -3,6 +3,8 @@
*
* Utility functions for implementing TILER container managers.
*
+ * Author: Lajos Molnar <molnar@ti.com>
+ *
* Copyright (C) 2009-2010 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
@@ -14,19 +16,17 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef _TCM_UTILS_H
-#define _TCM_UTILS_H
+#ifndef TCM_UTILS_H
+#define TCM_UTILS_H
#include "../tcm.h"
-#define AREA_FMT "(%03d %03d)-(%03d %03d)"
-#define AREA(area) (area).p0.x, (area).p0.y, (area).p1.x, (area).p1.y
-
/* TCM_ALG_NAME must be defined to use the debug methods */
#ifdef DEBUG
#define IFDEBUG(x) x
#else
+/* compile-check debug statements even if not DEBUG */
#define IFDEBUG(x) do { if (0) x; } while (0)
#endif
@@ -38,7 +38,8 @@
#define P2(fmt, ...) P(KERN_INFO, fmt, ##__VA_ARGS__)
#define P3(fmt, ...) P(KERN_DEBUG, fmt, ##__VA_ARGS__)
-#define PA(level, msg, p_area) P##level(msg " " AREA_FMT "\n", AREA(*(p_area)))
+#define PA(level, msg, p_area) P##level(msg " (%03d %03d)-(%03d %03d)\n", \
+ (p_area)->p0.x, (p_area)->p0.y, (p_area)->p1.x, (p_area)->p1.y)
/* assign coordinates to area */
static inline
@@ -50,10 +51,4 @@ void assign(struct tcm_area *a, u16 x0, u16 y0, u16 x1, u16 y1)
a->p1.y = y1;
}
-static inline
-void dump_area(struct tcm_area *area)
-{
- printk(KERN_NOTICE AREA_FMT "\n", AREA(*area));
-}
-
#endif