Skip to contentSkip to conversation

TI DMM-TILER driver

PATCH In review David Sin 4 participants 19 messages Dec 6, 2010 – Dec 22, 2010

Subsystems (5)
lore
Share & tools
lore

David Sin

author
#0 lore raw

cover TI DMM-TILER driver

Tiling and Isometric Lightweight Engine for Rotation (TILER) driver
=====

Dynamic Memory Manager (DMM) is a hardware block made by Texas Instruments. Within the DMM exists at least one TILER hardware component. Its purpose is to organize video/image memory in a 2-dimensional fashion to limit memory bandwidth and facilitate 0 effort rotation and mirroring. The TILER driver facilitates allocating, freeing, as well as mapping 2D blocks (areas) in the TILER container(s). It also facilitates rotating and mirroring the allocated blocks or its rectangular subsections.

TERMINOLOGY

"slot"

The basic TILER driver operates on blocks of slots. A slot is the granularity of the TILER hardware device. For all current uses it is 4K, but could also be 16 or 64K. The DMM-TILER TRM refers to this as "page" but we want to separate this concept from the MMU pages.

"page"

The granularity of the MMU, used by the kernel. This is 4K.

"block"

The TILER hardware component supports 1D and 2D blocks. A 2D block is a rectangular arrangement of slots with arbitrary width and height in a 2D container. A 1D block is a linear arrangement of slots with arbitrary length
in a 1D container. This TILER driver only supports 2D blocks.

"container"

The TILER driver supports an arbitrary TILER container size. However, for all current implementations it is 256 by 128 slots. The container currently can only be used as a 2D container.

"reserved area"

Each block resides within a reserved area in the container. This area may be larger than the actual set of slots that a block occupies. The reason for this is to protect access from one block into another. Since TILER container is mmap-ped into user space as individual pages, all slots that are spanned by that page become visible to the user. The tiler driver allows restricting the granularity of the reserved area (default alignment) as well as the mapped area (granularity).

Technical Reference Manual
=====
http://focus.ti.com/pdfs/wtbu/OMAP4430_ES2.x_PUBLIC_TRM_vN.zip

Changes since RFC v2: https://lkml.org/lkml/2010/11/30/352
=====
Randy Dunlap:
1) Clarify the meaning of 2^n when referring to TILER alignment and allocation granularity

Greg KH:
1) Move tiler.h to include/linux since it's not arch specific
2) Rename _tiler.h to tiler-geom.h (ick)
3) Use WARN_ON instead of BUG_ON
4) Export symbols as 'EXPORT_SYMBOL_GPL'
5) Remove comment from Kconfig file

Santosh Shilimkar:
1) Create separate DMM OMAP device file patch (#9)

Changes since RFC v1: http://www.spinics.net/lists/linux-omap/msg33867.html
=====
Santosh Shilimkar:
1) Correct documentation location
2) Remove ioremap of RAM
3) Implement probe function and hwmod
4) Correct commenting style
5) Reduce use of barrier instances

Linus Walleij:
1) Define TCM acryonym

Russell King:
1) Implement probe function
2) Fix spelling mistake
3) Remove GFP_ATOMIC flag when calling dma_alloc_coherent for PAT array mem
4) Replace alloc_page and flush range calls with dma_alloc_coherent

Nishanth Menon:
1) Address infinite while loop when reading dmm register

Benoit Cousson:
1) Fix source file headers
2) Correct logical errors in device file

Kevin Hilman:
1) Move DMM/TILER source code into driver/misc/tiler until a recommendation is made as to where it should go

List of pending items in proposed order:

* Determine driver source code location
(Currently, resides in drivers/misc/tiler)
* Add area packing support (multiple blocks can reside in the same band/area) to optimize area use
* Add group-ID support (to specify which blocks can reside together in the same area)
* Add multiple search directions to TCM-SiTA
* Add 1D block support (including adding 1D search algo to TCM-SiTA)
* Optimize mutex handling (don.t hold mutex during memory allocation/mapping/cache flushing)
* Add block reference counting, support for sharing blocks
* Move all kernel-API-s to tiler-iface.c
* Support orphaned block support (in preparation for process cleanup support)
* Change block identification from physical address to key-ID pair (in preparation for user space support, and process security)
* Add support for process security (blocks from separate processes never reside in the same band)
* Support file interface (ioctl and mmap)
* Support for buffers (ordered list of blocks that are mapped to userspace together, such as YUV420sp)
* Support 1D user buffer mapping into TILER container
* Support for block pre-reservation (to further optimize area use)

David Sin (2):
TILER-DMM: DMM-PAT driver for TI TILER
TILER-DMM: Device support for OMAP

Lajos Molnar (6):
TILER-DMM: Container manager interface and utility definitons
TILER-DMM: TILER Memory Manager interface and implementation
TILER-DMM: TILER interface file and documentation
TILER-DMM: Geometry and view manipulation functions
TILER-DMM: Main TILER driver implementation
TILER-DMM: Linking TILER driver into the Linux kernel build

Ravi Ramachandra (1):
TILER-DMM: Sample TCM implementation: Simple TILER Allocator (SiTA)

 Documentation/arm/OMAP/TILER           |  126 ++++++++++
 arch/arm/mach-omap2/Makefile           |    2 +
 arch/arm/mach-omap2/dmm-omap44xx.c     |   80 ++++++
 arch/arm/mach-omap2/include/mach/dmm.h |   92 +++++++
 drivers/misc/Kconfig                   |    1 +
 drivers/misc/Makefile                  |    1 +
 drivers/misc/tiler/Kconfig             |   72 ++++++
 drivers/misc/tiler/Makefile            |    7 +
 drivers/misc/tiler/dmm-main.c          |  187 ++++++++++++++
 drivers/misc/tiler/tcm.h               |  171 +++++++++++++
 drivers/misc/tiler/tcm/Makefile        |    1 +
 drivers/misc/tiler/tcm/_tcm-sita.h     |   61 +++++
 drivers/misc/tiler/tcm/tcm-sita.c      |  422 ++++++++++++++++++++++++++++++++
 drivers/misc/tiler/tcm/tcm-sita.h      |   28 ++
 drivers/misc/tiler/tcm/tcm-utils.h     |   51 ++++
 drivers/misc/tiler/tiler-geom.c        |  362 +++++++++++++++++++++++++++
 drivers/misc/tiler/tiler-geom.h        |   48 ++++
 drivers/misc/tiler/tiler-iface.c       |   66 +++++
 drivers/misc/tiler/tiler-main.c        |  405 ++++++++++++++++++++++++++++++
 drivers/misc/tiler/tmm-pat.c           |  266 ++++++++++++++++++++
 drivers/misc/tiler/tmm.h               |  103 ++++++++
 include/linux/tiler.h                  |  173 +++++++++++++
 22 files changed, 2725 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/arm/OMAP/TILER
 create mode 100644 arch/arm/mach-omap2/dmm-omap44xx.c
 create mode 100644 arch/arm/mach-omap2/include/mach/dmm.h
 create mode 100644 drivers/misc/tiler/Kconfig
 create mode 100644 drivers/misc/tiler/Makefile
 create mode 100644 drivers/misc/tiler/dmm-main.c
 create mode 100644 drivers/misc/tiler/tcm.h
 create mode 100644 drivers/misc/tiler/tcm/Makefile
 create mode 100644 drivers/misc/tiler/tcm/_tcm-sita.h
 create mode 100644 drivers/misc/tiler/tcm/tcm-sita.c
 create mode 100644 drivers/misc/tiler/tcm/tcm-sita.h
 create mode 100644 drivers/misc/tiler/tcm/tcm-utils.h
 create mode 100644 drivers/misc/tiler/tiler-geom.c
 create mode 100644 drivers/misc/tiler/tiler-geom.h
 create mode 100644 drivers/misc/tiler/tiler-iface.c
 create mode 100644 drivers/misc/tiler/tiler-main.c
 create mode 100644 drivers/misc/tiler/tmm-pat.c
 create mode 100644 drivers/misc/tiler/tmm.h
 create mode 100644 include/linux/tiler.h
