• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2024 Advanced Micro Devices, Inc.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a
4  * copy of this software and associated documentation files (the "Software"),
5  * to deal in the Software without restriction, including without limitation
6  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7  * and/or sell copies of the Software, and to permit persons to whom the
8  * Software is furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
17  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19  * OTHER DEALINGS IN THE SOFTWARE.
20  *
21  * Authors: AMD
22  *
23  */
24 #pragma once
25 
26 #include "cdc.h"
27 #include "reg_helper.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define VPE10_CDC_VUPDATE_OFFSET_DEFAULT (21)
34 #define VPE10_CDC_VUPDATE_WIDTH_DEFAULT  (60)
35 #define VPE10_CDC_VREADY_OFFSET_DEFAULT  (150)
36 
37 /* macros for filing variable or field list
38    SRI, SFRB should be defined in the resource file */
39 #define CDC_BE_REG_LIST_VPE10(id)                                                                  \
40     SRIDFVL(VPCDC_BE0_P2B_CONFIG, CDC, id), SRIDFVL(VPCDC_BE0_GLOBAL_SYNC_CONFIG, CDC, id)
41 
42 #define CDC_BE_FIELD_LIST_VPE10(post_fix)                                                          \
43     SFRB(VPCDC_BE0_P2B_XBAR_SEL0, VPCDC_BE0_P2B_CONFIG, post_fix),                                 \
44         SFRB(VPCDC_BE0_P2B_XBAR_SEL1, VPCDC_BE0_P2B_CONFIG, post_fix),                             \
45         SFRB(VPCDC_BE0_P2B_XBAR_SEL2, VPCDC_BE0_P2B_CONFIG, post_fix),                             \
46         SFRB(VPCDC_BE0_P2B_XBAR_SEL3, VPCDC_BE0_P2B_CONFIG, post_fix),                             \
47         SFRB(VPCDC_BE0_P2B_FORMAT_SEL, VPCDC_BE0_P2B_CONFIG, post_fix),                            \
48         SFRB(BE0_VUPDATE_OFFSET, VPCDC_BE0_GLOBAL_SYNC_CONFIG, post_fix),                          \
49         SFRB(BE0_VUPDATE_WIDTH, VPCDC_BE0_GLOBAL_SYNC_CONFIG, post_fix),                           \
50         SFRB(BE0_VREADY_OFFSET, VPCDC_BE0_GLOBAL_SYNC_CONFIG, post_fix)
51 /* define all structure register variables below */
52 #define CDC_BE_REG_VARIABLE_LIST_VPE10                                                             \
53     reg_id_val VPCDC_BE0_P2B_CONFIG;                                                               \
54     reg_id_val VPCDC_BE0_GLOBAL_SYNC_CONFIG;
55 
56 #define CDC_BE_FIELD_VARIABLE_LIST_VPE10(type)                                                     \
57     type VPCDC_BE0_P2B_XBAR_SEL0;                                                                  \
58     type VPCDC_BE0_P2B_XBAR_SEL1;                                                                  \
59     type VPCDC_BE0_P2B_XBAR_SEL2;                                                                  \
60     type VPCDC_BE0_P2B_XBAR_SEL3;                                                                  \
61     type VPCDC_BE0_P2B_FORMAT_SEL;                                                                 \
62     type BE0_VUPDATE_OFFSET;                                                                       \
63     type BE0_VUPDATE_WIDTH;                                                                        \
64     type BE0_VREADY_OFFSET;
65 
66 struct vpe10_cdc_be_registers {
67     CDC_BE_REG_VARIABLE_LIST_VPE10
68 };
69 
70 struct vpe10_cdc_be_shift {
71     CDC_BE_FIELD_VARIABLE_LIST_VPE10(uint8_t)
72 };
73 
74 struct vpe10_cdc_be_mask {
75     CDC_BE_FIELD_VARIABLE_LIST_VPE10(uint32_t)
76 };
77 
78 struct vpe10_cdc_be {
79     struct cdc_be                    base; // base class, must be the first field
80     struct vpe10_cdc_be_registers   *regs;
81     const struct vpe10_cdc_be_shift *shift;
82     const struct vpe10_cdc_be_mask  *mask;
83 };
84 
85 void vpe10_construct_cdc_be(struct vpe_priv *vpe_priv, struct cdc_be *cdc_be);
86 
87 bool vpe10_cdc_check_output_format(struct cdc_be *cdc_be, enum vpe_surface_pixel_format format);
88 
89 void vpe10_cdc_program_global_sync(
90     struct cdc_be *cdc_be, uint32_t vupdate_offset, uint32_t vupdate_width, uint32_t vready_offset);
91 
92 void vpe10_cdc_program_p2b_config(struct cdc_be *cdc_be, enum vpe_surface_pixel_format format,
93     enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport,
94     const struct vpe_rect *viewport_c);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99