1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef __MMSCH_V1_0_H__
25#define __MMSCH_V1_0_H__
26
27#define MMSCH_VERSION_MAJOR 1
28#define MMSCH_VERSION_MINOR 0
29#define MMSCH_VERSION (MMSCH_VERSION_MAJOR << 16 | MMSCH_VERSION_MINOR)
30
31enum mmsch_v1_0_command_type {
32 MMSCH_COMMAND__DIRECT_REG_WRITE = 0,
33 MMSCH_COMMAND__DIRECT_REG_POLLING = 2,
34 MMSCH_COMMAND__DIRECT_REG_READ_MODIFY_WRITE = 3,
35 MMSCH_COMMAND__INDIRECT_REG_WRITE = 8,
36 MMSCH_COMMAND__END = 0xf
37};
38
39struct mmsch_v1_0_init_header {
40 uint32_t version;
41 uint32_t header_size;
42 uint32_t vce_init_status;
43 uint32_t uvd_init_status;
44 uint32_t vce_table_offset;
45 uint32_t vce_table_size;
46 uint32_t uvd_table_offset;
47 uint32_t uvd_table_size;
48};
49
50struct mmsch_vf_eng_init_header {
51 uint32_t init_status;
52 uint32_t table_offset;
53 uint32_t table_size;
54};
55
56struct mmsch_v1_1_init_header {
57 uint32_t version;
58 uint32_t total_size;
59 struct mmsch_vf_eng_init_header eng[2];
60};
61
62struct mmsch_v1_0_cmd_direct_reg_header {
63 uint32_t reg_offset : 28;
64 uint32_t command_type : 4;
65};
66
67struct mmsch_v1_0_cmd_indirect_reg_header {
68 uint32_t reg_offset : 20;
69 uint32_t reg_idx_space : 8;
70 uint32_t command_type : 4;
71};
72
73struct mmsch_v1_0_cmd_direct_write {
74 struct mmsch_v1_0_cmd_direct_reg_header cmd_header;
75 uint32_t reg_value;
76};
77
78struct mmsch_v1_0_cmd_direct_read_modify_write {
79 struct mmsch_v1_0_cmd_direct_reg_header cmd_header;
80 uint32_t write_data;
81 uint32_t mask_value;
82};
83
84struct mmsch_v1_0_cmd_direct_polling {
85 struct mmsch_v1_0_cmd_direct_reg_header cmd_header;
86 uint32_t mask_value;
87 uint32_t wait_value;
88};
89
90struct mmsch_v1_0_cmd_end {
91 struct mmsch_v1_0_cmd_direct_reg_header cmd_header;
92};
93
94struct mmsch_v1_0_cmd_indirect_write {
95 struct mmsch_v1_0_cmd_indirect_reg_header cmd_header;
96 uint32_t reg_value;
97};
98
99static inline void mmsch_v1_0_insert_direct_wt(struct mmsch_v1_0_cmd_direct_write *direct_wt,
100 uint32_t *init_table,
101 uint32_t reg_offset,
102 uint32_t value)
103{
104 direct_wt->cmd_header.reg_offset = reg_offset;
105 direct_wt->reg_value = value;
106 memcpy((void *)init_table, direct_wt, sizeof(struct mmsch_v1_0_cmd_direct_write));
107}
108
109static inline void mmsch_v1_0_insert_direct_rd_mod_wt(struct mmsch_v1_0_cmd_direct_read_modify_write *direct_rd_mod_wt,
110 uint32_t *init_table,
111 uint32_t reg_offset,
112 uint32_t mask, uint32_t data)
113{
114 direct_rd_mod_wt->cmd_header.reg_offset = reg_offset;
115 direct_rd_mod_wt->mask_value = mask;
116 direct_rd_mod_wt->write_data = data;
117 memcpy((void *)init_table, direct_rd_mod_wt,
118 sizeof(struct mmsch_v1_0_cmd_direct_read_modify_write));
119}
120
121static inline void mmsch_v1_0_insert_direct_poll(struct mmsch_v1_0_cmd_direct_polling *direct_poll,
122 uint32_t *init_table,
123 uint32_t reg_offset,
124 uint32_t mask, uint32_t wait)
125{
126 direct_poll->cmd_header.reg_offset = reg_offset;
127 direct_poll->mask_value = mask;
128 direct_poll->wait_value = wait;
129 memcpy((void *)init_table, direct_poll, sizeof(struct mmsch_v1_0_cmd_direct_polling));
130}
131
132#define MMSCH_V1_0_INSERT_DIRECT_RD_MOD_WT(reg, mask, data) { \
133 mmsch_v1_0_insert_direct_rd_mod_wt(&direct_rd_mod_wt, \
134 init_table, (reg), \
135 (mask), (data)); \
136 init_table += sizeof(struct mmsch_v1_0_cmd_direct_read_modify_write)/4; \
137 table_size += sizeof(struct mmsch_v1_0_cmd_direct_read_modify_write)/4; \
138}
139
140#define MMSCH_V1_0_INSERT_DIRECT_WT(reg, value) { \
141 mmsch_v1_0_insert_direct_wt(&direct_wt, \
142 init_table, (reg), \
143 (value)); \
144 init_table += sizeof(struct mmsch_v1_0_cmd_direct_write)/4; \
145 table_size += sizeof(struct mmsch_v1_0_cmd_direct_write)/4; \
146}
147
148#define MMSCH_V1_0_INSERT_DIRECT_POLL(reg, mask, wait) { \
149 mmsch_v1_0_insert_direct_poll(&direct_poll, \
150 init_table, (reg), \
151 (mask), (wait)); \
152 init_table += sizeof(struct mmsch_v1_0_cmd_direct_polling)/4; \
153 table_size += sizeof(struct mmsch_v1_0_cmd_direct_polling)/4; \
154}
155
156#endif
157