author
#1 lore raw

PATCH 1/9 TILER-DMM: DMM-PAT driver for TI TILER

This patch adds support for DMM-PAT initialization and programming.

---
 arch/arm/mach-omap2/include/mach/dmm.h |   92 ++++++++++++++++
 drivers/misc/tiler/dmm-main.c          |  187 ++++++++++++++++++++++++++++++++
 2 files changed, 279 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/dmm.h
 create mode 100644 drivers/misc/tiler/dmm-main.c
arch/arm/mach-omap2/include/mach/dmm.h new file +92 -0
new file mode 100644
index 0000000..33a1215
@@ -0,0 +1,92 @@
+/*
+ * Dynamic Memory Manager (DMM) driver support functions for
+ * TI DMM-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.
+ */
+
+#ifndef DMM_H
+#define DMM_H
+
+#define DMM_TILER_OR__0       0x220
+#define DMM_TILER_OR__1       0x224
+#define DMM_PAT_VIEW__0       0x420
+#define DMM_PAT_VIEW__1       0x424
+#define DMM_PAT_VIEW_MAP__0   0x440
+#define DMM_PAT_VIEW_MAP_BASE 0x460
+#define DMM_PAT_IRQSTATUS_RAW 0x480
+#define DMM_PAT_IRQSTATUS     0x490
+#define DMM_PAT_STATUS__0     0x4C0
+#define DMM_PAT_DESCR__0      0x500
+#define DMM_PAT_AREA__0       0x504
+#define DMM_PAT_CTRL__0       0x508
+#define DMM_PAT_DATA__0       0x50C
+
+/*
+ * Physical Address Translator (PAT) refill programming mode
+ */
+enum pat_mode {
+	MANUAL,
+	AUTO
+};
+
+/*
+ * Area definition for DMM physical address translator
+ */
+struct pat_area {
+	s8 x0:8;
+	s8 y0:8;
+	s8 x1:8;
+	s8 y1:8;
+};
+
+/*
+ * DMM physical address translator control
+ */
+struct pat_ctrl {
+	s32 start:4;
+	s32 dir:4;
+	s32 lut_id:8;
+	s32 sync:12;
+	s32 ini:4;
+};
+
+/*
+ * Physical Address Translator (PAT) descriptor
+ */
+struct pat {
+	struct pat *next;
+	struct pat_area area;
+	struct pat_ctrl ctrl;
+	u32 data;
+};
+
+/*
+ * DMM device data
+ */
+struct dmm {
+	const char *oh_name;
+	void __iomem *base;
+	int irq;
+};
+
+/*
+ * Create and initialize the physical address translator
+ */
+struct dmm *dmm_pat_init(u32 id);
+
+/*
+ * Program the physical address translator
+ */
+int dmm_pat_refill(struct dmm *dmm, struct pat *desc, enum pat_mode mode);
+
+#endif
drivers/misc/tiler/dmm-main.c new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#2 lore raw

PATCH 2/9 TILER-DMM: Container manager interface and utility definitons

In reply to David Sin

From: Lajos Molnar <[email protected]>

This patch defined the TILER Container Manager (TCM) interface and provides utility methods for implementing a TCM.

---
 drivers/misc/tiler/tcm.h           |  171 ++++++++++++++++++++++++++++++++++++
 drivers/misc/tiler/tcm/tcm-utils.h |   51 +++++++++++
 2 files changed, 222 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/tiler/tcm.h
 create mode 100644 drivers/misc/tiler/tcm/tcm-utils.h
drivers/misc/tiler/tcm.h new file +171 -0
new file mode 100644
index 0000000..8968108
@@ -0,0 +1,171 @@
+/*
+ * TILER container manager specification and support functions for TI
+ * TILER driver.
+ *
+ * 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 TCM_H
+#define TCM_H
+
+struct tcm;
+
+/* point */
+struct tcm_pt {
+	u16 x;
+	u16 y;
+};
+
+/* 2d area */
+struct tcm_area {
+	struct tcm    *tcm;	/* parent */
+	struct tcm_pt  p0;
+	struct tcm_pt  p1;
+};
+
+struct tcm {
+	u16 width, height;	/* container dimensions */
+
+	/*
+	 * 'pvt' structure shall contain any tcm details (attr) along with
+	 * linked list of allocated areas and mutex for mutually exclusive
+	 * access to the list.  It may also contain copies of width and height
+	 * to notice any changes to the publicly available width and height
+	 * fields.
+	 */
+	void *pvt;
+
+	/* function table */
+	s32 (*reserve_2d)(struct tcm *tcm, u16 height, u16 width, u8 align,
+			  struct tcm_area *area);
+	s32 (*free)      (struct tcm *tcm, struct tcm_area *area);
+	void (*deinit)   (struct tcm *tcm);
+};
+
+/*
+ * Since some basic parameter checking is done outside the TCM algorithms,
+ * TCM implementation do NOT have to check the following:
+ *
+ *   area pointer is NULL
+ *   width and height fits within container
+ *   number of pages is more than the size of the container
+ */
+
+/*
+ * Template for <ALGO_NAME>_tcm_init method.  Define as:
+ * TCM_INIT(<ALGO_NAME>_tcm_init)
+ *
+ * Allocates and initializes a tiler container manager.
+ *
+ * Pointer to the allocated and initialized container manager.
+ * NULL on failure.  DO NOT leak any memory on failure!
+ */
+#define TCM_INIT(name, attr_t) \
+struct tcm *name(u16 width, u16 height, typeof(attr_t) *attr);
+
+/*
+ * Deinitialize tiler container manager.
+ *
+ * The call should free as much memory as possible and meaningful
+ * even on failure.  Some error codes: -ENODEV: invalid manager.
+ */
+static inline void tcm_deinit(struct tcm *tcm)
+{
+	if (tcm)
+		tcm->deinit(tcm);
+}
+
+/*
+ * Reserves a 2D area in the container.
+ *
+ * The tcm field of the area will be set to NULL on failure.
+ * Some error codes: -ENODEV: invalid manager, -EINVAL:
+ * invalid area, -ENOMEM: not enough space for allocation.
+ */
+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 || width == 0 || height == 0 ||
+		 /* align must be a 2 power */
+		 align & (align - 1)) ? -EINVAL :
+		(height > tcm->height || width > tcm->width) ? -ENOMEM :
+		tcm->reserve_2d(tcm, height, width, align, area));
+
+	if (area)
+		area->tcm = res ? NULL : tcm;
+
+	return res;
+}
+
+/*
+ * Free a previously reserved area from the container.
+ *
+ * The tcm field of the area is set to NULL on success
+ * to avoid subsequent freeing.  This call will succeed
+ * even if supplying the area from a failed reserved call.
+ */
+static inline s32 tcm_free(struct tcm_area *area)
+{
+	s32 res = 0; /* free succeeds by default */
+
+	if (area && area->tcm) {
+		res = area->tcm->free(area->tcm, area);
+		if (res == 0)
+			area->tcm = NULL;
+	}
+
+	return res;
+}
+
+/* Verify if a tcm area is logically valid */
+static inline bool tcm_area_is_valid(struct tcm_area *area)
+{
+	return area && area->tcm &&
+		/* coordinate bounds */
+		area->p1.x < area->tcm->width &&
+		area->p1.y < area->tcm->height &&
+		area->p0.y <= area->p1.y &&
+		area->p0.x <= area->p1.x;
+}
+
+/* see if a coordinate is within an area */
+static inline bool __tcm_is_in(struct tcm_pt *p, struct tcm_area *a)
+{
+	return p->x >= a->p0.x && p->x <= a->p1.x &&
+		p->y >= a->p0.y && p->y <= a->p1.y;
+}
+
+/* calculate area width */
+static inline u16 __tcm_area_width(struct tcm_area *area)
+{
+	return area->p1.x - area->p0.x + 1;
+}
+
+/* calculate area height */
+static inline u16 __tcm_area_height(struct tcm_area *area)
+{
+	return area->p1.y - area->p0.y + 1;
+}
+
+/* calculate number of slots in an area */
+static inline u16 __tcm_sizeof(struct tcm_area *area)
+{
+	return __tcm_area_width(area) * __tcm_area_height(area);
+}
+#define tcm_sizeof(area) __tcm_sizeof(&(area))
+#define tcm_awidth(area) __tcm_area_width(&(area))
+#define tcm_aheight(area) __tcm_area_height(&(area))
+#define tcm_is_in(pt, area) __tcm_is_in(&(pt), &(area))
+
+#endif
drivers/misc/tiler/tcm/tcm-utils.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#3 lore raw

