Skip to content

Commit 254a2ac

Browse files
jannaumarcan
authored andcommitted
dcp_iboot: Support macOS 13.3 DCP firmware
The macOS 13.3 DCP firmware extended swap_set_layer_cmd in an incompatible way. Let dcp_ib_swap_set_layer() send the matching struct based on the firmware version. Signed-off-by: Janne Grunau <[email protected]>
1 parent 01ea1ae commit 254a2ac

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

src/dcp_iboot.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "dcp_iboot.h"
44
#include "afk.h"
55
#include "assert.h"
6+
#include "firmware.h"
67
#include "malloc.h"
78
#include "string.h"
89
#include "utils.h"
@@ -85,6 +86,17 @@ struct swap_set_layer_cmd {
8586
u32 unk2;
8687
} PACKED;
8788

89+
struct swap_set_layer_cmd_v13_3 {
90+
u32 unk;
91+
u32 layer_id;
92+
dcp_layer_t layer;
93+
u32 unk3; // possibly part of layer
94+
u32 unk4; // possibly part of layer
95+
dcp_rect_t src;
96+
dcp_rect_t dst;
97+
u32 unk2;
98+
} PACKED;
99+
88100
dcp_iboot_if_t *dcp_ib_init(dcp_dev_t *dcp)
89101
{
90102
dcp_iboot_if_t *iboot = malloc(sizeof(dcp_iboot_if_t));
@@ -204,8 +216,8 @@ int dcp_ib_swap_begin(dcp_iboot_if_t *iboot)
204216
return resp->swap_id;
205217
}
206218

207-
int dcp_ib_swap_set_layer(dcp_iboot_if_t *iboot, int layer_id, dcp_layer_t *layer,
208-
dcp_rect_t *src_rect, dcp_rect_t *dst_rect)
219+
static int swap_set_layer_v12_3(dcp_iboot_if_t *iboot, int layer_id, dcp_layer_t *layer,
220+
dcp_rect_t *src_rect, dcp_rect_t *dst_rect)
209221
{
210222
struct swap_set_layer_cmd *cmd = (void *)iboot->txcmd.payload;
211223
memset(cmd, 0, sizeof(*cmd));
@@ -217,6 +229,28 @@ int dcp_ib_swap_set_layer(dcp_iboot_if_t *iboot, int layer_id, dcp_layer_t *laye
217229
return dcp_ib_cmd(iboot, IBOOT_SWAP_SET_LAYER, sizeof(*cmd));
218230
}
219231

232+
static int swap_set_layer_v13_3(dcp_iboot_if_t *iboot, int layer_id, dcp_layer_t *layer,
233+
dcp_rect_t *src_rect, dcp_rect_t *dst_rect)
234+
{
235+
struct swap_set_layer_cmd_v13_3 *cmd = (void *)iboot->txcmd.payload;
236+
memset(cmd, 0, sizeof(*cmd));
237+
cmd->layer_id = layer_id;
238+
cmd->layer = *layer;
239+
cmd->src = *src_rect;
240+
cmd->dst = *dst_rect;
241+
242+
return dcp_ib_cmd(iboot, IBOOT_SWAP_SET_LAYER, sizeof(*cmd));
243+
}
244+
245+
int dcp_ib_swap_set_layer(dcp_iboot_if_t *iboot, int layer_id, dcp_layer_t *layer,
246+
dcp_rect_t *src_rect, dcp_rect_t *dst_rect)
247+
{
248+
if (os_firmware.version < V13_3)
249+
return swap_set_layer_v12_3(iboot, layer_id, layer, src_rect, dst_rect);
250+
else
251+
return swap_set_layer_v13_3(iboot, layer_id, layer, src_rect, dst_rect);
252+
}
253+
220254
int dcp_ib_swap_end(dcp_iboot_if_t *iboot)
221255
{
222256
memset(iboot->txcmd.payload, 0, 12);

0 commit comments

Comments
 (0)