1b8e80941Smrg/*
2b8e80941Smrg * Copyright © 2016-2018 Broadcom
3b8e80941Smrg *
4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
6b8e80941Smrg * to deal in the Software without restriction, including without limitation
7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
9b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
10b8e80941Smrg *
11b8e80941Smrg * The above copyright notice and this permission notice (including the next
12b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
13b8e80941Smrg * Software.
14b8e80941Smrg *
15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21b8e80941Smrg * IN THE SOFTWARE.
22b8e80941Smrg */
23b8e80941Smrg
24b8e80941Smrg#include "v3d_compiler.h"
25b8e80941Smrg
26b8e80941Smrg/* We don't do any address packing. */
27b8e80941Smrg#define __gen_user_data void
28b8e80941Smrg#define __gen_address_type uint32_t
29b8e80941Smrg#define __gen_address_offset(reloc) (*reloc)
30b8e80941Smrg#define __gen_emit_reloc(cl, reloc)
31b8e80941Smrg#include "broadcom/cle/v3d_packet_v33_pack.h"
32b8e80941Smrg
33b8e80941Smrgvoid
34b8e80941Smrgv3d33_vir_vpm_read_setup(struct v3d_compile *c, int num_components)
35b8e80941Smrg{
36b8e80941Smrg        struct V3D33_VPM_GENERIC_BLOCK_READ_SETUP unpacked = {
37b8e80941Smrg                V3D33_VPM_GENERIC_BLOCK_READ_SETUP_header,
38b8e80941Smrg
39b8e80941Smrg                .horiz = true,
40b8e80941Smrg                .laned = false,
41b8e80941Smrg                /* If the field is 0, that means a read count of 32. */
42b8e80941Smrg                .num = num_components & 31,
43b8e80941Smrg                .segs = true,
44b8e80941Smrg                .stride = 1,
45b8e80941Smrg                .size = VPM_SETUP_SIZE_32_BIT,
46b8e80941Smrg                .addr = c->num_inputs,
47b8e80941Smrg        };
48b8e80941Smrg
49b8e80941Smrg        uint32_t packed;
50b8e80941Smrg        V3D33_VPM_GENERIC_BLOCK_READ_SETUP_pack(NULL,
51b8e80941Smrg                                                (uint8_t *)&packed,
52b8e80941Smrg                                                &unpacked);
53b8e80941Smrg        vir_VPMSETUP(c, vir_uniform_ui(c, packed));
54b8e80941Smrg}
55b8e80941Smrg
56b8e80941Smrgvoid
57b8e80941Smrgv3d33_vir_vpm_write_setup(struct v3d_compile *c)
58b8e80941Smrg{
59b8e80941Smrg        uint32_t packed;
60b8e80941Smrg        struct V3D33_VPM_GENERIC_BLOCK_WRITE_SETUP unpacked = {
61b8e80941Smrg                V3D33_VPM_GENERIC_BLOCK_WRITE_SETUP_header,
62b8e80941Smrg
63b8e80941Smrg                .horiz = true,
64b8e80941Smrg                .laned = false,
65b8e80941Smrg                .segs = true,
66b8e80941Smrg                .stride = 1,
67b8e80941Smrg                .size = VPM_SETUP_SIZE_32_BIT,
68b8e80941Smrg                .addr = 0,
69b8e80941Smrg        };
70b8e80941Smrg
71b8e80941Smrg        V3D33_VPM_GENERIC_BLOCK_WRITE_SETUP_pack(NULL,
72b8e80941Smrg                                                (uint8_t *)&packed,
73b8e80941Smrg                                                &unpacked);
74b8e80941Smrg        vir_VPMSETUP(c, vir_uniform_ui(c, packed));
75b8e80941Smrg}
76