PATCH 3/9 TILER-DMM: Sample TCM implementation: Simple TILER Allocator (SiTA)

In reply to David Sin

From: Ravi Ramachandra <[email protected]>

This patch implements a simple TILER Container Manager (TCM).

---
 drivers/misc/tiler/tcm/Makefile    |    1 +
 drivers/misc/tiler/tcm/_tcm-sita.h |   61 +++++
 drivers/misc/tiler/tcm/tcm-sita.c  |  422 ++++++++++++++++++++++++++++++++++++
 drivers/misc/tiler/tcm/tcm-sita.h  |   28 +++
 4 files changed, 512 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/tiler/tcm/Makefile
 create mode 100644 drivers/misc/tiler/tcm/_tcm-sita.h
 create mode 100644 drivers/misc/tiler/tcm/tcm-sita.c
 create mode 100644 drivers/misc/tiler/tcm/tcm-sita.h
drivers/misc/tiler/tcm/Makefile new file +1 -0
new file mode 100644
index 0000000..8434607
@@ -0,0 +1 @@
+obj-$(CONFIG_TI_TILER) += tcm-sita.o
drivers/misc/tiler/tcm/_tcm-sita.h new file +61 -0

61 lines not on this page · raw message

drivers/misc/tiler/tcm/tcm-sita.c new file +422 -0

422 lines not on this page · raw message

drivers/misc/tiler/tcm/tcm-sita.h new file +28 -0
new file mode 100644
index 0000000..a435bce
@@ -0,0 +1,28 @@
+/*
+ * SImple Tiler Allocator (SiTA) interface.
+ *
+ * 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 TCM_SITA_H
+#define TCM_SITA_H
+
+#include "../tcm.h"
+
+/*
+ * Create a SiTA tiler container manager.
+ */
+struct tcm *sita_init(u16 width, u16 height, void *attr);
+
+TCM_INIT(sita_init, void);
+
+#endif
Signature · 1 line
1.7.0.4
author
#4 lore raw

PATCH 4/9 TILER-DMM: TILER Memory Manager interface and implementation

In reply to David Sin

From: Lajos Molnar <[email protected]>

This patch defines the TILER Memory Manager (TMM) interface and provides implementation for a PAT-supporting TMM.

---
 drivers/misc/tiler/tmm-pat.c |  266 ++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/tiler/tmm.h     |  103 ++++++++++++++++
 2 files changed, 369 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/tiler/tmm-pat.c
 create mode 100644 drivers/misc/tiler/tmm.h
