[RFC v2 6/8] TILER-DMM: Geometry and view manipulation functions

2010-11-30 Thread David Sin
From: Lajos Molnar mol...@ti.com

This patch contains information on TILER geometry, as well as
tiler_view_t object manipulation functions.

It also contains an internal TILER header file to share geometric
information with other TILER files.

Signed-off-by: Lajos Molnar mol...@ti.com
Signed-off-by: David Sin david...@ti.com
---
 drivers/misc/tiler/_tiler.h |   48 +
 drivers/misc/tiler/tiler-geom.c |  362 +++
 2 files changed, 410 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/tiler/_tiler.h
 create mode 100644 drivers/misc/tiler/tiler-geom.c

diff --git a/drivers/misc/tiler/_tiler.h b/drivers/misc/tiler/_tiler.h
new file mode 100644
index 000..0f00330
--- /dev/null
+++ b/drivers/misc/tiler/_tiler.h
@@ -0,0 +1,48 @@
+/*
+ * TI TILER driver internal shared definitions.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _TILER_H
+#define _TILER_H
+
+#include linux/kernel.h
+#include mach/tiler.h
+#include tcm.h
+
+#define TILER_FORMATS  (TILFMT_MAX - TILFMT_MIN + 1)
+
+/* tiler geometry information */
+struct tiler_geom {
+   u32 x_shft; /* unused X-bits (as part of bpp) */
+   u32 y_shft; /* unused Y-bits (as part of bpp) */
+   u32 bpp;/* bytes per pixel */
+   u32 slot_w; /* width of each slot (in pixels) */
+   u32 slot_h; /* height of each slot (in pixels) */
+};
+
+/* methods and variables shared between source files */
+struct tiler_ops {
+   /* geometry operations */
+   void (*xy) (u32 ssptr, u32 *x, u32 *y);
+   u32 (*addr) (enum tiler_fmt fmt, u32 x, u32 y);
+   const struct tiler_geom * (*geom) (enum tiler_fmt fmt);
+
+   u32 page;   /* page size */
+   u32 width;  /* container width */
+   u32 height; /* container height */
+};
+
+void tiler_geom_init(struct tiler_ops *tiler);
+
+#endif
diff --git a/drivers/misc/tiler/tiler-geom.c b/drivers/misc/tiler/tiler-geom.c
new file mode 100644
index 000..df5fe2c
--- /dev/null
+++ b/drivers/misc/tiler/tiler-geom.c
@@ -0,0 +1,362 @@
+/*
+ * TILER geometry functions for TI TILER hardware block.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed as is WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include linux/module.h
+#include _tiler.h
+
+/* bits representing the same slot in DMM-TILER hw-block */
+#define SLOT_WIDTH_BITS6
+#define SLOT_HEIGHT_BITS   6
+
+/* bits reserved to describe coordinates in DMM-TILER hw-block */
+#define CONT_WIDTH_BITS14
+#define CONT_HEIGHT_BITS   13
+
+static struct tiler_geom geom[TILER_FORMATS] = {
+   {
+   .x_shft = 0,
+   .y_shft = 0,
+   },
+   {
+   .x_shft = 0,
+   .y_shft = 1,
+   },
+   {
+   .x_shft = 1,
+   .y_shft = 1,
+   },
+};
+
+/* tiler space addressing bitfields */
+#define MASK_XY_FLIP   (1  31)
+#define MASK_Y_INVERT  (1  30)
+#define MASK_X_INVERT  (1  29)
+#define SHIFT_ACC_MODE 27
+#define MASK_ACC_MODE  3
+
+/* calculated constants */
+#define TILER_PAGE (1  (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
+#define TILER_WIDTH(1  (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
+#define TILER_HEIGHT   (1  (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
+
+#define VIEW_SIZE  (1u  (CONT_WIDTH_BITS + CONT_HEIGHT_BITS))
+#define VIEW_MASK  (VIEW_SIZE - 1u)
+
+#define MASK(bits) ((1  (bits)) - 1)
+
+#define TILER_FMT(x)   ((enum tiler_fmt) \
+   ((x  SHIFT_ACC_MODE)  MASK_ACC_MODE))
+
+#define MASK_VIEW  (MASK_X_INVERT | MASK_Y_INVERT | MASK_XY_FLIP)
+
+/* location of the various tiler views in physical address space */
+#define TILVIEW_8BIT   0x6000u
+#define TILVIEW_16BIT  (TILVIEW_8BIT  + VIEW_SIZE)
+#define TILVIEW_32BIT  (TILVIEW_16BIT + VIEW_SIZE)
+#define TILVIEW_PAGE   (TILVIEW_32BIT + VIEW_SIZE)
+#define TILVIEW_END(TILVIEW_PAGE  + VIEW_SIZE)
+
+/* create tsptr by adding 

Re: [RFC v2 6/8] TILER-DMM: Geometry and view manipulation functions

2010-11-30 Thread Greg KH
On Tue, Nov 30, 2010 at 01:58:57PM -0600, David Sin wrote:
 From: Lajos Molnar mol...@ti.com
 
 This patch contains information on TILER geometry, as well as
 tiler_view_t object manipulation functions.
 
 It also contains an internal TILER header file to share geometric
 information with other TILER files.
 
 Signed-off-by: Lajos Molnar mol...@ti.com
 Signed-off-by: David Sin david...@ti.com
 ---
  drivers/misc/tiler/_tiler.h |   48 +

Ick, no, just name it tiler.h please.  There should not be any need to
put _ in front of a .h file.

 +u32 tiler_bpp(const struct tiler_block_t *b)
 +{
 + enum tiler_fmt fmt = tiler_fmt(b-phys);
 + BUG_ON(fmt == TILFMT_INVALID || fmt == TILFMT_PAGE);

Don't cause the kernel to crash within a driver for no good reason like
this.  Please fix these to WARN_ON if it's really something that can
happen.

If not, then just remove it.

 +
 + return geom[fmt].bpp;
 +}
 +EXPORT_SYMBOL(tiler_bpp);

EXPORT_SYMBOL_GPL() perhaps for all of these?

thanks,

greg k-h
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html