[RFC,libdrm 2/3] tegra: Add 2d library

2012-12-28 Thread Mark Zhang
I just skimmed the code of libdrm while I'm trying to understand the
host1x driver. So below is what I found.

Mark
On 12/13/2012 10:01 PM, Arto Meril?inen wrote:
> From: Francis Hart 
> 
> This patch introduces a simple 2d library on top of stream library.
> 
> Signed-off-by: Francis Hart 
[...]
> +void
> +g2fill_dispatch(const struct tegra_2d_g2fill *hw,
> +struct tegra_stream *stream)
> +{
> +ASSERT(hw);
> +ASSERT(hw->is_valid);
> +ASSERT(stream);
> +
> +tegra_stream_push_setclass(stream, NV_GRAPHICS_2D_CLASS_ID);

I think at the end of the "tegra_stream_begin", we already pushed a
setclass opcode into the stream's active buffer.
So why we need another one here?

> +
> +tegra_stream_push_words(stream,
> +>block,
> +sizeof(hw->block) / sizeof(uint32_t),
> +1,
> +tegra_reloc(>block.dstba,
> +hw->dst_handle,
> +hw->dst_offset));
> +}
> +
[...]
> +#endif // TEGRA_2D_H
> 


[RFC,libdrm 2/3] tegra: Add 2d library

2012-12-13 Thread Arto Meriläinen
From: Francis Hart 

This patch introduces a simple 2d library on top of stream library.

Signed-off-by: Francis Hart 
---
 tegra/2d/hw_gr2d.h   | 2614 ++
 tegra/2d/tegra_2d_api.c  |  235 
 tegra/2d/tegra_2d_color.c|  412 +++
 tegra/2d/tegra_2d_color.h|   51 +
 tegra/2d/tegra_2d_context.c  |  140 +++
 tegra/2d/tegra_2d_context.h  |   67 ++
 tegra/2d/tegra_2d_copy.c |  209 
 tegra/2d/tegra_2d_copy.h |   38 +
 tegra/2d/tegra_2d_fill.c |  136 +++
 tegra/2d/tegra_2d_fill.h |   36 +
 tegra/2d/tegra_2d_frcopy.c   |  274 +
 tegra/2d/tegra_2d_frcopy.h   |   85 ++
 tegra/2d/tegra_2d_g2copy.c   |  272 +
 tegra/2d/tegra_2d_g2copy.h   |   88 ++
 tegra/2d/tegra_2d_g2fill.c   |  192 
 tegra/2d/tegra_2d_g2fill.h   |   80 ++
 tegra/2d/tegra_2d_reg_g2sb.h |   89 ++
 tegra/2d/tegra_2d_reg_host.h |  119 ++
 tegra/2d/tegra_2d_sbcopy.c   |  388 +++
 tegra/2d/tegra_2d_sbcopy.h   |   94 ++
 tegra/2d/tegra_2d_surface.c  |  280 +
 tegra/2d/tegra_2d_surface.h  |   57 +
 tegra/2d/tegra_2d_util.c |  145 +++
 tegra/2d/tegra_2d_util.h |   89 ++
 tegra/Makefile.am|   13 +-
 tegra/tegra_2d.h |  223 
 26 files changed, 6425 insertions(+), 1 deletion(-)
 create mode 100644 tegra/2d/hw_gr2d.h
 create mode 100644 tegra/2d/tegra_2d_api.c
 create mode 100644 tegra/2d/tegra_2d_color.c
 create mode 100644 tegra/2d/tegra_2d_color.h
 create mode 100644 tegra/2d/tegra_2d_context.c
 create mode 100644 tegra/2d/tegra_2d_context.h
 create mode 100644 tegra/2d/tegra_2d_copy.c
 create mode 100644 tegra/2d/tegra_2d_copy.h
 create mode 100644 tegra/2d/tegra_2d_fill.c
 create mode 100644 tegra/2d/tegra_2d_fill.h
 create mode 100644 tegra/2d/tegra_2d_frcopy.c
 create mode 100644 tegra/2d/tegra_2d_frcopy.h
 create mode 100644 tegra/2d/tegra_2d_g2copy.c
 create mode 100644 tegra/2d/tegra_2d_g2copy.h
 create mode 100644 tegra/2d/tegra_2d_g2fill.c
 create mode 100644 tegra/2d/tegra_2d_g2fill.h
 create mode 100644 tegra/2d/tegra_2d_reg_g2sb.h
 create mode 100644 tegra/2d/tegra_2d_reg_host.h
 create mode 100644 tegra/2d/tegra_2d_sbcopy.c
 create mode 100644 tegra/2d/tegra_2d_sbcopy.h
 create mode 100644 tegra/2d/tegra_2d_surface.c
 create mode 100644 tegra/2d/tegra_2d_surface.h
 create mode 100644 tegra/2d/tegra_2d_util.c
 create mode 100644 tegra/2d/tegra_2d_util.h
 create mode 100644 tegra/tegra_2d.h

diff --git a/tegra/2d/hw_gr2d.h b/tegra/2d/hw_gr2d.h
new file mode 100644
index 000..4c48feb
--- /dev/null
+++ b/tegra/2d/hw_gr2d.h
@@ -0,0 +1,2614 @@
+/*
+ * Copyright (C) 2012 NVIDIA Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+ /*
+  * Function naming determines intended use:
+  *
+  * _r(void) : Returns the offset for register .
+  *
+  * _w(void) : Returns the word offset for word (4 byte) element .
+  *
+  * __s(void) : Returns size of field  of register  in bits.
+  *
+  * __f(uint32_t v) : Returns a value based on 'v' which has been 
shifted
+  * and masked to place it at field  of register .  This value
+  * can be |'d with others to produce a full register value for
+  * register .
+  *
+  * __m(void) : Returns a mask for field  of register .  This
+  * value can be ~'d and then &'d to clear the value of field  for
+  * register .
+  *
+  * ___f(void) : Returns the constant value  after being 
shifted
+  * to place it at field  of register .  This value can be |'d
+  * with others to produce a full register value for .
+  *
+  * __v(uint32_t r) : Returns the value of field  from a full 
register
+  *  value 'r' after being shifted to place its LSB at bit 0.
+  * This value is suitable for direct comparison with other unshifted
+  * values appropriate for use in field  of register .
+  *
+  *