drivers/misc/tiler/tmm-pat.c new file +266 -0
new file mode 100644
index 0000000..682f549
@@ -0,0 +1,266 @@
+/*
+ * DMM driver support 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/init.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/mmzone.h>
+#include <asm/cacheflush.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+
+#include "tmm.h"
+
+/* Page size granularity can be 4k, 16k, or 64k */
+#define DMM_PAGE SZ_4K
+
+/* Memory limit to cache free pages. TILER will eventually use this much */
+static u32 cache_limit = CONFIG_TILER_CACHE_LIMIT << 20;
+module_param_named(cache, cache_limit, uint, 0644);
+MODULE_PARM_DESC(cache, "Cache free pages if total memory is under this limit");
+
+/* global state - statically initialized */
+static LIST_HEAD(free_list);	/* page cache: list of free pages */
+static u32 total_mem;		/* total memory allocated (free & used) */
+static u32 refs;		/* number of tmm_pat instances */
+static DEFINE_MUTEX(mtx);	/* global mutex */
+
+/* The page struct pointer and physical address of each page.*/
+struct mem {
+	struct list_head list;
+	u32 *pg;	/* page struct */
+	dma_addr_t pa;	/* physical address */
+};
+
+/* Used to keep track of mem per tmm_pat_get_pages call */
+struct fast {
+	struct list_head list;
+	struct mem **mem;	/* array of page info */
+	u32 *pa;		/* array of physical addresses */
+	u32 num;		/* number of pages */
+};
+
+/* TMM PAT private structure */
+struct dmm_mem {
+	struct list_head fast_list;
+	struct dmm *dmm;
+};
+
+/*
+ *  Frees pages in a fast structure.  Moves pages to the free list if there
+ *  are	less pages used	than max_to_keep.  Otherwise, it frees the pages
+ */
+static void free_fast(struct fast *f)
+{
+	s32 i = 0;
+
+	/* mutex is locked */
+	for (i = 0; i < f->num; i++) {
+		if (total_mem < cache_limit) {
+			/* cache free page if under the limit */
+			list_add(&f->mem[i]->list, &free_list);
+		} else {
+			/* otherwise, free */
+			total_mem -= PAGE_SIZE;
+			dma_free_coherent(NULL, DMM_PAGE, f->mem[i]->pg,
+								f->mem[i]->pa);
+		}
+	}
+	kfree(f->pa);
+	kfree(f->mem);
+	/* remove only if element was added */
+	if (f->list.next)
+		list_del(&f->list);
+	kfree(f);
+}
+
+/* allocate and flush a page */
+static struct mem *alloc_mem(void)
+{
+	struct mem *m = kzalloc(sizeof(*m), GFP_KERNEL);
+	if (!m)
+		return NULL;
+
+	m->pg = dma_alloc_coherent(NULL, DMM_PAGE, &m->pa, GFP_KERNEL);
+	if (!m->pg) {
+		kfree(m);
+		return NULL;
+	}
+	wmb();
+
+	return m;
+}
+
+static void free_page_cache(void)
+{
+	struct mem *m, *m_;
+
+	/* mutex is locked */
+	list_for_each_entry_safe(m, m_, &free_list, list) {
+		dma_free_coherent(NULL, DMM_PAGE, m->pg, m->pa);
+		total_mem -= PAGE_SIZE;
+		list_del(&m->list);
+		kfree(m);
+	}
+}
+
+static void tmm_pat_deinit(struct tmm *tmm)
+{
+	struct fast *f, *f_;
+	struct dmm_mem *pvt = (struct dmm_mem *) tmm->pvt;
+
+	mutex_lock(&mtx);
+
+	/* free all outstanding used memory */
+	list_for_each_entry_safe(f, f_, &pvt->fast_list, list)
+		free_fast(f);
+
+	/* if this is the last tmm_pat, free all memory */
+	if (--refs == 0)
+		free_page_cache();
+
+	mutex_unlock(&mtx);
+}
+
+static u32 *tmm_pat_get_pages(struct tmm *tmm, u32 n)
+{
+	struct mem *m;
+	struct fast *f;
+	struct dmm_mem *pvt = (struct dmm_mem *) tmm->pvt;
+
+	f = kzalloc(sizeof(*f), GFP_KERNEL);
+	if (!f)
+		return NULL;
+
+	/* array of mem struct pointers */
+	f->mem = kzalloc(n * sizeof(*f->mem), GFP_KERNEL);
+
+	/* array of physical addresses */
+	f->pa = kzalloc(n * sizeof(*f->pa), GFP_KERNEL);
+
+	/* no pages have been allocated yet (needed for cleanup) */
+	f->num = 0;
+
+	if (!f->mem || !f->pa)
+		goto cleanup;
+
+	/* fill out fast struct mem array with free pages */
+	mutex_lock(&mtx);
+	while (f->num < n) {
+		/* if there is a free cached page use it */
+		if (!list_empty(&free_list)) {
+			/* unbind first element from list */
+			m = list_first_entry(&free_list, typeof(*m), list);
+			list_del(&m->list);
+		} else {
+			mutex_unlock(&mtx);
+
+			/*
+			 * Unlock mutex during allocation and cache flushing.
+			 */
+			m = alloc_mem();
+			if (!m)
+				goto cleanup;
+
+			mutex_lock(&mtx);
+			total_mem += PAGE_SIZE;
+		}
+
+		f->mem[f->num] = m;
+		f->pa[f->num++] = m->pa;
+	}
+
+	list_add(&f->list, &pvt->fast_list);
+	mutex_unlock(&mtx);
+	return f->pa;
+
+cleanup:
+	free_fast(f);
+	return NULL;
+}
+
+static void tmm_pat_free_pages(struct tmm *tmm, u32 *page_list)
+{
+	struct dmm_mem *pvt = (struct dmm_mem *) tmm->pvt;
+	struct fast *f, *f_;
+
+	mutex_lock(&mtx);
+	/* find fast struct based on 1st page */
+	list_for_each_entry_safe(f, f_, &pvt->fast_list, list) {
+		if (f->pa[0] == page_list[0]) {
+			free_fast(f);
+			break;
+		}
+	}
+	mutex_unlock(&mtx);
+}
+
+static s32 tmm_pat_map(struct tmm *tmm, struct pat_area area, u32 page_pa)
+{
+	struct dmm_mem *pvt = (struct dmm_mem *) tmm->pvt;
+	struct pat pat_desc = {NULL};
+
+	/* send pat descriptor to dmm driver */
+	pat_desc.ctrl.dir = 0;
+	pat_desc.ctrl.ini = 0;
+	pat_desc.ctrl.lut_id = 0;
+	pat_desc.ctrl.start = 1;
+	pat_desc.ctrl.sync = 0;
+	pat_desc.area = area;
+	pat_desc.next = NULL;
+
+	/* must be a 16-byte aligned physical address */
+	pat_desc.data = page_pa;
+	return dmm_pat_refill(pvt->dmm, &pat_desc, MANUAL);
+}
+
+struct tmm *tmm_pat_init(u32 pat_id)
+{
+	struct tmm *tmm = NULL;
+	struct dmm_mem *pvt = NULL;
+
+	struct dmm *dmm = dmm_pat_init(pat_id);
+	if (dmm)
+		tmm = kzalloc(sizeof(*tmm), GFP_KERNEL);
+	if (tmm)
+		pvt = kzalloc(sizeof(*pvt), GFP_KERNEL);
+	if (pvt) {
+		/* private data */
+		pvt->dmm = dmm;
+		INIT_LIST_HEAD(&pvt->fast_list);
+
+		/* increate tmm_pat references */
+		mutex_lock(&mtx);
+		refs++;
+		mutex_unlock(&mtx);
+
+		/* public data */
+		tmm->pvt = pvt;
+		tmm->deinit = tmm_pat_deinit;
+		tmm->get = tmm_pat_get_pages;
+		tmm->free = tmm_pat_free_pages;
+		tmm->map = tmm_pat_map;
+		tmm->clear = NULL;   /* not yet supported */
+
+		return tmm;
+	}
+
+	kfree(pvt);
+	kfree(tmm);
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(tmm_pat_init);
drivers/misc/tiler/tmm.h new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#5 lore raw

PATCH 5/9 TILER-DMM: TILER interface file and documentation

In reply to David Sin

From: Lajos Molnar <[email protected]>

This patch contains the TILER interface file and the documentation.

---
 Documentation/arm/OMAP/TILER |  126 ++++++++++++++++++++++++++++++
 include/linux/tiler.h        |  173 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 299 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/arm/OMAP/TILER
 create mode 100644 include/linux/tiler.h
Documentation/arm/OMAP/TILER new file +126 -0
new file mode 100644
index 0000000..2e94ad7
@@ -0,0 +1,126 @@
+Tiling and Isometric Lightweight Engine for Rotation (TILER) driver
+
+Dynamic Memory Manager (DMM) is a hardware block made by Texas Instruments.
+Within the DMM exists at least one TILER hardware component.  Its purpose is to
+organize video/image memory in a 2-dimensional fashion to limit memory
+bandwidth and facilitate 0 effort rotation and mirroring.  The TILER driver
+facilitates allocating, freeing, as well as mapping 2D blocks (areas) in the
+TILER container(s).  It also facilitates rotating and mirroring the allocated
+blocks or its rectangular subsections.
+
+TERMINOLOGY
+
+"slot"
+
+The basic TILER driver operates on blocks of slots.  A slot is the granularity
+of the TILER hardware device.  For all current uses it is 4K, but could also be
+16 or 64K.  The DMM-TILER TRM refers to this as "page" but we want to separate
+this concept from the MMU pages.
+
+"page"
+
+The granularity of the MMU, used by the kernel.  This is 4K.
+
+"block"
+
+The TILER hardware component supports 1D and 2D blocks.  A 2D block is a
+rectangular arrangement of slots with arbitrary width and height in a 2D 
+container.  A 1D block is a linear arrangement of slots with arbitrary length
+ in a 1D container.  This TILER driver only supports 2D blocks.
+
+"container"
+
+The TILER driver supports an arbitrary TILER container size.  However, for
+all current implementations it is 256 by 128 slots.  The container currently can
+only be used as a 2D container.
+
+"reserved area"
+
+Each block resides within a reserved area in the container.  This area may
+be larger than the actual set of slots that a block occupies.  The reason for
+this is to protect access from one block into another.  Since TILER container is
+mmap-ped into user space as individual pages, all slots that are spanned by
+that page become visible to the user.  The tiler driver allows restricting the
+granularity of the reserved area (default alignment) as well as the mapped
+area (granularity).
+
+Using TILER driver KERNEL APIs:
+
+1. Allocating and freeing a 1080p YUV422 block
+
+        struct tiler_block_t blk = {0};
+        int res;
+
+        blk.width = 1920;
+        blk.height = 1080;
+        res = tiler_alloc(&blk, TILFMT_16BIT, 0, 0);
+
+        tiler_free(&blk);
+
+2. Allocating and freeing a 1080p YUV420p block
+
+        struct tiler_block_t blk_Y = {0}, blk_UV = {0};
+        int res;
+
+        blk_Y.width = 1920;
+        blk_Y.height = 1080;
+        blk_UV.widht = 960;
+        blk_UV.height = 540;
+        res = tiler_alloc(&blk_Y, TILFMT_8BIT, 0, 0) ? :
+                tiler_alloc(&blk_UV, TILFMT_16BIT, PAGE_SIZE,
+                                blk_y->phys & ~PAGE_MASK);
+
+        tiler_free(&blk_Y);
+        tiler_free(&blk_UV);
+
+Note how we allocated the UV block at the same in-page offset as the Y buffer.
+This facilitates mmap-ping both Y and UV blocks into userspace as one
+contiguous buffer.
+
+3. Mmap-ing YUV420p block into user space
+
+        static int my_mmap(struct file *file, struct vm_area_struct *vma)
+        {
+                unsigned long size = (vma->vm_end - vma->vm_start);
+                unsigned long start = vma->vm_start;
+
+                if (size != tiler_size(&blk_Y) + tiler_size(&blk_UV))
+                        return -EINVAL;
+
+                return tiler_mmap_blk(&blk_Y, 0, tiler_size(&blk_Y), vma, 0) ?
+                        : tiler_mmap_blk(&blk_UV, 0, tiler_size(&blk_UV), vma,
+                                tiler_size(&blk_Y));
+        }
+
+CONFIGURATIONS
+
+The TILER driver allows specifying a container manager (tcm) for each
+pixel format.  The same container manager can be specified for more than
+one pixel formats.
+
+Each container manager also operates on a Physical Address Translator PAT
+ instance.  One can also specify a "virtual" PAT (with a linear preassigned
+ memory space no actual PAT programming), but it is not implemented.
+
+PARAMETERS
+
+The TILER driver allows specifying:
+
+    granularity (tiler.grain, CONFIG_TILER_GRANULARITY):
+
+        Each block is mapped in width-chunks of granularity.
+
+    default alignment (tiler.align, CONFIG_TILER_ALIGNMENT):
+
+        Default alignment if aligment is not specified (0). Otherwise,
+        blocks are allocated at an address aligned to the value given plus an
+        offset within the alignment.
+
+    cache limit (tiler.cache, CONFIG_TILER_CACHE_LIMIT):
+
+        TILER driver keeps a cache of allocated pages to speed up allocation of
+        TILER blocks.  You can set a limit of how much memory the TILER driver
+        should keep if there are no actual TILER allocations.  This also means
+        that if there is less memory used than this limit, the pages of freed
+        tiler blocks will not actually be freed, but instead are put into this
+        cache.
include/linux/tiler.h new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#6 lore raw

PATCH 6/9 TILER-DMM: Geometry and view manipulation functions

In reply to David Sin

From: Lajos Molnar <[email protected]>

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.

---
 drivers/misc/tiler/tiler-geom.c |  362 +++++++++++++++++++++++++++++++++++++++
 drivers/misc/tiler/tiler-geom.h |   48 +++++
 2 files changed, 410 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/tiler/tiler-geom.c
 create mode 100644 drivers/misc/tiler/tiler-geom.h
drivers/misc/tiler/tiler-geom.c new file +362 -0
new file mode 100644
index 0000000..c94193b
@@ -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-geom.h"
+
+/* bits representing the same slot in DMM-TILER hw-block */
+#define SLOT_WIDTH_BITS		6
+#define SLOT_HEIGHT_BITS	6
+
+/* bits reserved to describe coordinates in DMM-TILER hw-block */
+#define CONT_WIDTH_BITS		14
+#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	0x60000000u
+#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 view orientation and access mode */
+#define TIL_ADDR(x, orient, a)\
+	((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
+
+bool is_tiler_addr(u32 phys)
+{
+	return phys >= TILVIEW_8BIT && phys < TILVIEW_END;
+}
+EXPORT_SYMBOL_GPL(is_tiler_addr);
+
+u32 tiler_bpp(const struct tiler_block_t *b)
+{
+	enum tiler_fmt fmt = tiler_fmt(b->phys);
+	WARN_ON(fmt == TILFMT_INVALID || fmt == TILFMT_PAGE);
+
+	return geom[fmt].bpp;
+}
+EXPORT_SYMBOL_GPL(tiler_bpp);
+
+/* return the stride of a tiler-block in tiler space */
+static inline s32 tiler_stride(u32 tsptr)
+{
+	enum tiler_fmt fmt = TILER_FMT(tsptr);
+
+	if (fmt == TILFMT_PAGE)
+		return 0;
+	else if (tsptr & MASK_XY_FLIP)
+		return 1 << (CONT_HEIGHT_BITS + geom[fmt].x_shft);
+	else
+		return 1 << (CONT_WIDTH_BITS + geom[fmt].y_shft);
+}
+
+u32 tiler_pstride(const struct tiler_block_t *b)
+{
+	enum tiler_fmt fmt = tiler_fmt(b->phys);
+	WARN_ON(fmt == TILFMT_INVALID);
+
+	/* return the virtual stride for page mode */
+	if (fmt == TILFMT_PAGE)
+		return tiler_vstride(b);
+
+	return tiler_stride(b->phys & ~MASK_VIEW);
+}
+EXPORT_SYMBOL_GPL(tiler_pstride);
+
+enum tiler_fmt tiler_fmt(u32 phys)
+{
+	if (!is_tiler_addr(phys))
+		return TILFMT_INVALID;
+
+	return TILER_FMT(phys);
+}
+EXPORT_SYMBOL_GPL(tiler_fmt);
+
+/* returns the tiler geometry information for a format */
+static const struct tiler_geom *get_geom(enum tiler_fmt fmt)
+{
+	if (fmt >= TILFMT_MIN && fmt <= TILFMT_MAX)
+		return geom + fmt;
+	return NULL;
+}
+
+/*
+ * Returns the natural x and y coordinates for a pixel in tiler space address.
+ * That is, the coordinates for the same pixel in the natural (non-rotated,
+ * non-mirrored) view. This allows to uniquely identify a tiler pixel in any
+ * view orientation.
+ */
+static void tiler_get_natural_xy(u32 tsptr, u32 *x, u32 *y)
+{
+	u32 x_bits, y_bits, offset;
+	enum tiler_fmt fmt;
+
+	fmt = TILER_FMT(tsptr);
+
+	x_bits = CONT_WIDTH_BITS - geom[fmt].x_shft;
+	y_bits = CONT_HEIGHT_BITS - geom[fmt].y_shft;
+	offset = (tsptr & VIEW_MASK) >> (geom[fmt].x_shft + geom[fmt].y_shft);
+
+	/* separate coordinate bitfields based on view orientation */
+	if (tsptr & MASK_XY_FLIP) {
+		*x = offset >> y_bits;
+		*y = offset & MASK(y_bits);
+	} else {
+		*x = offset & MASK(x_bits);
+		*y = offset >> x_bits;
+	}
+
+	/* account for mirroring */
+	if (tsptr & MASK_X_INVERT)
+		*x ^= MASK(x_bits);
+	if (tsptr & MASK_Y_INVERT)
+		*y ^= MASK(y_bits);
+}
+
+/* calculate the tiler space address of a pixel in a view orientation */
+static u32 tiler_get_address(u32 orient, enum tiler_fmt fmt, u32 x, u32 y)
+{
+	u32 x_bits, y_bits, tmp, x_mask, y_mask, alignment;
+
+	x_bits = CONT_WIDTH_BITS - geom[fmt].x_shft;
+	y_bits = CONT_HEIGHT_BITS - geom[fmt].y_shft;
+	alignment = geom[fmt].x_shft + geom[fmt].y_shft;
+
+	/* validate coordinate */
+	x_mask = MASK(x_bits);
+	y_mask = MASK(y_bits);
+	if (x < 0 || x > x_mask || y < 0 || y > y_mask)
+		return 0;
+
+	/* account for mirroring */
+	if (orient & MASK_X_INVERT)
+		x ^= x_mask;
+	if (orient & MASK_Y_INVERT)
+		y ^= y_mask;
+
+	/* get coordinate address */
+	if (orient & MASK_XY_FLIP)
+		tmp = ((x << y_bits) + y);
+	else
+		tmp = ((y << x_bits) + x);
+
+	return TIL_ADDR((tmp << alignment), orient, fmt);
+}
+
+void tilview_create(struct tiler_view_t *view, u32 phys, u32 width, u32 height)
+{
+	WARN_ON(!is_tiler_addr(phys));
+
+	view->tsptr = phys & ~MASK_VIEW;
+	view->bpp = geom[TILER_FMT(phys)].bpp;
+	view->width = width;
+	view->height = height;
+	view->h_inc = view->bpp;
+	view->v_inc = tiler_stride(view->tsptr);
+}
+EXPORT_SYMBOL_GPL(tilview_create);
+
+void tilview_get(struct tiler_view_t *view, struct tiler_block_t *blk)
+{
+	view->tsptr = blk->phys & ~MASK_VIEW;
+	view->bpp = tiler_bpp(blk);
+	view->width = blk->width;
+	view->height = blk->height;
+	view->h_inc = view->bpp;
+	view->v_inc = tiler_stride(view->tsptr);
+}
+EXPORT_SYMBOL_GPL(tilview_get);
+
+s32 tilview_crop(struct tiler_view_t *view, u32 left, u32 top, u32 width,
+								u32 height)
+{
+	/* check for valid crop */
+	if (left + width < left || left + width > view->width ||
+	    top + height < top || top + height > view->height)
+		return -EINVAL;
+
+	view->tsptr += left * view->h_inc + top * view->v_inc;
+	view->width = width;
+	view->height = height;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tilview_crop);
+
+/* calculate tilerspace address and stride after view orientation change */
+static void reorient(struct tiler_view_t *view, u32 orient)
+{
+	u32 x, y;
+
+	tiler_get_natural_xy(view->tsptr, &x, &y);
+	view->tsptr = tiler_get_address(orient,
+					TILER_FMT(view->tsptr), x, y);
+	view->v_inc = tiler_stride(view->tsptr);
+}
+
+s32 tilview_rotate(struct tiler_view_t *view, s32 rotation)
+{
+	u32 orient;
+
+	if (rotation % 90)
+		return -EINVAL;
+
+	/* normalize rotation to quarters */
+	rotation = (rotation / 90) & 3;
+	if (!rotation)
+		return 0; /* nothing to do */
+
+	/* PAGE mode view cannot be rotated */
+	if (TILER_FMT(view->tsptr) == TILFMT_PAGE)
+		return -EPERM;
+
+	/*
+	 * first adjust top-left corner. NOTE: it rotates counter-clockwise:
+	 * 0 < 3
+	 * v   ^
+	 * 1 > 2
+	 */
+	if (rotation < 3)
+		view->tsptr += (view->height - 1) * view->v_inc;
+	if (rotation > 1)
+		view->tsptr += (view->width - 1) * view->h_inc;
+
+	/* then rotate view itself */
+	orient = view->tsptr & MASK_VIEW;
+
+	/* rotate first 2 quarters */
+	if (rotation & 2) {
+		orient ^= MASK_X_INVERT;
+		orient ^= MASK_Y_INVERT;
+	}
+
+	/* rotate last quarter */
+	if (rotation & 1) {
+		orient ^= (orient & MASK_XY_FLIP) ?
+			MASK_X_INVERT : MASK_Y_INVERT;
+
+		/* swap x & y */
+		orient ^= MASK_XY_FLIP;
+		swap(view->height, view->width);
+	}
+
+	/* finally reorient view */
+	reorient(view, orient);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tilview_rotate);
+
+s32 tilview_flip(struct tiler_view_t *view, bool flip_x, bool flip_y)
+{
+	u32 orient;
+	orient = view->tsptr & MASK_VIEW;
+
+	if (!flip_x && !flip_y)
+		return 0; /* nothing to do */
+
+	/* PAGE mode view cannot be flipped */
+	if (TILER_FMT(view->tsptr) == TILFMT_PAGE)
+		return -EPERM;
+
+	/* adjust top-left corner */
+	if (flip_x)
+		view->tsptr += (view->width - 1) * view->h_inc;
+	if (flip_y)
+		view->tsptr += (view->height - 1) * view->v_inc;
+
+	/* flip view orientation */
+	if (orient & MASK_XY_FLIP)
+		swap(flip_x, flip_y);
+
+	if (flip_x)
+		orient ^= MASK_X_INVERT;
+	if (flip_y)
+		orient ^= MASK_Y_INVERT;
+
+	/* finally reorient view */
+	reorient(view, orient);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(tilview_flip);
+
+/* return the alias address for a coordinate */
+static inline u32 alias_address(enum tiler_fmt fmt, u32 x, u32 y)
+{
+	return tiler_get_address(0, fmt, x, y) + TILVIEW_8BIT;
+}
+
+/* get the coordinates for an alias address */
+static inline void alias_xy(u32 ssptr, u32 *x, u32 *y)
+{
+	tiler_get_natural_xy(ssptr & ~MASK_VIEW, x, y);
+}
+
+/* initialize shared geometric data */
+void tiler_geom_init(struct tiler_ops *tiler)
+{
+	struct tiler_geom *g;
+
+	tiler->xy = alias_xy;
+	tiler->addr = alias_address;
+	tiler->geom = get_geom;
+
+	tiler->page   = TILER_PAGE;
+	tiler->width  = TILER_WIDTH;
+	tiler->height = TILER_HEIGHT;
+
+	/* calculate geometry */
+	for (g = geom; g < geom + TILER_FORMATS; g++) {
+		g->bpp = 1 << (g->x_shft + g->y_shft);
+		g->slot_w = 1 << (SLOT_WIDTH_BITS - g->x_shft);
+		g->slot_h = 1 << (SLOT_HEIGHT_BITS - g->y_shft);
+	}
+}
drivers/misc/tiler/tiler-geom.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.7.0.4
author
#7 lore raw

PATCH 7/9 TILER-DMM: Main TILER driver implementation

In reply to David Sin

From: Lajos Molnar <[email protected]>

This patch contains the TILER driver and implementation of the TILER block manipulation and mapping functions.

It also contains the makefile and config file for the TILER driver.

---
 drivers/misc/tiler/Kconfig       |   72 +++++++
 drivers/misc/tiler/Makefile      |    7 +
 drivers/misc/tiler/tiler-iface.c |   66 ++++++
 drivers/misc/tiler/tiler-main.c  |  405 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 550 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/tiler/Kconfig
 create mode 100644 drivers/misc/tiler/Makefile
 create mode 100644 drivers/misc/tiler/tiler-iface.c
 create mode 100644 drivers/misc/tiler/tiler-main.c
drivers/misc/tiler/Kconfig new file +72 -0
new file mode 100644
index 0000000..eae4fb1
@@ -0,0 +1,72 @@
+config HAVE_TI_DMM
+	bool
+	default y
+	depends on ARCH_OMAP4
+
+menuconfig TI_DMM
+        tristate "TI DMM support"
+        default y
+        depends on HAVE_TI_DMM
+        help
+           DMM driver for TI chips.
+
+menuconfig TI_TILER
+        tristate "TI TILER support"
+        default y
+        depends on TI_DMM
+        help
+           TILER driver for TI chips.  The TI TILER device
+           enables video rotation on certain TI chips such as OMAP4 or
+           TI816x.  Video rotation will be limited without TILER support.
+
+config TILER_GRANULARITY
+        int "Allocation granularity"
+        range 1 4096
+        default 128
+        depends on TI_TILER
+        help
+           This option sets the default TILER allocation granularity.  It can
+           be overriden by the tiler.grain boot argument.
+
+           The allocation granularity is the smallest TILER block size (in
+           bytes) managed distinctly by the TILER driver.  TILER blocks of any
+           size are managed in chunks of at least this size.
+
+           Must be a power of 2 in the range of 1 to 4096; however, the TILER
+           driver may use a larger supported granularity.
+
+           Supported values are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,
+           2048, 4096.
+
+config TILER_ALIGNMENT
+        int "Allocation alignment"
+        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 power of 2 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
+        default 40
+        depends on TI_TILER
+        help
+           This option sets the minimum memory that TILER retains even if
+           there is less TILER allocated memory is use.  The unused memory is
+           instead stored in a cache to speed up allocation and freeing of
+           physical pages.
+
+           This option can be overriden by the tiler.cache boot argument.
+
+           While initially TILER will use less memory than this limit (0), it
+           will not release any memory used until it reaches this limit.
+           Thereafter, TILER will release any unused memory immediately as
+           long as there it is above this threshold.
drivers/misc/tiler/Makefile new file +7 -0
new file mode 100644
index 0000000..7dbc828
@@ -0,0 +1,7 @@
+obj-$(CONFIG_TI_DMM) += dmm.o
+dmm-objs = dmm-main.o
+
+obj-$(CONFIG_TI_TILER) += tcm/
+
+obj-$(CONFIG_TI_TILER) += tiler.o
+tiler-objs = tiler-geom.o tiler-main.o tiler-iface.o tmm-pat.o
drivers/misc/tiler/tiler-iface.c new file +66 -0

66 lines not on this page · raw message

drivers/misc/tiler/tiler-main.c new file +405 -0

405 lines not on this page · raw message

Signature · 1 line
1.7.0.4
maintainer
#8 lore raw

Re: [PATCH 7/9] TILER-DMM: Main TILER driver implementation

Hi,

Quoted 6 lines · David Sin

From: Lajos Molnar <[email protected]>

This patch contains the TILER driver and implementation of the TILER block manipulation and mapping functions.

It also contains the makefile and config file for the TILER driver.

...

Quoted 4 lines
drivers/misc/tiler/Kconfig new file +4 -0
+config TILER_GRANULARITY
+        int "Allocation granularity"
+        range 1 4096
+        default 128

...

Quoted 4 lines
drivers/misc/tiler/Kconfig new file +4 -0
+config TILER_ALIGNMENT
+        int "Allocation alignment"
+        range 1 4096
+        default 4096

...

drivers/misc/tiler/Kconfig line 59

Quoted 4 lines
drivers/misc/tiler/Kconfig new file +4 -0
+config TILER_CACHE_LIMIT
+        int "Memory limit to cache free pages in MBytes"
+        range 0 128
+        default 40

...

Do you really need these Kconfig options? To me it seems you should pass these in platform_data.

Regards,

Tony

author
#9 lore raw

Re: [PATCH 7/9] TILER-DMM: Main TILER driver implementation

Quoted 25 lines · Tony Lindgren

Hi,

Quoted 6 lines · David Sin

From: Lajos Molnar <[email protected]>

This patch contains the TILER driver and implementation of the TILER block manipulation and mapping functions.

It also contains the makefile and config file for the TILER driver.

...

Quoted 4 lines
drivers/misc/tiler/Kconfig new file +4 -0
+config TILER_GRANULARITY
+        int "Allocation granularity"
+        range 1 4096
+        default 128

...

Quoted 4 lines
drivers/misc/tiler/Kconfig new file +4 -0
+config TILER_ALIGNMENT
+        int "Allocation alignment"
+        range 1 4096
+        default 4096

...

drivers/misc/tiler/Kconfig line 59

Quoted 4 lines
drivers/misc/tiler/Kconfig new file +4 -0
+config TILER_CACHE_LIMIT
+        int "Memory limit to cache free pages in MBytes"
+        range 0 128
+        default 40
Quoted 8 lines

...

Do you really need these Kconfig options? To me it seems you should pass these in platform_data.

Regards,

Tony

Hi Tony,
No -- we don't really need these here, but we thought that it would be an easy way for the user to set them -- esp the
CACHE_LIMIT. We can actually remove themi, since it's not going to change very often, and add it to plat data later.
I'll revise the patch. BTW, Are you going to be the one to
merge this code?

Regards,

Signature · 1 line
David Sin
author
#10 lore raw

PATCH 8/9 TILER-DMM: Linking TILER driver into the Linux kernel build

In reply to David Sin

From: Lajos Molnar <[email protected]>

This patch links the TILER driver into the Linux kernel build and config system.

---
 drivers/misc/Kconfig  |    1 +
 drivers/misc/Makefile |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
drivers/misc/Kconfig +1 -0
index 4d073f1..1ebc655 100644
@@ -457,5 +457,6 @@ source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
 source "drivers/misc/iwmc3200top/Kconfig"
 source "drivers/misc/ti-st/Kconfig"
+source "drivers/misc/tiler/Kconfig"
 
 endif # MISC_DEVICES
drivers/misc/Makefile +1 -0
index 98009cc..3716c49 100644
@@ -42,3 +42,4 @@ obj-$(CONFIG_ARM_CHARLCD)	+= arm-charlcd.o
 obj-$(CONFIG_PCH_PHUB)		+= pch_phub.o
 obj-y				+= ti-st/
 obj-$(CONFIG_AB8500_PWM)	+= ab8500-pwm.o
+obj-$(CONFIG_TI_TILER)		+= tiler/
Signature · 1 line
1.7.0.4
author
#11 lore raw

PATCH 9/9 TILER-DMM: Device support for OMAP

In reply to David Sin

Add DMM device support for OMAP utilizing the
OMAP HWMOD framework.

---
 arch/arm/mach-omap2/Makefile       |    2 +
 arch/arm/mach-omap2/dmm-omap44xx.c |   80 ++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/dmm-omap44xx.c
arch/arm/mach-omap2/Makefile +2 -0
index 60e51bc..fc682ea 100644
@@ -194,3 +194,5 @@ obj-y					+= $(smc91x-m) $(smc91x-y)
 
 smsc911x-$(CONFIG_SMSC911X)		:= gpmc-smsc911x.o
 obj-y					+= $(smsc911x-m) $(smsc911x-y)
+
+obj-$(CONFIG_ARCH_OMAP4)		+= dmm-omap44xx.o
arch/arm/mach-omap2/dmm-omap44xx.c new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
1.7.0.4
maintainer
#12 lore raw
In reply to David Sin
Quoted 10 lines · David Sin

Tiling and Isometric Lightweight Engine for Rotation (TILER) driver
=====

Dynamic Memory Manager (DMM) is a hardware block made by Texas Instruments. Within the DMM exists at least one TILER hardware component. Its purpose is to organize video/image memory in a 2-dimensional fashion to limit memory bandwidth and facilitate 0 effort rotation and mirroring. The TILER driver facilitates allocating, freeing, as well as mapping 2D blocks (areas) in the TILER container(s). It also facilitates rotating and mirroring the allocated blocks or its rectangular subsections.

How does this relate to DRM/GEM? I don't understand too much about graphics drivers, but it does sound like there is some overlap in functionality.

I guess at the very least the DMM should live in drivers/gpu/ instead of drivers/misc, but perhaps it could be integrated more closely with the existing code there.

Arnd

author
#13 lore raw
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · David Sin

Tiling and Isometric Lightweight Engine for Rotation (TILER) driver
=====

Dynamic Memory Manager (DMM) is a hardware block made by Texas Instruments. Within the DMM exists at least one TILER hardware component. Its purpose is to organize video/image memory in a 2-dimensional fashion to limit memory bandwidth and facilitate 0 effort rotation and mirroring. The TILER driver facilitates allocating, freeing, as well as mapping 2D blocks (areas) in the TILER container(s). It also facilitates rotating and mirroring the allocated blocks or its rectangular subsections.

Quoted 8 lines

How does this relate to DRM/GEM? I don't understand too much about graphics drivers, but it does sound like there is some overlap in functionality.

I guess at the very least the DMM should live in drivers/gpu/ instead of drivers/misc, but perhaps it could be integrated more closely with the existing code there.

Arnd

Do you know if anyone on your team is familiar with DRM/GEM (grap ext mgr) for x86? I'm trying to understand the differences and make a case that
it's not the same as DMM/TILER.

thanks,

Signature · 1 line
David Sin
author
#14 lore raw
Quoted 20 lines · David Sin
Quoted 19 lines · Arnd Bergmann
Quoted 10 lines · David Sin

Tiling and Isometric Lightweight Engine for Rotation (TILER) driver
=====

Dynamic Memory Manager (DMM) is a hardware block made by Texas Instruments. Within the DMM exists at least one TILER hardware component. Its purpose is to organize video/image memory in a 2-dimensional fashion to limit memory bandwidth and facilitate 0 effort rotation and mirroring. The TILER driver facilitates allocating, freeing, as well as mapping 2D blocks (areas) in the TILER container(s). It also facilitates rotating and mirroring the allocated blocks or its rectangular subsections.

How does this relate to DRM/GEM? I don't understand too much about graphics drivers, but it does sound like there is some overlap in functionality.

I guess at the very least the DMM should live in drivers/gpu/ instead of drivers/misc, but perhaps it could be integrated more closely with the existing code there.

Quoted 8 lines
Quoted 1 line

Arnd

Do you know if anyone on your team is familiar with DRM/GEM (grap ext mgr) for x86? I'm trying to understand the differences and make a case that
it's not the same as DMM/TILER.

thanks,

Signature · 1 line
David Sin

Hi Arnd,
I'm not sure exactly how DRM/GEM works.. What functionality do you think is overlapping? The main feature, aside from reduced page accesses, of the DMM hw block is to provide physically contiguous 2 dimensional memory blocks for image and video processing. This hw sits between the interconnect and the ext memory interface in the OMAP, and contains an MMU-like address traslator for "virtually" physically contiguous memory and sdram pages.

thank you for your comments.

BR,

Signature · 1 line
David Sin
maintainer
#15 lore raw
Quoted 6 lines · On Thursday 16 December 2010 18:37:38 David Sin wrote:

I'm not sure exactly how DRM/GEM works.. What functionality do you think is overlapping? The main feature, aside from reduced page accesses, of the DMM hw block is to provide physically contiguous 2 dimensional memory blocks for image and video processing. This hw sits between the interconnect and the ext memory interface in the OMAP, and contains an MMU-like address traslator for "virtually" physically contiguous memory and sdram pages.

As far as I can tell, both DMM and GEM at a high level manage objects in video memory. The IOMMU that you have on the Omap hardware seems to resemble the GART that sits between PC-style video cards and main memory.

I don't know any details, but google quickly finds
http://lwn.net/Articles/283798/ with a description of the initial GEM design. My main thought when looking over the DMM code was that this should not be tied too closely to a specific hardware, and GEM seems to be an existing abstraction that may fit what you need.

Arnd

author
#16 lore raw
Quoted 5 lines · Arnd Bergmann

As far as I can tell, both DMM and GEM at a high level manage objects in video memory. The IOMMU that you have on the Omap hardware seems to resemble the GART that sits between PC-style video cards and main memory.

Quoted 8 lines

I don't know any details, but google quickly finds
http://lwn.net/Articles/283798/ with a description of the initial GEM design. My main thought when looking over the DMM code was that this should not be tied too closely to a specific hardware, and GEM seems to be an existing abstraction that may fit what you need.

Arnd

Thanks for the pointer, Arnd. I also found a nice readme file in the gpu/drm directory, which points to a wiki and source code. I'll read into this and get back to you.

BR,

Signature · 1 line
David Sin
#17 lore raw
Quoted 13 lines · David Sin
Quoted 12 lines · Arnd Bergmann

As far as I can tell, both DMM and GEM at a high level manage objects in video memory. The IOMMU that you have on the Omap hardware seems to resemble the GART that sits between PC-style video cards and main memory.

I don't know any details, but google quickly finds
http://lwn.net/Articles/283798/ with a description of the initial GEM design. My main thought when looking over the DMM code was that this should not be tied too closely to a specific hardware, and GEM seems to be an existing abstraction that may fit what you need.

Quoted 4 lines
Quoted 1 line

      Arnd

Thanks for the pointer, Arnd.  I also found a nice readme file in the gpu/drm directory, which points to a wiki and source code. I'll read into this and get back to you.

I get the impression with the ARM graphics, that you just have a lot of separate drivers for separate IP blocks all providing some misc random interfaces to userspace where some binary driver binds all the functionality together into a useful whole, which seems like a really bad design.

Generally on x86, the tiling hw is part of the GPU and is exposed as part of a coherent GPU driver.

I'm just wonder what the use-cases for this tiler are and what open apps can use it for?

Dave.

author
#18 lore raw
Quoted 7 lines · Dave Airlie

On Fri, Dec 17, 2010 at 5:02 AM, David Sin <[email protected]> wrote:
I get the impression with the ARM graphics, that you just have a lot of separate drivers for separate IP blocks all providing some misc random interfaces to userspace where some binary driver binds all the functionality together into a useful whole, which seems like a really bad design.

Quoted 7 lines

Generally on x86, the tiling hw is part of the GPU and is exposed as part of a coherent GPU driver.

I'm just wonder what the use-cases for this tiler are and what open apps can use it for?

Dave.

Yes -- on the omap4 soc, the dmm-tiler hw block is separate from the gpu. I've had some, but not much, past discusions on hw designs where graphics/video related ip blocks are part of the same core. It's a good point that you bring up and it certainly makes sense to me. I will bring it up with some omap hw folks that I know, and see if something that can be considered in future omap versions.

Some of the use-cases are HD video decoding and encoding. Also, hi-res image capture -- I believe 12MP or greater. OpenMax IL components and other multimedia frameworks can allocate video memory through a user space tiler library. Thanks for your comments, Dave.

Signature · 1 line
David Sin