From c9e8b49b885242d84ba031dacef5aa4a5ac1e5b6 Mon Sep 17 00:00:00 2001 From: The etnaviv authors Date: Fri, 23 Dec 2016 20:58:23 +0100 Subject: etnaviv: gallium driver for Vivante GPUs This driver supports a wide range of Vivante IP cores like GC880, GC1000, GC2000 and GC3000. Changes from V1 -> V2: - added missing files to actually integrate the driver into build system. - adapted driver to new renderonly API Signed-off-by: Christian Gmeiner Signed-off-by: Lucas Stach Signed-off-by: Philipp Zabel Signed-off-by: Rob Herring Signed-off-by: Russell King Signed-off-by: Wladimir J. van der Laan Acked-by: Emil Velikov --- src/gallium/drivers/etnaviv/etnaviv_emit.h | 123 +++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/gallium/drivers/etnaviv/etnaviv_emit.h (limited to 'src/gallium/drivers/etnaviv/etnaviv_emit.h') diff --git a/src/gallium/drivers/etnaviv/etnaviv_emit.h b/src/gallium/drivers/etnaviv/etnaviv_emit.h new file mode 100644 index 00000000000..6a3c77286d3 --- /dev/null +++ b/src/gallium/drivers/etnaviv/etnaviv_emit.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2012-2015 Etnaviv Project + * + * 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, sub license, + * 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 NON-INFRINGEMENT. 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. + * + * Authors: + * Wladimir J. van der Laan + */ + +#ifndef H_ETNA_EMIT +#define H_ETNA_EMIT + +#include "etnaviv_screen.h" +#include "etnaviv_util.h" +#include "hw/cmdstream.xml.h" + +struct etna_context; +struct compiled_rs_state; + +static inline void +etna_emit_load_state(struct etna_cmd_stream *stream, const uint16_t offset, + const uint16_t count, const int fixp) +{ + uint32_t v; + + v = VIV_FE_LOAD_STATE_HEADER_OP_LOAD_STATE | + COND(fixp, VIV_FE_LOAD_STATE_HEADER_FIXP) | + VIV_FE_LOAD_STATE_HEADER_OFFSET(offset) | + (VIV_FE_LOAD_STATE_HEADER_COUNT(count) & + VIV_FE_LOAD_STATE_HEADER_COUNT__MASK); + + etna_cmd_stream_emit(stream, v); +} + +static inline void +etna_set_state(struct etna_cmd_stream *stream, uint32_t address, uint32_t value) +{ + etna_cmd_stream_reserve(stream, 2); + etna_emit_load_state(stream, address >> 2, 1, 0); + etna_cmd_stream_emit(stream, value); +} + +static inline void +etna_set_state_reloc(struct etna_cmd_stream *stream, uint32_t address, + struct etna_reloc *reloc) +{ + etna_cmd_stream_reserve(stream, 2); + etna_emit_load_state(stream, address >> 2, 1, 0); + etna_cmd_stream_reloc(stream, reloc); +} + +static inline void +etna_set_state_multi(struct etna_cmd_stream *stream, uint32_t base, + uint32_t num, const uint32_t *values) +{ + if (num == 0) + return; + + etna_cmd_stream_reserve(stream, 1 + num + 1); /* 1 extra for potential alignment */ + etna_emit_load_state(stream, base >> 2, num, 0); + + for (uint32_t i = 0; i < num; i++) + etna_cmd_stream_emit(stream, values[i]); + + /* add potential padding */ + if ((num % 2) == 0) + etna_cmd_stream_emit(stream, 0); +} + +void +etna_stall(struct etna_cmd_stream *stream, uint32_t from, uint32_t to); + +void +etna_submit_rs_state(struct etna_context *ctx, const struct compiled_rs_state *cs); + +static inline void +etna_draw_primitives(struct etna_cmd_stream *stream, uint32_t primitive_type, + uint32_t start, uint32_t count) +{ + etna_cmd_stream_reserve(stream, 4); + + etna_cmd_stream_emit(stream, VIV_FE_DRAW_PRIMITIVES_HEADER_OP_DRAW_PRIMITIVES); + etna_cmd_stream_emit(stream, primitive_type); + etna_cmd_stream_emit(stream, start); + etna_cmd_stream_emit(stream, count); +} + +static inline void +etna_draw_indexed_primitives(struct etna_cmd_stream *stream, + uint32_t primitive_type, uint32_t start, + uint32_t count, uint32_t offset) +{ + etna_cmd_stream_reserve(stream, 5 + 1); + + etna_cmd_stream_emit(stream, VIV_FE_DRAW_INDEXED_PRIMITIVES_HEADER_OP_DRAW_INDEXED_PRIMITIVES); + etna_cmd_stream_emit(stream, primitive_type); + etna_cmd_stream_emit(stream, start); + etna_cmd_stream_emit(stream, count); + etna_cmd_stream_emit(stream, offset); + etna_cmd_stream_emit(stream, 0); +} + +void +etna_emit_state(struct etna_context *ctx); + +#endif -- cgit v1.2.3